[Devel] [PATCH RHEL COMMIT] mm/memcontrol: do not uncharge cache folio for root memcg
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Jul 30 18:06:58 MSK 2025
The commit is pushed to "branch-rh10-6.12.0-55.13.1.vz10.2.x-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-55.13.1.el10
------>
commit 3d9f76014032918d41ef7070bec9d31950ea2416
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date: Tue Jul 29 14:27:38 2025 +0200
mm/memcontrol: do not uncharge cache folio for root memcg
We do not account/limit memcg::memory,::memsw for root memcg,
so don't we do that for cache.
And memory.cache.current,memory.cache.max files are not available for
root memcg as well.
But there is one place - uncharge_folio() - where we forgot to put cache
accounting under !mem_cgroup_is_root() check, so fix this.
Fixes: 6a2ca4d515c5 ("mm: Memory cgroup page cache limit")
https://virtuozzo.atlassian.net/browse/VSTOR-111756
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Feature: mm: Memory cgroup page cache limit
---
mm/memcontrol.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f0b53e5f4d243..8a4fdef58743e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5499,11 +5499,12 @@ static void uncharge_folio(struct folio *folio, struct uncharge_gather *ug)
folio->memcg_data = 0;
obj_cgroup_put(objcg);
} else {
- if (folio_memcg_cache(folio))
- ug->nr_pgcache += nr_pages;
/* LRU pages aren't accounted at the root level */
- if (!mem_cgroup_is_root(memcg))
+ if (!mem_cgroup_is_root(memcg)) {
ug->nr_memory += nr_pages;
+ if (folio_memcg_cache(folio))
+ ug->nr_pgcache += nr_pages;
+ }
ug->pgpgout++;
WARN_ON_ONCE(folio_unqueue_deferred_split(folio));
More information about the Devel
mailing list