Re: [PATCH v4 04/11] mm: zswap: add range lookup for large-folio swapin
From: Usama Arif
Date: Mon Jul 13 2026 - 12:31:59 EST
On 13/07/2026 17:02, Yosry Ahmed wrote:
>> /**
>> * zswap_load() - load a folio from zswap
>> * @folio: folio to load
>> @@ -1571,10 +1588,9 @@ bool zswap_store(struct folio *folio)
>> * NOT marked up-to-date, so that an IO error is emitted (e.g. do_swap_page()
>> * will SIGBUS).
>> *
>> - * -EINVAL: if the swapped out content was in zswap, but the page belongs
>> - * to a large folio, which is not supported by zswap. The folio is unlocked,
>> - * but NOT marked up-to-date, so that an IO error is emitted (e.g.
>> - * do_swap_page() will SIGBUS).
>> + * -EIO: if a slot in a large-folio range is unexpectedly still in zswap.
>> + * The folio is unlocked, but NOT marked up-to-date, so that an IO
>> + * error is emitted (e.g. do_swap_page() will SIGBUS).
>
> Just curious, why the change from -EINVAL to -EIO here? Does it matter
> in practice or is it just a matter of personal taste? :)
The caller only checks for != -ENOENT so no functional difference here. I viewed
it as a change in semantic, -EINVAL meant that you passed a large folio, which
wasn't supported to -EIO meaning the request is valid but zswap cannot safely
complete a PMD-sized read from per-page compressed state.
I dont want to speak for Alexandre, will let him comment on this properly :)
But above is what I thought of when I got the patch from Alex.
>
>> *
>> * -ENOENT: if the swapped out content was not in zswap. The folio remains
>> * locked on return.
>> @@ -1593,13 +1609,19 @@ int zswap_load(struct folio *folio)
>> return -ENOENT;
>>
>> /*
>> - * Large folios should not be swapped in while zswap is being used, as
>> - * they are not properly handled. Zswap does not properly load large
>> - * folios, and a large folio may only be partially in zswap.
>> + * A large folio reaches zswap_load() only when its whole range is
>> + * expected to be on disk: PMD swap-entry consumers split before
>> + * calling into PMD-order swapin whenever any slot is still in zswap.
>> + * Confirm the range is entirely absent from zswap and return -ENOENT
>> + * so the caller reads it from disk; if a slot is unexpectedly still in
>> + * zswap, fail the read rather than return partially-initialized data.
>> */
>> - if (WARN_ON_ONCE(folio_test_large(folio))) {
>> - folio_unlock(folio);
>> - return -EINVAL;
>> + if (folio_test_large(folio)) {
>> + if (zswap_is_present(swp, folio_nr_pages(folio))) {
>> + folio_unlock(folio);
>> + return -EIO;
>> + }
>> + return -ENOENT;
>> }
>>
>> entry = xa_load(tree, offset);
>> --
>> 2.53.0-Meta
>>