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

kemi kemi.wang at intel.com
Thu Nov 1 06:38:38 UTC 2018



On 2018/11/1 下午1:35, kemi wrote:
> 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.
>>

have tried. `nproc` works well.

>>
>>>   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.
>>
>>

/proc/cpuinfo also matches the expected result.
However, it seems that sysfs in container  still shares with host /sys file system.
Right?


> 


More information about the lxc-users mailing list