[PATCH] fix: mm: vmscan: prepare for reparenting MGLRU folios
From: Qi Zheng
Date: Tue Mar 24 2026 - 08:09:44 EST
From: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx>
The lru_to_folio() returns the tail folio, and the lruvec_add_folio() adds
folio to the head, so the tail page is colder. Since we always assume that
the folios in child memcg (about to go offline) are always colder, we
should use list_splice_tail_init() to reparent the child folios to the
tail of the lru list of parent memcg.
Reported-by: Harry Yoo <harry.yoo@xxxxxxxxxx>
Signed-off-by: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx>
---
mm/vmscan.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 33287ba4a5003..e4a1078254ff1 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -4524,8 +4524,8 @@ static void __lru_gen_reparent_memcg(struct lruvec *child_lruvec, struct lruvec
int parent_lru_active = lru_gen_is_active(parent_lruvec, gen) ? LRU_ACTIVE : 0;
/* Assuming that child pages are colder than parent pages */
- list_splice_init(&child_lrugen->folios[gen][type][zone],
- &parent_lrugen->folios[gen][type][zone]);
+ list_splice_tail_init(&child_lrugen->folios[gen][type][zone],
+ &parent_lrugen->folios[gen][type][zone]);
WRITE_ONCE(child_lrugen->nr_pages[gen][type][zone], 0);
WRITE_ONCE(parent_lrugen->nr_pages[gen][type][zone],
--
2.20.1