Thanks Daniel It's clear now!! And the test with lxc-execute works perfect!! I will continue searchs for memory on demand. May be someone here is familiar with that!!
On 6 May 2010 11:37, Daniel Lezcano <daniel.lezc...@free.fr> wrote: > Yanick Emiliano wrote: > >> Hi everybody, >> I have just started playing with lxc and having some difficulties to set >> cpu >> and memory on my guests. After my searches, seems that resources >> controlling >> is managing in cgroup files and I think that I missed something or I >> didn't >> understand how deal with cgroup. >> >> After reading cgroup documentation, I understand that: >> - *cpuset.cpus* indicate to a container the number of cpu available >> > > No exactly, it's a mask of usable cpus for the container. Let's imagine you > have a 16 cpus machine. The content of cpuset.cpus will be, > 0-15 which means cpu number 0 to cpu number 15 is used by the cgroup. > > If you want to assign the cpu 1 (second cpu) to the container, you have to > set it by "echo 1 > /cgroup/<name>/cpuset.cpus". > > If you want to assign the cpu 1,2,3 to the container, "echo 1,2,3 > > /cgroup/<name>/cpuset.cpus". > > If you want to assign cpu 0 up to 7 to the container, "echo 0-7 > > /cgroup/<name>/cpuset.cpus". > > > In the context of lxc. > > lxc-execute -n foo -s lxc.cgroup.cpuset.cpus="1,2,3" myforks > > etc ... > > -*cpuset.cpu_exclusive* limit the number of cpu which the container can >> use. >> >> Am I in good way? >> > > When you assigned the cpus to the container, the processes of the container > will run on these cpus only but that does not prevent the other tasks of the > system to run on these cpus. If you want the cpus to be used by the > container *only*, set them 'exclusive'. This is what I understood. > > > For example , can I tell to my container that there are 2 cpu available (* >> cpuset.cpus)*, but use one generally (*puset.cpu_exclusive)*, use the >> second >> one only when it's necessary (when there are a lot of application to >> run)? >> > > cpu on demand ? :) > > Hey, externally look at the cpu usage of the container, when it reach a > threshold you define, assign another cpu to the container. > > > What I want is manage QoS with my containers. >> > > Very likely, you are looking for the cgroup fair scheduler, it would be > better than dynamically assign cpus to the container, IMHO. > > http://lwn.net/Articles/240474/ > > It's /cgroup/<name>/cpu.shares > > Create 2 containers, > > lxc-execute -n foo -s lxc.cgroup.cpu.shares=1 /bin/bash > > in another shell > > lxc-execute -n bar -s /bin/bash > > > in both shell, do "while $(true); do echo -n . ; done" > > You will see "foo" displaying the dots veeeery slowly and bar being at the > normal speed. > > As soon as "bar" exits or is frozen (via lxc-freeze), "foo" works at normal > speed as it is no longer competing the cpu with "bar". > > You can dynamically change the priority of the container with "lxc-cgroup > -n foo cpu.shares=1024" for example. > > > > And my last question is, Can I do the same thing with memory sharing? >> > > memory on demand :) > > I will let someone else to add comments here, as I am not very familiar > with memory vs cgroup. > > Thanks > -- Daniel > -- Yanick HOUNGBEJI
------------------------------------------------------------------------------
_______________________________________________ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users