[PATCH 3/4] zram: backend_zstd: use multi-page size for zstd parameter setup
From: Nanzhe Zhao
Date: Fri Dec 04 2026 - 21:20:14 EST
From: Barry Song <baohua@xxxxxxxxxx>
zstd_setup_params() passes PAGE_SIZE to zstd_get_params() and
zstd_get_cparams() as the source size hint. When multi-page compression
is enabled, compressing 16 KiB blocks with 4 KiB-tuned parameters limits
zstd's match window to a single page and prevents it from finding
cross-page redundancy.
Pass ZCOMP_MULTI_PAGES_SIZE instead of PAGE_SIZE so that zstd configures
its parameters for the multi-page block size.
Signed-off-by: Barry Song <baohua@xxxxxxxxxx>
Co-developed-by: Nanzhe Zhao <zhaonanzhe@xxxxxxxxxx>
Signed-off-by: Nanzhe Zhao <zhaonanzhe@xxxxxxxxxx>
---
drivers/block/zram/backend_zstd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/block/zram/backend_zstd.c b/drivers/block/zram/backend_zstd.c
index 824174815ddf..63f133fcb4b3 100644
--- a/drivers/block/zram/backend_zstd.c
+++ b/drivers/block/zram/backend_zstd.c
@@ -73,7 +73,7 @@ static int zstd_setup_params(struct zcomp_params *params)
return -ENOMEM;
params->drv_data = zp;
- zp->cprm = zstd_get_params(params->level, PAGE_SIZE);
+ zp->cprm = zstd_get_params(params->level, ZCOMP_MULTI_PAGES_SIZE);
zp->custom_mem.customAlloc = zstd_custom_alloc;
zp->custom_mem.customFree = zstd_custom_free;
@@ -81,7 +81,7 @@ static int zstd_setup_params(struct zcomp_params *params)
if (!params->dict || !params->dict_sz)
return 0;
- prm = zstd_get_cparams(params->level, PAGE_SIZE,
+ prm = zstd_get_cparams(params->level, ZCOMP_MULTI_PAGES_SIZE,
params->dict_sz);
zp->cdict = zstd_create_cdict_byreference(params->dict,
params->dict_sz,
--
2.43.0