Linux Hardening
 help / color / mirror / Atom feed
* [PATCH v5 00/19] mm/swap: introduce priority queues for swap device allocation
@ 2026-11-23 14:15 Lian Wang
  2026-11-23 14:16 ` [PATCH v5 01/19] mm/swap: remove unused parameter for reading swap header Lian Wang
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: Lian Wang @ 2026-11-23 14:15 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, Andrew Morton, Chris Li, Nhat Pham, Baoquan He,
	Barry Song, Youngjun Park, Kemeng Shi, Kairui Song, Jihan LIN,
	Kunwu Chan, Kees Cook, Gustavo A. R. Silva, Thomas Gleixner,
	linux-hardening

Hi all,

This is v5 of Kairui Song's swap priority queue series. Today, choosing
among swap devices of equal priority means rotating a shared plist.
With this series, each CPU advances its own position in a ring of
equal-priority devices. The allocator selects a device before looking for
slots on it. This keeps the existing global swap priorities and does not
add a tier ABI or a per-memcg device-selection policy. Memcg swap
accounting and limits are unchanged.

Thanks to Kairui and Kunwu Chan for reviewing v4. I'm dropping the RFC
tag and submitting the series for review.

Changes since v4:

- Rebased onto mm-unstable at 7d1a16abe4cc (7.4-rc3), retaining the
  upstream swap size reporting fix in swap_show() and swapon().
- Following Kairui's review, renamed swap_ring_iterator to
  swap_queue_reader_head and ring_only to no_fallback. A large folio
  can still try other devices of the same priority after an allocation
  failure, but not a lower priority.
- Following Kunwu's review, retained READ_ONCE() in the availability
  check, removed a misleading comment about slot reuse, and made both
  /proc/swaps iterators check the published swap_file under the read
  lock.
- Split the off-list bit fix into patch 10, before the queue conversion.
  The plist allocator also needs to mask that bit when checking whether
  a swap device is full.
- Revised patch 04 to distinguish all allocated descriptors from
  writable devices. drain_mmlist() needs only the usage count and no
  longer reads the flags. si_swapinfo() takes one flags snapshot when
  accounting for devices being taken offline. I have not carried the
  previous Reviewed-by on that patch.

Testing:

I ran Kairui's benchmarks on the 7.4-rc3 base (7d1a16abe4cc) before and
after applying the then-current v5 patches.

On one x86-64 host, both kernels built the same source (4dbe24720eb3)
with make -j96 and eight 8-GiB ZRAM devices. Each build used a fresh
output directory. The BRD test used twelve 8-GiB RAM disks, a 24-GiB
memcg limit and one invocation per kernel:

  usemem --init-time -O -y -x -n 32 1536M

Times are in seconds (means for kbuild).

  Workload        Runs/kernel   SYS: Before -> After      Wall: Before -> After
  kbuild, 2 GiB        12       4193.23 -> 4271.06        167.80 -> 168.80
  kbuild, 3 GiB        12       2257.60 -> 2299.63        136.29 -> 136.77
  12-BRD                1        141.16 ->  131.44          6.61 ->   6.32

Both kbuild cases used 1.86% more system CPU time; elapsed time rose by
0.60% and 0.35%, respectively. In the single BRD run, throughput
(48 GiB mapped divided by elapsed time) rose from 7436 to 7777 MiB/s
(+4.59%). There was one boot per kernel and the baseline ran first.
The BRD result alone does not establish a repeatable speedup.

v4:
https://lore.kernel.org/all/cover.1794666741.git.lianux.mm@gmail.com/
v1 and original test method:
https://lore.kernel.org/all/20260714-swap-pcp-priq-v1-0-de9b164ed419@tencent.com/
Related swap tier work:
https://lore.kernel.org/all/20260916183437.2946306-1-youngjun.park@lge.com/

Best regards,
Lian Wang

---

Kairui Song (12):
  mm/swap: remove unused parameter for reading swap header
  mm/swap: clean up hibernation error handling
  mm/swap: cleanup and document swap device availability flag usage
  mm/swap: introduce swap device iteration helper
  mm/swap: change the swapon lock into a percpu rwsem
  mm/swap: serialize swap publication before removing swapon mutex
  mm/swap: consolidate swap inuse accounting helpers
  mm/swap: add priority queue for swap device allocation
  mm/swap: remove available list
  mm/swap: bound synchronous discard outside the allocation reader
  mm/swap: drop swap active plist
  lib/plist.c: remove requeue function

Lian Wang (6):
  mm/swap: avoid direct reclaim when populating swap cluster metadata
  mm/swap: mask the off-list bit when checking whether swap is full
  mm/swap: reuse per-CPU queue readers across priority changes
  mm/swap: advance the global queue cursor directly between priority
    rings
  mm/swap: skip reader rotation for single-device priority rings
  mm/swap: redistribute queue readers after membership changes

Youngjun Park (1):
  mm/swap: change back to use each swap device's percpu cluster

 include/linux/plist.h |    2 -
 include/linux/swap.h  |   45 +-
 lib/plist.c           |   71 --
 mm/swap.h             |   12 +-
 mm/swapfile.c         | 1446 ++++++++++++++++++++++++++---------------
 5 files changed, 963 insertions(+), 613 deletions(-)


base-commit: 7d1a16abe4cc5dccd21e3d6262e44433a5885d27

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-11-23 14:20 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 14:15 [PATCH v5 00/19] mm/swap: introduce priority queues for swap device allocation Lian Wang
2026-11-23 14:16 ` [PATCH v5 01/19] mm/swap: remove unused parameter for reading swap header Lian Wang
2026-11-23 14:16 ` [PATCH v5 02/19] mm/swap: clean up hibernation error handling Lian Wang
2026-11-23 14:16 ` [PATCH v5 03/19] mm/swap: cleanup and document swap device availability flag usage Lian Wang
2026-11-23 14:16 ` [PATCH v5 04/19] mm/swap: introduce swap device iteration helper Lian Wang
2026-11-23 14:16 ` [PATCH v5 05/19] mm/swap: change the swapon lock into a percpu rwsem Lian Wang
2026-11-23 14:16 ` [PATCH v5 06/19] mm/swap: serialize swap publication before removing swapon mutex Lian Wang
2026-11-23 14:17 ` [PATCH v5 07/19] mm/swap: consolidate swap inuse accounting helpers Lian Wang
2026-11-23 14:17 ` [PATCH v5 08/19] mm/swap: change back to use each swap device's percpu cluster Lian Wang
2026-11-23 14:18 ` [PATCH v5 09/19] mm/swap: avoid direct reclaim when populating swap cluster metadata Lian Wang
2026-11-23 14:18 ` [PATCH v5 10/19] mm/swap: mask the off-list bit when checking whether swap is full Lian Wang
2026-11-23 14:18 ` [PATCH v5 11/19] mm/swap: add priority queue for swap device allocation Lian Wang
2026-11-23 14:18 ` [PATCH v5 12/19] mm/swap: remove available list Lian Wang
2026-11-23 14:18 ` [PATCH v5 13/19] mm/swap: bound synchronous discard outside the allocation reader Lian Wang
2026-11-23 14:19 ` [PATCH v5 14/19] mm/swap: drop swap active plist Lian Wang
2026-11-23 14:19 ` [PATCH v5 15/19] lib/plist.c: remove requeue function Lian Wang
2026-11-23 14:19 ` [PATCH v5 16/19] mm/swap: reuse per-CPU queue readers across priority changes Lian Wang
2026-11-23 14:19 ` [PATCH v5 17/19] mm/swap: advance the global queue cursor directly between priority rings Lian Wang
2026-11-23 14:19 ` [PATCH v5 18/19] mm/swap: skip reader rotation for single-device " Lian Wang
2026-11-23 14:20 ` [PATCH v5 19/19] mm/swap: redistribute queue readers after membership changes Lian Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox