Re: [PATCH v1] zram: add size class equals check into recompression

Sergey Senozhatsky
2022-10-25T01:41:23Z

On (22/10/24 13:59), Andrew Morton wrote:
> > It makes no sense for us to recompress the object if it will
> > be in the same size class. We anyway don't get any memory gain.
> > But, at the same time, we get a CPU time overhead when inserting
> > this object into zspage and decompressing it afterwards.
> >
>
> Dumb question: is it ever possible for compression to result in an
> increase in size?

That's a good question. Re-compressed object can be bigger than the
original compressed one, but this should already be taken care of.
We do
if (comp_len_next >= huge_class_size ||
comp_len_next >= comp_len_prev ||

This checks whether recompressed object is above huge-size watermark and
whether recompressed size is larger than the original size.