[RFC PATCH] mm/mglru: keep the root_memcg reclaim behavior the same as memcg reclaim

From: hailong
Date: Thu Dec 12 2024 - 04:57:39 EST


From: Hailong Liu <hailong.liu@xxxxxxxx>

commit a579086c99ed ("mm: multi-gen LRU: remove eviction fairness safeguard") said
Note that memcg LRU only applies to global reclaim. For memcg reclaim,
the eviction will continue, even if it is overshooting. This becomes
unconditional due to code simplification.

Howeven, if we reclaim a root memcg by sysfs (memory.reclaim), the behavior acts
as a kswapd or direct reclaim.

Fix this by remove the condition of mem_cgroup_is_root in
root_reclaim().
Signed-off-by: Hailong Liu <hailong.liu@xxxxxxxx>
---
mm/vmscan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 76378bc257e3..1f74f3ba0999 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -216,7 +216,7 @@ static bool cgroup_reclaim(struct scan_control *sc)
*/
static bool root_reclaim(struct scan_control *sc)
{
- return !sc->target_mem_cgroup || mem_cgroup_is_root(sc->target_mem_cgroup);
+ return !sc->target_mem_cgroup;
}

/**
--
Actually we switch to mglru on kernel-6.1 and see different behavior on
root_mem_cgroup reclaim. so is there any background fot this?

Brs,
Hailong.