[lxc-users] Number of core for a container

Fajar A. Nugraha list at fajar.net
Fri Nov 10 13:14:55 UTC 2017


Disclaimer: I no longer use lxc. Mostly lxd nowadays.

I can point you to some documentation on the web though, hopefully that
helps

On Fri, Nov 10, 2017 at 7:29 PM, Thouraya TH <thouraya87 at gmail.com> wrote:

> Hi all,
>
> I have used this command to fix cpu cores on which we have set running
> containers.
>
> root at g-105:~# lxc-cgroup -n worker cpuset.cpus 0
> root at g-105:~# lxc-cgroup -n worker cpuset.cpus 1
> root at g-105:~# lxc-cgroup -n worker cpuset.cpus 2
> root at g--105:~# lxc-cgroup -n worker cpuset.cpus 3
>
> root at g-105:~# lxc-cgroup -n worker cpuset.cpus 4
> lxc_container: cgmanager.c: do_cgm_set: 1022 Error setting cgroup value
> cpuset.cpus for cpuset:/lxc
> lxc_container: cgmanager.c: do_cgm_set: 1023 call to
> cgmanager_set_value_sync failed: invalid request
> lxc_container: lxc_cgroup.c: main: 103 failed to assign '4' value to
> 'cpuset.cpus' for 'worker'
>
> --> i have only 4 cores
>


... and what is your question here, if any? The cpuset cgroup is working as
intended, since there's no 'cpu 4' on your system.


>
> root at g-105:~# lxc-cgroup -n workerTest cpuset.cpus 0,1,2,3
> root at g-105:~# lxc-cgroup -n workerTest cpuset.cpus 0,1,2
>
> Please, is there a command to display containers and list of cores used by
> each container ?
>

Probably the combination of lxc-ls and lxc-cgroup.

'lxc-cgroup -n workerTest cpuset.cpus' will show you its current values.
See
- http://man7.org/linux/man-pages/man1/lxc-cgroup.1.html
- https://linuxcontainers.org/lxc/manpages/man1/lxc-ls.1.html



> A second question please,  can i fix that only container 1 uses  cpu 2,3 *(exclusive
> use)* or not ? i.e container 2 CANNOT use cpu 2,3
>
>

Try https://linuxcontainers.org/lxc/manpages/man5/lxc.container.conf.5.html,
'control group' section. And
https://www.kernel.org/doc/Documentation/cgroup-v1/cpusets.txt, search
for 'cpuset.cpu_exclusive'.
You could probably try (in container 1's config)

lxc.cgroup.cpuset.cpu_exclusive = 1
lxc.cgroup.cpuset.cpus = 2,3

It might work if no other cgroups currently explicitly use cpu 2-3.

-- 
Fajar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20171110/756ba664/attachment.html>


More information about the lxc-users mailing list