LXC cgroup namespacing?

shinji

Member
Jun 23, 2013
4
0
21
I've been trying to figure out why NetData was providing inaccurate memory data for LXC containers and during our investigation we found that the memory.stat information at /sys/fs/cgroup/memory/lxc/<container>/memory.stat is not giving the expected information. The top half of the stats are all showing zeros instead of actual values (the totals are showing values though). We did find something more along the lines of what we were looking for at /sys/fs/cgroup/memory/lxc/<container>/ns/memory.stat however the normal stats just seem to mirror the totals.

This confuses me because this cgroup structure isn't consistent with LXC/LXD installs on just straight linux. Is there a reason for this setup?
 
For memory accounting we substract "/sys/fs/cgroup/memory/lxc/$VMID/memory.usage_in_bytes" from thew total_cache entry in "/sys/fs/cgroup/memory/lxc/$VMID/memory.stat".

Swap is "/sys/fs/cgroup/memory/lxc/$vmid/memory.memsw.usage_in_bytes" minus the former calculated one.

confuses me because this cgroup structure isn't consistent with LXC/LXD installs on just straight linux

Which version of both on which Linux Distro?
 
Ok. That's fine then and I understand it is an intentional setup. Given all this I noticed that the top of half of memory.stat in the root namespace for each container is just zero. You have to look at the /ns nested cgroup to see the non-total values (although they are the same anyways). This throws off scripts like netdata that are expecting values on the top half so that it can display information correctly. I will admit that there are a few values in there but the majority are just zero.

shinji@zeus:/sys/fs/cgroup/memory/lxc/103$ cat memory.stat
cache 0
rss 0
rss_huge 0
shmem 0
mapped_file 0
dirty 0
writeback 0
swap 0
pgpgin 1
pgpgout 1
pgfault 6
pgmajfault 0
inactive_anon 0
active_anon 0
inactive_file 0
active_file 0
unevictable 0
hierarchical_memory_limit 8589934592
hierarchical_memsw_limit 9663676416
total_cache 4504817664
total_rss 271237120
total_rss_huge 6291456
total_shmem 18173952
total_mapped_file 82857984
total_dirty 0
total_writeback 0
total_swap 0
total_pgpgin 1926277
total_pgpgout 761781
total_pgfault 1155483
total_pgmajfault 1477
total_inactive_anon 18145280
total_active_anon 271265792
total_inactive_file 924405760
total_active_file 3562131456
total_unevictable 0
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!