From: Chris Mason With MGLRU enabled, memory.pressure_level listeners on the cgroup v1 root can miss global reclaim: kswapd sends them no events, and direct reclaim only "critical" ones. On v1 the eventfds are only fed by vmpressure() calls with tree=true. shrink_node() makes that call after walking the memcgs, but it hands root reclaim to lru_gen_shrink_node() and returns first. The MGLRU walk only calls vmpressure() from shrink_one(), with tree=false, which has no consumer on v1. That leaves vmpressure_prio() in direct reclaim. The fix used here is to make the same subtree report at the end of the MGLRU walk of a node. Listeners for "medium" and "critical" can miss events they got before, since a vmpressure_prio() report is now averaged with the pages that the walk freed in the same window. Fixes: e4dde56cd208 ("mm: multi-gen LRU: per-node lru_gen_folio lists") Signed-off-by: Chris Mason Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Barry Song (Xiaomi) --- mm/vmscan.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index 5fb3055a4302..99cb209797b4 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -5511,6 +5511,7 @@ static void lru_gen_shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc static void lru_gen_shrink_node(struct pglist_data *pgdat, struct scan_control *sc) { struct blk_plug plug; + unsigned long scanned = sc->nr_scanned; unsigned long reclaimed = sc->nr_reclaimed; VM_WARN_ON_ONCE(!root_reclaim(sc)); @@ -5545,6 +5546,11 @@ static void lru_gen_shrink_node(struct pglist_data *pgdat, struct scan_control * clear_mm_walk(); blk_finish_plug(&plug); + + /* Record the subtree's reclaim efficiency */ + if (!sc->proactive) + vmpressure(sc->gfp_mask, sc->order, sc->target_mem_cgroup, true, + sc->nr_scanned - scanned, sc->nr_reclaimed - reclaimed); done: if (sc->nr_reclaimed > reclaimed) kswapd_try_clear_hopeless(pgdat, sc->order, sc->reclaim_idx); -- 2.39.3 (Apple Git-146)