[RFC PATCH v4 16/16] mm/mglru: reduce folios pulled from the oldest gen in inc_min_seq()

From: Barry Song (Xiaomi)

Date: Wed Aug 12 2026 - 08:31:34 EST


Pulling folios from the oldest generation to the second-oldest
generation with MAX_LRU_BATCH can take a long time, as the spinlock
is held throughout the operation and blocks other users.

Reduce the remaining batch size significantly. This reduces the lock
hold time, allowing concurrent reclaim, lru_cache_drain, and other
operations to make progress.

Signed-off-by: Barry Song (Xiaomi) <baohua@xxxxxxxxxx>
---
mm/vmscan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index c0350a8b61d1..8e6fcefe0353 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3945,7 +3945,7 @@ static inline void flush_lru_batch(struct list_head *head, struct list_head **ba
static bool inc_min_seq(struct lruvec *lruvec, int type, int swappiness)
{
int zone;
- int remaining = MAX_LRU_BATCH;
+ int remaining = MAX_LRU_BATCH / (is_extreme_swappiness(swappiness) ? 2 : 8);
struct lru_gen_folio *lrugen = &lruvec->lrugen;
int hist = lru_hist_from_seq(lrugen->min_seq[type]);
int new_gen, old_gen = lru_gen_from_seq(lrugen->min_seq[type]);
--
2.34.1