Re: [PATCH v4] mm/zswap: store <PAGE_SIZE compression failed page as-is
From: Barry Song
Date: Tue Aug 19 2025 - 21:14:13 EST
[...]
> +
> + /*
> + * If a page cannot be compressed into a size smaller than PAGE_SIZE,
> + * save the content as is without a compression, to keep the LRU order
> + * of writebacks. If writeback is disabled, reject the page since it
> + * only adds metadata overhead. swap_writeout() will put the page back
> + * to the active LRU list in the case.
> + */
> + if (comp_ret || !dlen) {
> + zswap_crypto_compress_fail++;
> + dlen = PAGE_SIZE;
> + }
I’m not entirely sure about this. As long as we pass 2*PAGE_SIZE as
dst_buf, any error returned by crypto drivers should indicate a bug in
the driver that needs to be fixed.
There have also been attempts to unify crypto drivers so they consistently
return -ENOSPC when the destination buffer would overflow. If that has
been achieved, we might be able to reduce the buffer from 2*PAGE_SIZE to
just PAGE_SIZE in zswap. There was a long discussion on this here:
https://lore.kernel.org/linux-mm/Z7dnPh4tPxLO1UEo@xxxxxxxxxx/
I’m not sure of the current status — do all crypto drivers now return a
consistent -ENOSPC when the compressed size exceeds PAGE_SIZE? From
what I recall during that discussion, most drivers already behaved this
way, but Sergey Senozhatsky pointed out one or two exceptions.
Let’s sync with Herbert: have we reached the stage where all drivers
reliably return -ENOSPC when dst_buf is PAGE_SIZE but the compressed
size would exceed it?
Thanks
Barry