Thanks Daniel<br>It's clear now!! And the test with lxc-execute works perfect!!<br>I will continue searchs for  memory on demand.<br>May be someone here is familiar with that!!<br><br><div class="gmail_quote">On 6 May 2010 11:37, Daniel Lezcano <span dir="ltr"><<a href="mailto:daniel.lezcano@free.fr">daniel.lezcano@free.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">Yanick Emiliano wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi everybody,<br>
I have just started playing with lxc and having some difficulties to set cpu<br>
and memory on my guests. After my searches, seems that resources controlling<br>
is managing in cgroup files and I think that I missed something or I didn't<br>
understand how deal with cgroup.<br>
<br>
After reading cgroup documentation, I understand that:<br>
- *cpuset.cpus* indicate to a container the number of cpu available<br>
</blockquote>
<br></div>
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,<br>
0-15 which means cpu number 0 to cpu number 15 is used by the cgroup.<br>
<br>
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".<br>
<br>
If you want to assign the cpu 1,2,3 to the container, "echo 1,2,3 > /cgroup/<name>/cpuset.cpus".<br>
<br>
If you want to assign cpu 0 up to 7 to the container, "echo 0-7 > /cgroup/<name>/cpuset.cpus".<br>
<br>
<br>
In the context of lxc.<br>
<br>
lxc-execute -n foo -s lxc.cgroup.cpuset.cpus="1,2,3" myforks<br>
<br>
etc ...<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
-*cpuset.cpu_exclusive* limit the number of cpu which the container can use.<div class="im"><br>
Am I in good way?<br>
</div></blockquote>
<br>
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.<div class="im">
<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
For example , can I tell to my container that there are 2 cpu available (*<br>
cpuset.cpus)*, but use one generally (*puset.cpu_exclusive)*, use the second<br>
one only  when it's necessary (when there are a  lot of application to run)?<br>
</blockquote>
<br></div>
cpu on demand ? :)<br>
<br>
Hey, externally look at the cpu usage of the container, when it reach a threshold you define, assign another cpu to the container.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
What I want is manage QoS with my containers.<br>
</blockquote>
<br></div>
Very likely, you are looking for the cgroup fair scheduler, it would be better than dynamically assign cpus to the container, IMHO.<br>
<br>
<a href="http://lwn.net/Articles/240474/" target="_blank">http://lwn.net/Articles/240474/</a><br>
<br>
It's /cgroup/<name>/cpu.shares<br>
<br>
Create 2 containers,<br>
<br>
lxc-execute -n foo -s lxc.cgroup.cpu.shares=1 /bin/bash<br>
<br>
in another shell<br>
<br>
lxc-execute -n bar -s /bin/bash<br>
<br>
<br>
in both shell, do "while $(true); do echo -n . ; done"<br>
<br>
You will see "foo" displaying the dots veeeery slowly and bar being at the normal speed.<br>
<br>
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".<br>
<br>
You can dynamically change the priority of the container with "lxc-cgroup -n foo cpu.shares=1024" for example.<div class="im"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
And my last question is, Can I do the same thing with memory sharing?<br>
</blockquote>
<br></div>
memory on demand :)<br>
<br>
I will let someone else to add comments here, as I am not very familiar with memory vs cgroup.<br>
<br>
Thanks<br><font color="#888888">
  -- Daniel<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Yanick HOUNGBEJI<br><br><br>