[lxc-devel] [patch 1/1] overwrite /proc/meminfo informations with a fuse

Serge E. Hallyn serue at us.ibm.com
Fri Sep 4 15:21:41 UTC 2009


Quoting Daniel Lezcano (daniel.lezcano at free.fr):
> Krzysztof Taraszka wrote:
>> 2009/9/1 Daniel Lezcano <daniel.lezcano at free.fr>
>>
>>> This patch allows to display information related to the cgroup
>>> in /proc/meminfo.
>>>
>>> It is a first try, there is certainly a clever way to do that but
>>> it is just to play with it.
>>>
>>> Compile with:
>>>
>>>        make lxcfs CFLAGS="-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=27"
>>> LDFLAGS="-lfuse"
>>>
>>> Launch a container as root with:
>>>
>>>        lxc-execute -n foo /bin/bash
>>>
>>> Set 256MB of memory:
>>>
>>>        echo 268435456 > /cgroup/foo/memory.limit_in_bytes
>>>
>>> And finally mount /proc/meminfo:
>>>
>>>        ./lxcfs -odirect_io /proc/meminfo
>>>
>>> And the results are:
>>>
>>> cat /proc/meminfo:
>>> ==================
>>>
>>> MemTotal:      262144 kB
>>> MemFree:       255991 kB
>>>
>>> top:
>>> ====
>>>
>>> top - 23:52:17 up  2:43,  2 users,  load average: 0.00, 0.00, 0.00
>>> Tasks:   6 total,   1 running,   5 sleeping,   0 stopped,   0 zombie
>>> Cpu(s):  0.0%us,  0.3%sy,  0.0%ni, 99.0%id,  0.0%wa,  0.0%hi,  0.7%si,  0.0
>>> Mem:    262144k total,     6153k used,   255991k free,        0k buffers
>>> Swap:        0k total,        0k used,        0k free,        0k cached
>>>
>>>  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
>>>    1 dlezcano  20   0  8136  484  408 S  0.0  0.2   0:00.00 lxc-init
>>>    2 dlezcano  20   0 90112 1764 1304 S  0.0  0.7   0:00.08 bash
>>>   29 root      20   0  121m 1392 1128 S  0.0  0.5   0:00.05 su
>>>   30 root      20   0 89984 1696 1328 S  0.0  0.6   0:00.05 bash
>>>   68 root      20   0 37628  888  544 S  0.0  0.3   0:00.00 lxcfs
>>>   74 root      20   0 14748 1040  868 R  0.0  0.4   0:00.02 top
>>>
>>> free:
>>> =====
>>>
>>>             total       used       free     shared    buffers     cached
>>> Mem:        262144       6153     255991          0          0          0
>>> -/+ buffers/cache:       6153     255991
>>>
>>>
>>> To be extended ...
>>>
>>> Signed-off-by: Daniel Lezcano <daniel.lezcano at free.fr>
>>> ---
>
> [ ... ]
>
>> Great. Let me see.
>> Oh, forgot about memsw? "swap in use" is: memory.memsw.usage_in_bytes -
>> memory.usage_in_bytes. "available swap" is: memory.memsw.limit_in_bytes -
>> memory.limit_in_bytes because memsw is memory + swap.
>
> Yep, thanks I will add it.
>
> I would like to find a efficient way to generalize this fs on the whole  
> /proc and provide a framework to add the files to be virtualized one by 
> one.

Hmm, yes.

> For example, we don't want to hide /proc/self or /proc/<pid> but the  
> mount will hide this informations, so we need to do some kind of  
> "file-proxy", especially for displaying directory content.

This looks like fun.  I'll have to download the fuse-libs source and take a
look in the evenings this weekend.

thanks,
-serge




More information about the lxc-devel mailing list