Re: [PATCH v4 0/8] Batched zswap_store() framework with compression batching

From: Nhat Pham

Date: Fri Nov 20 2026 - 18:17:09 EST


On Thu, Nov 19, 2026 at 8:19 PM Kanchana P. Sridhar
<kanchanapsridhar2026@xxxxxxxxx> wrote:
>
>
> v4: Batched zswap_store() framework with compression batching
> =============================================================
>
> This series is a spin-off of "v14: zswap compression batching with optimized
> iaa_crypto driver" [1], and focuses on the generic crypto_acomp and zswap
> compression batching enablers. Resuming work on this series following a gap
> since v14 (January 2026). Please note that my email address and affiliation have
> changed from kanchana.p.sridhar@xxxxxxxxx to kanchanapsridhar2026@xxxxxxxxx. I
> have retained the original Intel sign-offs on prior patches for historical
> attribution while signing off v4 of this series with my current address.
>
> The main focus of v4 was to establish a performance measurement methodology to
> quantify the benefits to high level metrics by using zswap compression
> batching. This was done using an Intel Sapphire Rapids bare-metal instance with
> 48 physical cores and by running "usemem30", i.e., 30 concurrent usemem
> processes, each of which allocates 10G, in a 150G memory.high contrained cgroup,
> for 10 iterations. The environment was set up to minimize performance jitter so
> we can understand the system-level/workload-level advantages of zswap
> compression batching when running workloads at scale.
>
> To summarize the main contribution of this patch series: Batching is introduced
> in zswap_store() of large folios: we carve out a large folio into batches of
> ZSWAP_MAX_BATCH_SIZE (4 pages) for software compressors, and store each
> batch. Moving the fundamental operations that need to be happen to store a page
> to now work at the granularity of a batch offers opportunities to optimize them
> from these perspectives:
>
> 1) Utilize existing kernel API that minimize obtaining locks for bulk
> operations, e.g. kmem_cache_alloc_bulk()/kmem_cache_free_bulk().
>
> 2) We keep the working set for each of the core store functionalities
> (alloc/initialize zswap entries, compress pages, store pages in zsmalloc,
> pool/objcg reference increments, objcg charging) to be focused on a
> batch, thereby minimizing cache evictions and benefiting from cache
> locality.
>
> 3) Along the lines of (1), the main zswap_compress() batching routine obtains
> the comp_ctx mutex lock once per batch, and releases it after it has
> processed all pages in that batch.
>
> 4) Any zswap store functionality that works on a batch can potentially be
> optimized via bulk-processing/parallelized as a next step, to further improve
> performance.
>
> Performance testing: usemem30 with 100% over-commit:
> =====================================================
> Validation was done with mm-unstable as of 11-17-2026 (Baseline: commit
> 866f761fd414) and with this patch series.
>
> v4 was validated on an Intel Xeon Sapphire Rapids bare-metal instance with
> 48 cores.
>
> Bare-metal instance specs:
> --------------------------
> - 48 physical cores
> - 190G RAM
> - 200G SWAP disk partition
>
> Workload: 30 concurrent usemem processes, each allocates 10G:
> -------------------------------------------------------------
> The vm-scalability "usemem" test (unmodified version) was run in a
> cgroup with memory.high fixed at 150G. There is no swap limit set for the
> cgroup.
>
> To quantify the performance benefit of zswap compress batching at scale,
> 30 usemem processes were run ("usemem30"), each allocating and writing 10G of
> memory, and sleeping for 10 sec before exiting.
>
> usemem -w -O -b 5 -s 10 -n 30 10g
> echo 0 > /sys/module/zswap/parameters/shrinker_enabled
>
> Performance validation methodology:
> -----------------------------------
> These settings were used to minimize variation:
>
> - All cores were fixed to run at 2.4GHz with "performance" scaling governor.
> - Turbo boost was disabled.
> - CPU power-saving C-states restricted with:
>
> GRUB_CMDLINE_LINUX_DEFAULT="intel_idle.max_cstate=1 processor.max_cstate=1"
>
> The usemem30 experiments were run with the baseline mm-unstable as of
> 11-17-2026 (commit 866f761fd414) and with this patch-series.
>
> After booting into each kernel:
>
> 1) Constrain the cgroup's memory.high to 150G.
>
> 2) Run 2 warm-up iterations of usemem30. Don't use this data for benchmarking
> since sys time typically skews higher for initial runs.
>
> 3) Next, run 10 benchmarking iterations of usemem30:
> - Log these high-level metrics: Sys time and individual usemem throughput.
>
> 4) Sys time and Throughput metrics were gathered for three mTHP settings:
>
> - 2048kB
> - 1024kB
> - 64kB
>
> 5) Benchmark summary data includes Sys time and Throughput components from the
> 10 iterations of usemem30:
>
> - Total Samples
> - Mean Value
> - Std Deviation
> - CoV (Variance): Coefficient of variation (relative standard deviation)
> measures spread relative to the mean rather than statistical variance.
>
> An LLM was used to help generate the benchmarking and data processing scripts.
>
> usemem30 Benchmarking Summary:
> ==============================
>
> ---------------------------------------------------
> Improvement with v4 zswap compress batching
> ---------------------------------------------------
> mTHP enabled: 2048kB 1024kB 64kB
> ---------------------------------------------------
> Sys time: -13.87% -2.64% -1.72%
> Throughput: +3.85% +0.42% +1.31%
> ---------------------------------------------------

Have you tried perf-ing the store path to see what was the overhead
source (before and after this optimization)? I'm curious.

Mostly LGTM - still taking a look...