Re: [PATCH v3 13/18] zram: lz4hc: compress levels above 9 as level 9

From: Sergey Senozhatsky

Date: Wed Dec 02 2026 - 21:27:02 EST


On (26/12/02 18:32), Michal Wilczynski wrote:
[..]
> +++ b/drivers/block/zram/backend_lz4hc.c
> @@ -36,6 +36,16 @@ static int lz4hc_setup_params(struct zcomp_params *params)
> */
> pr_err("invalid compression level %d\n", params->level);
> return -EINVAL;
> + } else if (params->level >= LZ4HC_OPT_MIN_CLEVEL) {
> + /*
> + * These levels select LZ4's optimal parser, which on a page
> + * compresses 2-5 times slower than level 9 for well under
> + * 1% smaller output. It suits data compressed once and
> + * read many times, not swap.
> + */
> + pr_info("level %d compresses as level %d\n", params->level,
> + LZ4HC_OPT_MIN_CLEVEL - 1);
> + params->level = LZ4HC_OPT_MIN_CLEVEL - 1;
> }

My preference would be to just return an error. We should not correct
"bad" user input.