[lxc-devel] [patch 1/1] overwrite /proc/meminfo informations with a fuse
Serge E. Hallyn
serue at us.ibm.com
Fri Sep 4 15:20:17 UTC 2009
Quoting 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 ...
Thanks, Daniel. This looks cool, and a generic config-driven one
would rock. I've looked through it a bit but am afraid I can't
do it justice without knowing more about the fuse libs (i.e. don't
know when lxcfs_destroy() can get called, or if private_data
can be not- or partially-instantiated...)
I saw no obvious problems though.
Now here's a question... Do we care to muck around with contents
of /proc/self/xyz too? I.e. /proc/self/mountinfo inside a container
could have 30 lines, of which only 5 are relaly relevant to the
container. I'm not sure there is a sane way to pare those down
though...
thanks,
-serge
More information about the lxc-devel
mailing list