freenode
Kernel & Low-Level

Linux fixes zswap stale-data corruption and swap-in PSI bugs

A critical zswap path could return old pages instead of written zeroes, while batched swap reads hid zram and async stalls from pressure and delay accounting.

Kernel memory-management developers have posted fixes for a zswap data-corruption bug and for swap-in accounting holes that left PSI memory pressure and delay accounting blind to workingset refaults from zram and other swap backends.

The sharpest issue is in zswap. Under the broken path, a swap-in could hand back stale compressed data instead of the zeroes that had been written, silent corruption rather than a crash. A second extent-handling flaw could also pull in unexpected data, though the required setup is described as rare. Both problems reach back to Linux 6.12 and are marked for stable.

Separately, batching of swap reads broke stall accounting. For synchronous devices such as zram, the pressure and delayacct window closed before the read actually ran, so the I/O never appeared in /proc/pressure/memory or thrashing delay stats. Workingset refaults from zram, a primary signal for userspace OOM handlers such as Android's lmkd and systemd-oomd, became invisible. Josef Bacik's fix submits those synchronous reads inside the accounting window again, giving up readahead batching that was of little value on devices that do I/O inline.

Johannes Weiner closed the same hole for asynchronous block devices and filesystem-backed swap by keeping the stall window open across the whole batch so submission time is billed. Those accounting changes target newer trees only and are not marked for stable.

Kairui Song assembled the series after David Hildenbrand collected candidates found largely through automated analysis. Song reports arm64 testing with zram and with swap files on both synchronous and asynchronous devices, with no content mismatches.