Re: [RFC PATCH] mm/zswap: store compression failed page as-is
From: SeongJae Park
Date: Thu Jul 31 2025 - 12:44:14 EST
On Wed, 30 Jul 2025 17:22:51 -0700 Nhat Pham <nphamcs@xxxxxxxxx> wrote:
> On Wed, Jul 30, 2025 at 5:21 PM Nhat Pham <nphamcs@xxxxxxxxx> wrote:
> >
> > On Wed, Jul 30, 2025 at 4:41 PM SeongJae Park <sj@xxxxxxxxxx> wrote:
> >
> > This might not be safe.
> >
> > It's conceivable that in zswap_compress(), some compression algorithm
> > "successfully" compresses a page to the same size (comp_ret == 0). We
> > hand that to zsmalloc, which happily stores the page.
> >
> > When we "decompress" the page again, we will attempt to
> > memcpy_to_folio from a bogus address (the handle from zsmalloc).
> >
> > So, in zswap_compress, you have to treat both comp_ret == 0 and dlen
> > == PAGE_SIZE as "compression failure".
>
> Meant to say comp_ret != 0 here... sorry for the confusion...
No worry, thank you for clarifying!
Thanks,
SJ