Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] mm: swap: allow per-device skipping of zero-filled page check
@ 2026-05-18  7:34 Youngjun Park
  2026-05-18  7:34 ` [RFC PATCH 1/2] mm: swap: add SWAP_FLAG_SKIP_ZERO_CHECK to skip " Youngjun Park
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Youngjun Park @ 2026-05-18  7:34 UTC (permalink / raw)
  To: linux-mm, akpm
  Cc: chrisl, kasong, shikemeng, nphamcs, bhe, baohua, youngjun.park

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/20260517-swap-table-p4-v5-0-88ae43e064c7@tencent.com/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(-)

-- 
2.34.1


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

end of thread, other threads:[~2026-06-01  2:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-18  7:34 [RFC PATCH 0/2] mm: swap: allow per-device skipping of zero-filled page check Youngjun Park
2026-05-18  7:34 ` [RFC PATCH 1/2] mm: swap: add SWAP_FLAG_SKIP_ZERO_CHECK to skip " Youngjun Park
2026-05-19  6:30   ` Christoph Hellwig
2026-05-19  7:08     ` YoungJun Park
2026-05-19  9:18       ` Christoph Hellwig
2026-05-21  6:46         ` YoungJun Park
2026-05-18  7:34 ` [RFC PATCH 2/2] mm: swap: do not allocate zero_bitmap if zero check is skipped Youngjun Park
2026-05-19 10:16 ` [RFC PATCH 0/2] mm: swap: allow per-device skipping of zero-filled page check Usama Arif
2026-05-21  6:57   ` YoungJun Park
2026-05-31 18:48 ` Kairui Song
2026-06-01  2:05   ` YoungJun Park

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