LXC cgroup namespacing?

Discussion in 'Proxmox VE: Installation and configuration' started by shinji, Feb 27, 2019.

  1. shinji

    shinji New Member

    Joined:
    Jun 23, 2013
    Messages:
    4
    Likes Received:
    0
    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?
     
  2. t.lamprecht

    t.lamprecht Proxmox Staff Member
    Staff Member

    Joined:
    Jul 28, 2015
    Messages:
    1,177
    Likes Received:
    155
    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.

    Which version of both on which Linux Distro?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. fabian

    fabian Proxmox Staff Member
    Staff Member

    Joined:
    Jan 7, 2016
    Messages:
    3,207
    Likes Received:
    498
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. shinji

    shinji New Member

    Joined:
    Jun 23, 2013
    Messages:
    4
    Likes Received:
    0
    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
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice