Re: [PATCHv4 2/9] zram: Add recompression algorithm sysfs knob

From: Sergey Senozhatsky
Date: Fri Nov 04 2022 - 20:00:49 EST


On (22/11/05 08:41), Sergey Senozhatsky wrote:
> One can be SW one can be HW. So I thought about having flexibility here.
> Instead of doing
>
> for (idx = 1; idx < MAX_IDX; idx++) {
> len = zcomp_compress(zram->comps[idx]);
> if (len <= threshold)
> break;
> }
>
> We would just directly use the suggested algo.
>
> But we probably don't need that param at all and can use
> the loop instead?

My idea was that recompress does not loop through the algos (what
on the fly recompression can do for instance), but instead
recompress only does one thing.

Because we can have, for instance, something like this

algo=zstd priority=1
algo=deflate priority=2

And we recompress with algo=zstd only first. Without going
into the slowest, most CPU and power consuming one. If the
memory pressure keeps increasing then we might do algo=deflate
recompress, as the last resort before we do writeback. But we
may skip algo=deflate altogether and go straight to writeback,
for instance because we have less than 30% of battery left.

So the reason I suggested algo= in recompress was, basically,
for that for having exact control of what recompression does.