Re: [PATCH 01/19] mm/swap: rename __read_swap_cache_async to swap_cache_alloc_folio
From: Yosry Ahmed
Date: Mon Nov 03 2025 - 11:51:20 EST
On Mon, Nov 03, 2025 at 05:02:28PM +0800, Kairui Song wrote:
> On Mon, Nov 3, 2025 at 4:28 PM Barry Song <baohua@xxxxxxxxxx> wrote:
> > > > +/**
> > > > + * swap_cache_alloc_folio - Allocate folio for swapped out slot in swap cache.
> > > > + * @entry: the swapped out swap entry to be binded to the folio.
> > > > + * @gfp_mask: memory allocation flags
> > > > + * @mpol: NUMA memory allocation policy to be applied
> > > > + * @ilx: NUMA interleave index, for use only when MPOL_INTERLEAVE
> > > > + * @new_page_allocated: sets true if allocation happened, false otherwise
> > > > + * @skip_if_exists: if the slot is a partially cached state, return NULL.
> > > > + * This is a workaround that would be removed shortly.
> > > > + *
> > > > + * Allocate a folio in the swap cache for one swap slot, typically before
> > > > + * doing IO (swap in or swap out). The swap slot indicated by @entry must
> > > > + * have a non-zero swap count (swapped out). Currently only supports order 0.
>
> Hi Yosry and Barry, thanks for the review.
>
> > >
> > > Is it used for swap in? That's confusing because the next sentence
> > > mention that it needs to be already swapped out.
>
> Yes, swap in is the typical user, swap_vma_readahead calls this
> function directly, allocate a folio then initiate the swap in IO.
>
> I'm not sure why it is confusing. A swapped out slot getting swapped
> in seems a very common thing?
I mixed up swapping in and swapping out :) I was complaining about
mentioning "swapping out", not vice versa. Sorry for the confusion.
>
> > >
> > > I suspect you're referring to the zswap writeback use case, but in this
> > > case we're still "swapping-in" the folio from zswap to swap it out to
> > > disk. I'd avoid mentioning swap in here because it's confusing.
>
> Oh, I thought the zswap writeback is considered a kind of swap out :),
> since it's technically writing data from ram to swap device.
We do swap the page out, but we use __read_swap_cache_async() to "swap
in" the page from zswap first.
>
> >
> > I assume you mean avoiding any mention of swap-out? As for swap-out, we’re
> > swapping a folio out from the LRU — we’re not allocating a new folio.
> >
> > BTW, this sentence also feels a bit odd to me. I’d prefer removing
> > “swap out” from
> > “doing IO (swap in or swap out)”.
>
> How about "doing IO (e.g. swap in or zswap writeback)"? Swap-in is a
> very common user, and zswap writeback can be mentioned explicitly.
Looks good to me. Thanks.