<div class="gmail_quote">2009/8/24 Krzysztof Taraszka <span dir="ltr"><<a href="mailto:krzysztof.taraszka@gnuhosting.net">krzysztof.taraszka@gnuhosting.net</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br><div class="gmail_quote">2009/8/24 Krzysztof Taraszka <span dir="ltr"><<a href="mailto:krzysztof.taraszka@gnuhosting.net" target="_blank">krzysztof.taraszka@gnuhosting.net</a>></span><div><div></div><div class="h5">
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div>2009/8/24 Daniel Lezcano <span dir="ltr"><<a href="mailto:daniel.lezcano@free.fr" target="_blank">daniel.lezcano@free.fr</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


<div><div></div><div>Krzysztof Taraszka wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2009/8/24 Daniel Lezcano <<a href="mailto:daniel.lezcano@free.fr" target="_blank">daniel.lezcano@free.fr</a>><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
[ snip ]<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
 i think that /proc/meminfo should be mounted after /proc . why? i think<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



that, because mounting /proc may override /proc/meminfo<br>
Am I right? :)<br>
<br>
<br>
<br>
<br>
</blockquote>
Ha ! haha ! arrgh ! no way ! You are right :/<br>
<br>
<br>
<br>
</blockquote>
Hehe ;)<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
In the case of application container, lxc mounts /proc but in the case of<br>
system container it is the system who do that so after the /proc/meminfo<br>
has<br>
been mounted.<br>
<br>
Maybe we can look at modifying fs/proc/meminfo.c instead. Let me do a<br>
small<br>
patch for the kernel...<br>
<br>
<br>
<br>
<br>
</blockquote>
Okey. I am waiting for your patch :)<br>
<br>
</blockquote>
Quick and dirty patch but at least working. It is no synced on the latest<br>
kernel version.<br>
I do not really like to touch fs/proc/meminfo.c but it's an example here.<br>
<br>
</blockquote>
<br>
<br>
Hi Daniel,<br>
<br>
I tried to compile my kernel tree (2.6.30.5) with your patch using gcc-4.4,<br>
gcc-4.3 and gcc-4.2 and i got this error on every gcc when linking kernel:<br>
<br>
mm/built-in.o: In function `mem_cgroup_info':<br>
(.text+0x27651): undefined reference to `__udivdi3'<br>
mm/built-in.o: In function `mem_cgroup_info':<br>
(.text+0x27678): undefined reference to `__udivdi3'<br>
mm/built-in.o: In function `mem_cgroup_info':<br>
(.text+0x276b0): undefined reference to `__udivdi3'<br>
mm/built-in.o: In function `mem_cgroup_info':<br>
(.text+0x276dd): undefined reference to `__udivdi3'<br>
make: *** [.tmp_vmlinux1] Error 1<br>
<br>
this can be gcc based error. What kernel and gcc did you use for compile<br>
your kernel?<br>
</blockquote>
<br></div></div>
I used a 2.6.30 kernel and<br>
gcc (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)<br>
Compiled on a x86_64 host.<br>
<br>
Do you have any warning at the compile time ?<br>
<br>
</blockquote></div><br></div></div>No, did not see any warnings when memcontrol.c or fs/meminfo.c was compiled.<br>Anyway, I will try to build in on the stable (lenny) version of debian (right now I am working on unstable debian tree).<br>


That might be gcc from unstable problem.<br><br>I will let you know what exactly problem is.<br><br></blockquote></div></div><div><br>ok Daniel,<br><br>i found a problem. I am runnning my debian box under vmware 32bit box so your patch can not be compiled propertly on the 32bit system, so I decided to make a little change in your patch.<br>

I used shift operation instead of div. in the asm/div64.h is macro do_div() but using shift instead of div is easier that implementing do_div macro, so<br>here is a small patch:<br><br>--- memcontrol.c.orig    2009-08-24 21:19:36.000000000 +0200<br>

+++ memcontrol.c    2009-08-24 21:20:37.000000000 +0200<br>@@ -1834,14 +1834,13 @@<br>         si_swapinfo(info);<br> <br>     if (limit != LLONG_MAX) {<br>-        info->totalram = limit / info->mem_unit;<br>-        info->freeram = (limit - mystat.stat[MCS_RSS]) / info->mem_unit;<br>

+        info->totalram = limit >> info->mem_unit;<br>+        info->freeram = (limit - mystat.stat[MCS_RSS]) >> info->mem_unit;<br>     }<br> <br>     if (memsw_limit != LLONG_MAX) {<br>-        info->totalswap = memsw_limit / info->mem_unit;<br>

-        info->freeswap = (memsw_limit - swap_in_u) / info->mem_unit;<br>-<br>+        info->totalswap = memsw_limit >> info->mem_unit;<br>+        info->freeswap = (memsw_limit - swap_in_u) >> info->mem_unit;<br>

     }<br> <br>     return 0;<br><br><br>I hope that simple change won't to break on your 64bit :) <br><br><br></div></div></blockquote><div><br>Agrhhh!<br>It broken at all ;) I forgot that shift operation is true only when the divisor is a power of 2 (if x=2^a then c=c/x is the same as c=c>>x).<br>
So.. my last patch only fix compilation on 32bit machines but totaly breaking show values by /proc/meminfo.<br><br>But.. I make another one which using do_div() macro and working as I wish.<br>It should look like that and it works for me :)<br>
<br>--- memcontrol.c.orig    2009-08-24 21:19:36.000000000 +0200<br>+++ memcontrol.c    2009-08-25 00:56:30.000000000 +0200<br>@@ -40,6 +40,7 @@<br> #include "internal.h"<br> <br> #include <asm/uaccess.h><br>
+#include <asm/div64.h><br> <br> struct cgroup_subsys mem_cgroup_subsys __read_mostly;<br> #define MEM_CGROUP_RECLAIM_RETRIES    5<br>@@ -1834,14 +1835,27 @@<br>         si_swapinfo(info);<br> <br>     if (limit != LLONG_MAX) {<br>
-        info->totalram = limit / info->mem_unit;<br>-        info->freeram = (limit - mystat.stat[MCS_RSS]) / info->mem_unit;<br>+<br>+        u64 dd_totalram, dd_freeram;<br>+<br>+        dd_totalram = limit;<br>
+        do_div(dd_totalram, info->mem_unit);<br>+        dd_freeram = (limit - mystat.stat[MCS_RSS]);<br>+        do_div(dd_freeram, info->mem_unit);<br>+        info->totalram = dd_totalram;<br>+        info->freeram = dd_freeram;<br>
     }<br> <br>     if (memsw_limit != LLONG_MAX) {<br>-        info->totalswap = memsw_limit / info->mem_unit;<br>-        info->freeswap = (memsw_limit - swap_in_u) / info->mem_unit;<br> <br>+        u64 dd_totalswap, dd_freeswap;<br>
+        <br>+        dd_totalswap = memsw_limit;<br>+        do_div(dd_totalswap, info->mem_unit);<br>+        dd_freeswap = memsw_limit - swap_in_u;<br>+        do_div(dd_freeswap, info->mem_unit);<br>+        info->totalswap = dd_totalswap;<br>
+        info->freeswap = dd_freeswap;<br>     }<br> <br>     return 0;<br><br>this should work for 32 & 64bit systems.<br><br>-- <br>Krzysztof Taraszka<br><a href="mailto:dzimi@pld-linux.org" target="_blank">dzimi@pld-linux.org</a> <br>
</div></div>