[PATCH v2 0/4] mm/swap, zswap: fix stale zswap data and swap-in bugs
From: Kairui Song via B4 Relay
Date: Tue Nov 03 2026 - 13:09:50 EST
Hi all,
There are some bug fixes found by AI and collected by David, mostly
originally from Anthropic. After filtering and dropping a few that are
already being patched up by the community [1] [2], these are the 3 we
kept. The accounting fix is in two patches now, the second one from
Johannes to cover asynchronous devices too.
Patches 1 and 2 are marked for stable, they affect v6.12 and later.
Patches 3 and 4 only affect v7.3 and later, so they are not marked for
stable.
The zswap bug in patch 1 can return stale data instead of the zeroes that
were written, so it is data corruption and seems critical. The extent
fix in patch 2 is more urgent than it might look, as it can also read in
unexpected data, but the setup could be really rare.
For the extent fix, in the long term we might actually want to detect
extent contiguity and allow mTHP swap-in for single-extent swap files.
We already disable mTHP allocation for swap files, so the current fix is
trivial. It seems the most minimal and correct one for now.
Optimization and cleanups can come later.
Patch 3 gives up readahead batching for synchronous devices, as its
changelog says; that only affects the MADV_WILLNEED and swapoff walks,
the fault path never batched.
Testing: tested on arm64 with both zram and swap file over sync device
and async device, everything works as expected, no content mismatch.
Link: https://lore.kernel.org/linux-mm/20261026-swapoff-writeok-v1-1-4f4cd420aa33@xxxxxxxxxxxx/ [1]
Link: https://lore.kernel.org/linux-mm/20260811132209.2862708-3-youngjun.park@xxxxxxx/ [2]
---
Changes in v2:
- The zswap and accounting fixes are unchanged from v1.
- Patch 2 simplifies the known-gap note about the unmerged xswap patch, per
Nhat.
- New patch 4 from Johannes keeps the swap-in pressure window open across
a batch so that asynchronous submission is counted as well.
- Link to v1: https://patch.msgid.link/20261030-swap-fixes-v1-0-73f73a59f2fc@xxxxxxxxxxx
To: linux-mm@xxxxxxxxx
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Chris Li <chrisl@xxxxxxxxxx>
Cc: Kairui Song <kasong@xxxxxxxxxxx>
Cc: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
Cc: Nhat Pham <nphamcs@xxxxxxxxx>
Cc: Baoquan He <baoquan.he@xxxxxxxxx>
Cc: Barry Song <baohua@xxxxxxxxxx>
Cc: Youngjun Park <youngjun.park@xxxxxxx>
Cc: Usama Arif <usamaarif642@xxxxxxxxx>
Cc: Chengming Zhou <chengming.zhou@xxxxxxxxx>
Cc: Yosry Ahmed <yosry@xxxxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: David Hildenbrand <david@xxxxxxxxxx>
Cc: Lorenzo Stoakes <ljs@xxxxxxxxxx>
Cc: "Liam R. Howlett" <liam@xxxxxxxxxxxxx>
Cc: Vlastimil Babka <vbabka@xxxxxxxxxx>
Cc: Mike Rapoport <rppt@xxxxxxxxxx>
Cc: Suren Baghdasaryan <surenb@xxxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: Chuanhua Han <hanchuanhua@xxxxxxxx>
Cc: Mani Tofigh <mt4022@xxxxxxxxxxxx>
Cc: NeilBrown <neil@xxxxxxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
Chris Mason (1):
mm, swap: fix large swap-in across swap file extents
Johannes Weiner (1):
mm/swap: keep the swap-in pressure window open across a batch
Josef Bacik (2):
mm/zswap: drop the stale zswap entry of a zero folio
mm/swap: account synchronous swap reads as memory stall
include/linux/swap_ops.h | 10 ++++++
mm/memory.c | 16 +++++++--
mm/page_io.c | 94 +++++++++++++++++++++++++++++++++---------------
3 files changed, 89 insertions(+), 31 deletions(-)
---
base-commit: 0ea6dc8c4a2192227ec25768625686b8fcd5cb09
change-id: 20261030-swap-fixes-1aa6c2c1e7f9
Best regards,
--
Kairui Song <kasong@xxxxxxxxxxx>