[lxc-users] Does cpu cgroup has been enabled in lxc/lxd

kemi kemi.wang at intel.com
Thu Nov 1 05:35:04 UTC 2018

Hi, Fajar
  thx for your reply.

On 2018/11/1 下午1:26, Fajar A. Nugraha wrote:
> On Thu, Nov 1, 2018 at 8:55 AM, kemi <kemi.wang at intel.com> wrote:
>> Hi, Everyone
>>    I am new comer of LXC/LXD community, and want to run a container on a
>> limited cpu set.
>>   The followings are my steps:
>>   a) lxd init
>>   b) lxc launch Ubuntu:18.04 first
>>   c) lxc stop first
>>   d) lxc config set first limits.cpu 0  // set container running on CPU 0
> I'm not sure, but I believe "0" here means all cpu, and not pin to cpu 0?

Hmm, I expected to pin on CPU 0. Seems I misunderstood the *limit* configuration here:)
I will try use another number as you suggested.

> Try changing this to "1", "0-0", and "1-2". Observe the difference.
>>   e) lxc start first
>>   f) lxc exec first -- bash
>>   g) nproc   // the expected result would be 1, however, it still equals
>> to cpu number of host
>>   h) ls /sys/devices/system/cpu   // the expected result should only
>> include cpu0 directory, however, it's not
> g) and h) read files from /proc, not cgroup. You need lxcfs. You should
> already have that on ubuntu though.

Hmm, I will take a look at it. thx for suggestion

>> So, it seems that CPU cgroup has not been enabled in LXC/LXD, right?  The
>> version of lxc is 2.0.11 on Ubuntu 16.04.
>> Anyone can help me on that, thx very much.
> If this is a new install, I highly suggest you just switch to ubuntu 18.04
> + lxd-3 host.

Lxd has a simple online testing using lxd-3.6. May I use it for testing purpose?

> If you simply want to have "correct" /proc entries, make sure lxcfs is
> installed, and then restart lxd (if needed).

Not only I want to get correct number of cpus in container, but still hope to have independent
procfs and sysfs virtualized in container.

> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users

More information about the lxc-users mailing list