mm: zswap: reduce request contention on loads
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest3 patches 0 repliesNew
- v33 patches 4 repliesSuperseded
- v22 patches 6 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 2 patches | 16 replies | Superseded |
Changes in v4 from the cover letter
- Propagate each zswap_acomp_req_init() error from CPU preparation, including asynchronous decompression request allocation (Yosry).
- Add Herbert Xu's Acked-by tag to patch 1 and Yosry Ahmed's to patches 1 and 3.
- Document the extra per-CPU memory in patch 1 and the cover letter (Yosry).
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | mm: zswap: use separate compression and decompression requestsmm/ | +70 | 0 replies | |
| 2/3 | crypto: acomp - enforce MAX_SYNC_COMP_REQSIZEcrypto/ | +9 | 0 replies | |
| 3/3 | mm: zswap: use stack requests for synchronous decompressionmm/ | +56 | 0 replies |
Reviews trailers per patch
2 of 3 patches have a Reviewed-by or Acked-by.
| Patch | Nhat Pham | Herbert Xu | Yosry Ahmed |
|---|---|---|---|
| 1/3 | A-b | A-b | A-b |
| 2/3 | |||
| 3/3 | A-b | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH v4 0/3] mm: zswap: reduce request contention on loads
Stores and loads share a per-CPU acomp request and mutex. A low-priority store can be preempted right after the compressor drops its stream lock, while it still holds the zswap mutex, and a higher-priority load on that CPU then waits for the store to run again. This follows the work from Sergey Senozhatsky's zram series which splits it for the same reason [1].
Patch 1 gives compression and decompression separate requests, waits and mutexes, so loads no longer wait for stores, though they can still wait for each other. Patch 2, authored by Herbert Xu, enforces MAX_SYNC_COMP_REQSIZE when synchronous Crypto ACOMP transforms are initialized. Patch 3 uses an on-stack request for synchronous decompression, so those loads take no zswap lock. This covers all in-tree software compressors. Asynchronous algorithms keep the per-CPU request and mutex.
On x86-64 without PREEMPT_RT or lock debugging, each pool's per-CPU context grows from 88 to 160 bytes (+72 bytes). Patch 1 also adds one heap request per initialized CPU per pool: 176 bytes plus the algorithm's request context, before alignment and allocator rounding. Patch 3 drops that extra heap request for synchronous algorithms, including zstd. The context increase remains for all algorithms, and asynchronous algorithms retain the extra heap request. The load path is about 270 bytes deeper on x86-64.
The series does not fix two related cases:
- Stores still serialize on the compression mutex, so a high-priority task that reclaims (direct reclaim, MADV_PAGEOUT) can still wait for a preempted store.
- On PREEMPT_RT the codec stream locks are preemptible, so a load can still wait for a preempted store inside the codec.
The numbers below are the slowest read per run, as a median (min-max) of 5 runs. Each run is 12 seconds in a zstd VM with lazy preemption, vm.page-cluster=0 and swap on /dev/ram0. With 1 vCPU, four nice +10 workers page memory out and read it back while a nice 0 task spins. A nice -19 reader pages out its own buffer and measures how long each read of it takes. With 8 vCPUs there are 16 workers, 8 spinning tasks and 8 readers.
Before series (ms) With series (ms) 1 vCPU 22.3 (21.6-22.6) 0.97 (0.72-1.4) 8 vCPUs 314 (97-2542) 7.0 (5.0-98)
Reads over 10 ms fell from 26-35 per run to none with 1 vCPU, and from 3-18 per run to at most one with 8 vCPUs. The benchmark and test programs
were written with the help of an LLM.
[1]
https://lore.kernel.org/all/[email protected]/
v3 -> v4:
- Propagate each zswap_acomp_req_init() error from CPU preparation, including asynchronous decompression request allocation (Yosry).
- Add Herbert Xu's Acked-by tag to patch 1 and Yosry Ahmed's to patches 1 and 3.
- Document the extra per-CPU memory in patch 1 and the cover letter (Yosry).
v2 -> v3:
- Include Herbert Xu's Crypto API patch enforcing MAX_SYNC_COMP_REQSIZE when synchronous ACOMP transforms are initialized.
- Use acomp_is_async() in the stack-request patch and remove the redundant acomp_can_use_stack_req() helper (Herbert).
v1 -> v2:
- Group the compression request and output buffer in zswap_comp_ctx, documenting that the compression mutex protects the buffer (Yosry).
- Move the existing synchronous and request context size checks into the Crypto API helper acomp_can_use_stack_req() (Yosry).
- Share callback setup through zswap_set_acomp_req_callback() and explain
the two decompression paths (Yosry).
- Clarify in patch 1's commit message that codecs and drivers synchronize
shared transform state internally (Yosry).
- Add Nhat Pham's Acked-by on patch 2.
- Add Nhat Pham's Acked-by to the first zswap patch.
Herbert Xu (1):
crypto: acomp - enforce MAX_SYNC_COMP_REQSIZE
Usama Arif (2):
mm: zswap: use separate compression and decompression requests
mm: zswap: use stack requests for synchronous decompression
crypto/acompress.c | 18 ++--- mm/zswap.c | 163 ++++++++++++++++++++++++++++++--------------- 2 files changed, 117 insertions(+), 64 deletions(-)
Signature · 1 line
2.53.0-Meta