[RFC PATCH 2/3] mm/vmscan: handle racing max_seq advancement

From: Ehab Ababneh

Date: Tue Sep 08 2026 - 18:15:24 EST


When kswapd support is expanded to multiple threads per node, concurrent
aging becomes more likely and try_to_inc_max_seq() can lose a race to
another aging pass that has already advanced max_seq.

Treat that case as success instead of warning, since the desired state has
already been reached by a concurrent updater.

Signed-off-by: Ehab Ababneh <ehab.ababneh@xxxxxxxxx>
---
mm/vmscan.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index fbb04848f59b..ad2b398a68f9 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3942,15 +3942,18 @@ static bool inc_max_seq(struct lruvec *lruvec, unsigned long seq, int swappiness
struct lru_gen_folio *lrugen = &lruvec->lrugen;
restart:
if (seq < READ_ONCE(lrugen->max_seq))
- return false;
+ return true;

lruvec_lock_irq(lruvec);

VM_WARN_ON_ONCE(!seq_is_valid(lruvec));

success = seq == lrugen->max_seq;
- if (!success)
+ if (!success) {
+ /* Concurrent aging advanced max_seq first; goal achieved. */
+ success = true;
goto unlock;
+ }

for (type = 0; type < ANON_AND_FILE; type++) {
if (get_nr_gens(lruvec, type) != MAX_NR_GENS)
@@ -4045,10 +4048,8 @@ static bool try_to_inc_max_seq(struct lruvec *lruvec, unsigned long seq,
walk_mm(mm, walk);
} while (mm);
done:
- if (success) {
+ if (success)
success = inc_max_seq(lruvec, seq, swappiness);
- WARN_ON_ONCE(!success);
- }

return success;
}
--
2.43.0