Skip to content

mm/swap: skip empty clusters in the swapoff scan

Youngjun Park linux-mm lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 3 repliesIn review
  2. v12 patches 6 repliesSuperseded

Changes in v2 from the cover letter

- 1/2: reword the comment to "array, one entry per cluster", dropping the redundant "on every device" (Barry)
- 1/2: pick up Kairui's Acked-by
- 2/2: drop the min(), the swap table is always SWAPFILE_CLUSTER entries and swapon() masks the tail past si->max as bad (Kairui)
- 2/2: mark the unlocked ci->count read with READ_ONCE() for KCSAN instead of cluster_is_empty(), whose other callers hold ci->lock (Kairui)
- 2/2: expand the commit message to cover both of the above
- Rebased on mm-new
- Link to v1: https://lore.kernel.org/r/[email protected]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2mm/swap: fix stale comment on swap_info_struct::cluster_infoinclude/linux/swap.h+1 -11 reply
2/2mm/swap: scan by cluster in find_next_to_unuse()mm/swapfile.c+28 -132 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchKairui SongBarry Song
1/2A-b R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] mm/swap: skip empty clusters in the swapoff scan

From: Youngjun Park <[email protected]>

find_next_to_unuse() walks a swap device one offset at a time. Slot state now lives in a per cluster swap table, so patch 2 dismisses an empty cluster with one counter read instead of SWAPFILE_CLUSTER table reads.

Patch 1 is an unrelated one line comment fix noticed on the way.

A debug test confirmed the skip path runs, and swapoff completed under load with no DEBUG_VM or lockdep splats.

Changes in v2:
- 1/2: reword the comment to "array, one entry per cluster", dropping the redundant "on every device" (Barry)
- 1/2: pick up Kairui's Acked-by
- 2/2: drop the min(), the swap table is always SWAPFILE_CLUSTER entries and swapon() masks the tail past si->max as bad (Kairui)
- 2/2: mark the unlocked ci->count read with READ_ONCE() for KCSAN instead of cluster_is_empty(), whose other callers hold ci->lock (Kairui)
- 2/2: expand the commit message to cover both of the above
- Rebased on mm-new
- Link to v1: https://lore.kernel.org/r/[email protected]

Youngjun Park (2):
mm/swap: fix stale comment on swap_info_struct::cluster_info mm/swap: scan by cluster in find_next_to_unuse()

 include/linux/swap.h |  2 +-
 mm/swapfile.c        | 41 ++++++++++++++++++++++++++++-------------
 2 files changed, 29 insertions(+), 14 deletions(-)

base-commit: 0b53bff4fa05ff0d3ffbd3d3bb10fae69dfab498 --
2.48.1