* [PATCH] mm/vmscan: fix missing NR_ISOLATED counter update in MGLRU reclaim path
@ 2026-08-11 7:17 Hui Zhu
2026-08-11 15:16 ` Kairui Song
0 siblings, 1 reply; 2+ messages in thread
From: Hui Zhu @ 2026-08-11 7:17 UTC (permalink / raw)
To: Andrew Morton, Kairui Song, Qi Zheng, Shakeel Butt, Barry Song,
Axel Rasmussen, Yuanchu Xie, Wei Xu, Johannes Weiner,
David Hildenbrand, Michal Hocko, Lorenzo Stoakes, linux-mm,
linux-kernel
Cc: Hui Zhu
From: Hui Zhu <zhuhui@kylinos.cn>
The MGLRU evict_folios() isolates folios from the LRU without updating
NR_ISOLATED_ANON/FILE counters, unlike the legacy shrink_inactive_list()
path.
This causes compaction's too_many_isolated() check and the OOMkiller to
under-count isolated pages when MGLRU reclaim is active, potentially
leading to unnecessary compaction attempts or incorrect OOM decisions
under memory pressure.
Add NR_ISOLATED counter updates in evict_folios(): increment after
isolate_folios() and decrement after all retry passes complete, using
the original isolated count saved before retry.
Signed-off-by: Hui Zhu <zhuhui@kylinos.cn>
---
mm/vmscan.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index bc324e37c5f1..723b513574b3 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -4817,6 +4817,7 @@ static int evict_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
struct lru_gen_mm_walk *walk;
int scanned, reclaimed;
int isolated = 0, type, type_scanned;
+ int isolated_orig = 0;
bool skip_retry = false;
struct mem_cgroup *memcg = lruvec_memcg(lruvec);
struct pglist_data *pgdat = lruvec_pgdat(lruvec);
@@ -4829,6 +4830,11 @@ static int evict_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
scanned = isolate_folios(nr_to_scan, lruvec, sc, swappiness,
&list, &isolated, &type, &type_scanned);
+ isolated_orig = isolated;
+ if (isolated)
+ __mod_node_page_state(pgdat, NR_ISOLATED_ANON + type,
+ isolated);
+
/* Scanning may have emptied the oldest gen, flush it */
if (scanned)
try_to_inc_min_seq(lruvec, swappiness);
@@ -4891,6 +4897,10 @@ static int evict_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
goto retry;
}
+ if (isolated_orig)
+ mod_node_page_state(pgdat, NR_ISOLATED_ANON + type,
+ -isolated_orig);
+
return scanned;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/vmscan: fix missing NR_ISOLATED counter update in MGLRU reclaim path
2026-08-11 7:17 [PATCH] mm/vmscan: fix missing NR_ISOLATED counter update in MGLRU reclaim path Hui Zhu
@ 2026-08-11 15:16 ` Kairui Song
0 siblings, 0 replies; 2+ messages in thread
From: Kairui Song @ 2026-08-11 15:16 UTC (permalink / raw)
To: Hui Zhu
Cc: Andrew Morton, Kairui Song, Qi Zheng, Shakeel Butt, Barry Song,
Axel Rasmussen, Yuanchu Xie, Wei Xu, Johannes Weiner,
David Hildenbrand, Michal Hocko, Lorenzo Stoakes, linux-mm,
linux-kernel, Hui Zhu
On Tue, Aug 11, 2026 at 03:17:03PM +0800, Hui Zhu wrote:
> From: Hui Zhu <zhuhui@kylinos.cn>
>
> The MGLRU evict_folios() isolates folios from the LRU without updating
> NR_ISOLATED_ANON/FILE counters, unlike the legacy shrink_inactive_list()
> path.
> This causes compaction's too_many_isolated() check and the OOMkiller to
> under-count isolated pages when MGLRU reclaim is active, potentially
> leading to unnecessary compaction attempts or incorrect OOM decisions
> under memory pressure.
This patch still doesn't cover the OOM problem, too_many_isolated is not
used for MGLRU. I prefer to keep unifying them like what we did previously
with writeback.
It might work for compaction though, did you test it?
>
> Add NR_ISOLATED counter updates in evict_folios(): increment after
> isolate_folios() and decrement after all retry passes complete, using
> the original isolated count saved before retry.
>
> Signed-off-by: Hui Zhu <zhuhui@kylinos.cn>
> ---
> mm/vmscan.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index bc324e37c5f1..723b513574b3 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -4817,6 +4817,7 @@ static int evict_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
> struct lru_gen_mm_walk *walk;
> int scanned, reclaimed;
> int isolated = 0, type, type_scanned;
> + int isolated_orig = 0;
The variable name looks a bit confusing, and what is your based commit?
In latest mm-unstable there is already a nr_isolated you can use.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-11 15:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 7:17 [PATCH] mm/vmscan: fix missing NR_ISOLATED counter update in MGLRU reclaim path Hui Zhu
2026-08-11 15:16 ` Kairui Song
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.