The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git after ark-5.14 ------> commit e7d2cdabedc71916b7ca50aaf28d0ea6353af71d Author: Vladimir Davydov <vdavydov....@gmail.com> Date: Thu Sep 30 17:44:01 2021 +0300
mm: memcontrol: add stats for reclaimable and unreclaimable stats Required by vcmmd for estimating the size of available memory, which in turn is used for calculating the lower boundary for memory limit. Also, these counters will be used by the following patches. Signed-off-by: Vladimir Davydov <vdavy...@virtuozzo.com> Signed-off-by: Andrey Ryabinin <aryabi...@virtuozzo.com> +++ memcg: Show correct values of slab_[un]reclaimable in memory.stat files The values of NR_SLAB_RECLAIMABLE_B and NR_SLAB_UNRECLAIMABLE_B counters are in bytes rather than in pages. So, one should not multiply them by PAGE_SIZE when preparing the records for 'memory.stat' files in the memory cgroups. This also applies to 'total_slab_[un]reclaimable' stats in those files. https://jira.sw.ru/browse/PSBM-132728 Signed-off-by: Evgenii Shatokhin <eshatok...@virtuozzo.com> Cherry-picked from vz8 commit 6ee44bfbd469 ("mm: memcontrol: add stats for reclaimable and unreclaimable stats")). Applied cosmetic fixes: remove unneeded cast, make type of 'nr' same in both loops inside memcg_stat_show(). Signed-off-by: Nikita Yushchenko <nikita.yushche...@virtuozzo.com> --- mm/memcontrol.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index d51f09a70bcd..c2b527cf73dc 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4076,6 +4076,8 @@ static const unsigned int memcg1_stats[] = { NR_FILE_MAPPED, NR_FILE_DIRTY, NR_WRITEBACK, + NR_SLAB_RECLAIMABLE_B, + NR_SLAB_UNRECLAIMABLE_B, MEMCG_SWAP, }; @@ -4089,6 +4091,8 @@ static const char *const memcg1_stat_names[] = { "mapped_file", "dirty", "writeback", + "slab_reclaimable", + "slab_unreclaimable", "swap", }; @@ -4112,12 +4116,14 @@ static int memcg_stat_show(struct seq_file *m, void *v) cgroup_rstat_flush(memcg->css.cgroup); for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) { - unsigned long nr; + u64 nr; if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account()) continue; nr = memcg_page_state_local(memcg, memcg1_stats[i]); - seq_printf(m, "%s %lu\n", memcg1_stat_names[i], nr * PAGE_SIZE); + if (!vmstat_item_in_bytes(memcg1_stats[i])) + nr *= PAGE_SIZE; + seq_printf(m, "%s %llu\n", memcg1_stat_names[i], nr); } for (i = 0; i < ARRAY_SIZE(memcg1_events); i++) @@ -4142,13 +4148,14 @@ static int memcg_stat_show(struct seq_file *m, void *v) (u64)memsw * PAGE_SIZE); for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) { - unsigned long nr; + u64 nr; if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account()) continue; nr = memcg_page_state(memcg, memcg1_stats[i]); - seq_printf(m, "total_%s %llu\n", memcg1_stat_names[i], - (u64)nr * PAGE_SIZE); + if (!vmstat_item_in_bytes(memcg1_stats[i])) + nr *= PAGE_SIZE; + seq_printf(m, "total_%s %llu\n", memcg1_stat_names[i], nr); } for (i = 0; i < ARRAY_SIZE(memcg1_events); i++) _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel