Re: [PATCH v3 6/7] mm/mglru: move folios from oldest gen to second-oldest gen from head to tail

From: Baolin Wang

Date: Thu Sep 03 2026 - 21:56:53 EST




On 9/2/26 7:24 AM, Barry Song (Xiaomi) wrote:
For reclamation, it makes sense to reclaim folios from tail to
head, as folios near the head are relatively hot. However, when
moving folios from the oldest generation to the second-oldest
generation, using the tail-to-head order would effectively cause
a cold/hot inversion.

Signed-off-by: Barry Song (Xiaomi) <baohua@xxxxxxxxxx>
Reviewed-by: Baoquan He <baoquan.he@xxxxxxxxx>
Tested-by: Xueyuan Chen <xueyuan.chen21@xxxxxxxxx>
Reviewed-by: Lian Wang <lianux.mm@xxxxxxxxx>
---
mm/vmscan.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 1907a946840d..76dfa9575852 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -192,11 +192,27 @@ static inline void prefetchw_prev_lru_folio(struct folio *folio,
prefetchw(&prev->flags);
}
}
+
+static inline void prefetchw_next_lru_folio(struct folio *folio,
+ struct list_head *base)
+{
+ if (folio->lru.next != base) {
+ struct folio *next;
+
+ next = list_entry(folio->lru.next, struct folio, lru);
+ prefetchw(&next->flags);
+ }
+}

You did not mention in the commit message why this prefetch was added. Just curious, does it really help performance?