From: Barry Song 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 Co-developed-by: Nanzhe Zhao Signed-off-by: Nanzhe Zhao --- 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 d55615f34300..9438691791ef 100644 --- a/drivers/block/zram/backend_zstd.c +++ b/drivers/block/zram/backend_zstd.c @@ -73,12 +73,12 @@ static int zstd_setup_params(struct zcomp_params *params) goto error; } - 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; - prm = zstd_get_cparams(params->level, PAGE_SIZE, + prm = zstd_get_cparams(params->level, ZCOMP_MULTI_PAGES_SIZE, params->dict_sz); if (!params->dict || !params->dict_sz) -- 2.43.0