diff options
| author | Alexandre Ghiti <alex@ghiti.fr> | 2026-11-09 15:18:32 -0800 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-11-22 22:24:09 -0800 |
| commit | 2ec6ad932675db84a55d0bce7543e80c5ba8351c (patch) | |
| tree | 4048ffc9478f0b0e6e45de63a34ae7c5f2991f40 /tools/perf/scripts/python | |
| parent | 76e1b20670b51a6cb31dc65877fc9a10f06366a2 (diff) | |
mm, swap: only prefer nonfull clusters on synchronous devices
Commit 9a42aed48421 ("mm, swap: prefer nonfull over free clusters") made
the allocator fill nonfull clusters before taking free ones on swap
devices without discard. Commit 3cedb745d354 ("mm: clarify the
folio_free_swap() for do_swap_page()") frees the swap slot on an exclusive
write fault. Such faults now leave holes in formerly full clusters,
putting those clusters back on the nonfull list. Reclaim allocates slots
one folio at a time, scattering a batch across the holes instead of
producing mergeable writes. Later swapin can also require more read
requests.
On a mysql/sysbench workload in a 256 MiB memcg swapping to an NVMe
partition, 7.3 compared with the previous version produced 59% more device
read requests and 27% more write requests per transaction. Throughput was
unchanged without iocost and fell 19% with iocost.
Prefer free clusters first on nonsynchronous devices, preserving
contiguous swap slots for merging I/O. Keep nonfull-first on synchronous
devices such as zram: they do not merge I/O, and filling holes saves free
clusters for large folios. Keep free-cluster preference on discard
devices to spread writes.
In the same workload, v2 reduced read requests per transaction by 14% and
write requests by 48% against its base kernel. Throughput was unchanged
without iocost and improved 33% with iocost. The RFC's batch-aware
allocator also improved this workload, but this policy needs no batch
information from reclaim. Reverting the slot-freeing change would keep
swap space pinned under dirty pages; a proposed 50% swap-usage cutoff for
free-cluster preference was arbitrary and would stop helping as swap
filled.
The 7.0 to 7.2 kernels retained the swap slot after a write fault as a
side effect of 4b34f1d82c65 ("mm, swap: free the swap cache after folio is
mapped"). The observed regression requires both 9a42aed48421 and
3cedb745d354; stable backports should target trees containing both.
Link: https://lore.kernel.org/r/20261105155032.240457-1-alex@ghiti.fr
Link: https://lore.kernel.org/r/20261105155032.240457-2-alex@ghiti.fr
Link: https://lore.kernel.org/r/20261022145615.2184343-1-alex@ghiti.fr
Link: https://lore.kernel.org/r/CAMgjq7BFbXEKEt9faj_rg5AStfLkpJ0j57EQOOJ+L3-w2xRvtg@mail.gmail.com
Fixes: 9a42aed48421 ("mm, swap: prefer nonfull over free clusters")
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Kairui Song <kasong@tencent.com>
Acked-by: Kairui Song <kasong@tencent.com>
Reviewed-by: Nhat Pham <nphamcs@gmail.com>
Cc: <stable@vger.kernel.org>
mm/swapfile.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
