RFC mm: swap: allow per-device skipping of zero-filled page check
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest2 patches 8 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | mm: swap: add SWAP_FLAG_SKIP_ZERO_CHECK to skip zero-filled page checkinclude/ mm/ mm/ +1 more | +24 | 4 replies | |
| 2/2 | mm: swap: do not allocate zero_bitmap if zero check is skippedmm/ | +7 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC PATCH 0/2] mm: swap: allow per-device skipping of zero-filled page check
Currently, the swap layer checks whether a page is entirely zero-filled before writing it out to the swap device. However, some swap backends, such as zram and our custom swap device, already perform their own same-filled page checking internally. This results in redundant CPU operations checking same page pattern.
This patchset introduces a new swapon flag, SWAP_FLAG_SKIP_ZERO_CHECK, to eliminate this redundancy. I introduce this as a per-device flag rather than a global setting because traditional swap devices still benefit from the swap layer's zero page check to avoid unnecessary I/O. By using this flag, userspace can selectively disable the zero check only for specific backends.
Furthermore, on certain architectures where the zero map is managed via a separate bitmap, skipping this check allows bypassing
the bitmap allocation entirely (saving memory).
This modification is based on the previous discussion with Nhat Pham [1]. Additionally, this patchset is built on top of Kairui Song's recent patchset regarding swap table and zeromap modifications [2].
Tested simply with zram on QEMU to verify zero-filled page handling.
References:
[1] https://lore.kernel.org/linux-mm/acQvNRLpHwnHt7i+@yjaykim-PowerEdge-T330/
[2] https://lore.kernel.org/linux-mm/[email protected]/T/#t
Youngjun Park (2):
mm: swap: add SWAP_FLAG_SKIP_ZERO_CHECK to skip zero-filled page check
mm: swap: do not allocate zero_bitmap if zero check is skipped
include/linux/swap.h | 4 +++- mm/page_io.c | 7 ++++++- mm/swap.h | 12 ++++++++++++ mm/swapfile.c | 14 ++++++++++---- 4 files changed, 31 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1