From: Ehab Ababneh <ehab.ababneh@intel.com>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
David Hildenbrand <david@kernel.org>,
Michal Hocko <mhocko@kernel.org>, Qi Zheng <qi.zheng@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Lorenzo Stoakes <ljs@kernel.org>,
Kairui Song <kasong@tencent.com>, Barry Song <baohua@kernel.org>,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>
Subject: [RFC PATCH 2/3] mm/vmscan: handle racing max_seq advancement
Date: Tue, 8 Sep 2026 15:10:55 -0700 [thread overview]
Message-ID: <20260908221059.14777-3-ehab.ababneh@intel.com> (raw)
In-Reply-To: <20260908221059.14777-1-ehab.ababneh@intel.com>
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@intel.com>
---
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
next prev parent reply other threads:[~2026-09-08 22:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 22:10 [RFC PATCH 0/3] mm/vmscan: adaptive multi-threaded kswapd for NUMA-aware reclaim Ehab Ababneh
2026-09-08 22:10 ` [RFC PATCH 1/3] vmscan: Support multiple kswapd threads per node Ehab Ababneh
2026-09-08 22:10 ` Ehab Ababneh [this message]
2026-09-08 22:10 ` [RFC PATCH 3/3] mm/vmscan: make kswapd wakeups NUMA load-aware Ehab Ababneh
2026-09-09 2:16 ` [RFC PATCH 0/3] mm/vmscan: adaptive multi-threaded kswapd for NUMA-aware reclaim Zi Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260908221059.14777-3-ehab.ababneh@intel.com \
--to=ehab.ababneh@intel.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@kernel.org \
--cc=qi.zheng@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=weixugc@google.com \
--cc=yuanchu@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®