From: Alexey Gladkov <legion@xxxxxxxxxx>
The /proc/meminfo contains information regardless of the cgroups
restrictions. This file is still widely used [1]. This means that all
these programs will not work correctly inside container [2][3][4]. Some
programs try to respect the cgroups limits, but not all of them
implement support for all cgroup versions [5].
Correct information can be obtained from cgroups, but this requires the
cgroups to be available inside container and the correct version of
cgroups to be supported.
+ for_each_online_node(nid)
+ mem_cgroup_nr_pages(memcg, nid, mi->pages);
+
+ mi->slab_reclaimable = memcg_page_state(memcg, NR_SLAB_RECLAIMABLE_B);
+ mi->slab_unreclaimable = memcg_page_state(memcg, NR_SLAB_UNRECLAIMABLE_B);
+ mi->cached = memcg_page_state(memcg, NR_FILE_PAGES);
+ mi->swapcached = memcg_page_state(memcg, NR_SWAPCACHE);
+ mi->anon_pages = memcg_page_state(memcg, NR_ANON_MAPPED);
+ mi->mapped = memcg_page_state(memcg, NR_FILE_MAPPED);
+ mi->nr_pagetable = memcg_page_state(memcg, NR_PAGETABLE);
+ mi->dirty_pages = memcg_page_state(memcg, NR_FILE_DIRTY);
+ mi->writeback_pages = memcg_page_state(memcg, NR_WRITEBACK);
+}