From: Ehab Ababneh <ehab.ababneh@intel.com>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 0/3] mm/vmscan: adaptive multi-threaded kswapd for NUMA-aware reclaim
Date: Tue, 8 Sep 2026 15:10:53 -0700 [thread overview]
Message-ID: <20260908221059.14777-1-ehab.ababneh@intel.com> (raw)
This series revives Buddy Lumpkin's earlier multi-kswapd proposal:
https://lkml.iu.edu/hypermail/linux/kernel/1804.0/00342.html
The motivation is stronger now than when the patch was first discussed.
Many current systems have hundreds of cores per NUMA node, not the
single-digit or low-tens core counts that were more common at the time.
When reclaim does not keep up, direct reclaim can still push allocation
latency into application paths and leave substantial CPU capacity waiting
for memory to be freed.
This patchset adds adaptive multi-threaded kswapd. The wakeup policy uses
node load to decide how many kswapd workers to run, so reclaim can scale
when it helps and stay conservative on already busy nodes.
Series summary:
1. Allow multiple kswapd threads per node and add control plumbing.
2. Wake an appropriate number of kswapd threads from per-node
runnable load.
Concerns from the original discussion and how this series addresses some
of them:
- Concern: Direct reclaim is intended to slow a memory-hogging thread.
Response: That can be acceptable on lower-core systems. On high-core
systems, idling many cores while reclaim catches up can cost more than
allowing reclaim parallelism to scale. It can also block higher-priority
tasks in direct reclaim while they perform reclaim work on behalf of
lower-priority memory-hogging tasks.
- Concern: More kswapd threads may hide deeper reclaim issues.
Response: This series is additive to ongoing reclaim improvements. In
our testing, multi-threaded kswapd was able to improve performance on
top of what multi-gen LRU already provides.
- Concern: Existing knobs (such as swappiness and watermarks) should be
preferred.
Response: In our testing, those knobs alone did not reliably hit
performance targets and could increase CPU cost for the same workload
objective.
- Concern: Need evidence from real workloads.
Response: This cover letter includes Cassandra results showing higher
throughput and lower response latency.
- Concern: More reclaim threads may increase pressure on well-behaved
tasks.
Response: Adaptive wakeup addresses this by choosing thread count from
node load.
- Concern: Additional configuration can increase operational complexity.
Response: The user-facing interface is intentionally minimal:
max_kswapds_per_node.
- Concern: Lock contention may serialize workers.
Response: The Cassandra runs below still show net gains, indicating
contention did not erase the benefit for this workload. The wakeup path
now uses wake_up_nr() against the existing kswapd_wait queue, avoiding
pgdat->kswapd_lock (a sleeping mutex) entirely on the allocation hot
path.
Real-world workload results (Cassandra):
Tests were performed on 7.0.0-rc1.
- max_kswapds_per_node=1
- throughput sample: 171146
- reference latency value: 6.375
- op rates: 43256, 42731, 42341, 42818 ops/s
- p99 latency: 6.3, 6.4, 6.4, 6.4 ms
- max_kswapds_per_node=8
- throughput sample: 183639
- reference latency value: 6.0
- op rates: 45791, 45253, 46534, 46061 ops/s
- p99 latency: 6.0, 6.1, 5.9, 6.0 ms
Observed improvement in these runs was about +7.3% throughput and about
-5.9% response latency, which shows practical benefit for production-style
database workloads.
In our runs, performance numbers were essentially unchanged with and
without the adaptive multi-threaded kswapd wakeup policy. In both cases,
they outperformed the single-kswapd-thread baseline. This indicates the
adaptive method preserved the multi-threaded performance improvement.
Addendum: alternative approaches evaluated
- PSI per NUMA node.
I prototyped PSI-based node pressure ranges to drive wakeup count.
This became cumbersome because robust PSI-to-thread mappings were not
straightforward across workload types.
- CPU mask snapshot policy.
I also tested a simple CPU mask snapshot approach.
While functional, it reflects a moment-in-time view and does not capture
pressure trends over a broader sampling window.
Buddy Lumpkin (1):
vmscan: Support multiple kswapd threads per node
Ehab Ababneh (2):
mm/vmscan: handle racing max_seq advancement
mm/vmscan: make kswapd wakeups NUMA load-aware
include/linux/mmzone.h | 5 +-
include/trace/events/vmscan.h | 28 +++
mm/compaction.c | 8 +-
mm/internal.h | 3 +
mm/page_alloc.c | 26 +++
mm/vmscan.c | 419 +++++++++++++++++++++++++++++++++++++++---
6 files changed, 465 insertions(+), 24 deletions(-)
--
2.43.0
next 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 Ehab Ababneh [this message]
2026-09-08 22:10 ` [RFC PATCH 1/3] vmscan: Support multiple kswapd threads per node Ehab Ababneh
2026-09-08 22:10 ` [RFC PATCH 2/3] mm/vmscan: handle racing max_seq advancement Ehab Ababneh
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-1-ehab.ababneh@intel.com \
--to=ehab.ababneh@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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