Re: [PATCH v3 04/12] mm, swap: add support for stable large allocation in swap cache directly

From: YoungJun Park

Date: Wed May 13 2026 - 13:53:07 EST


On Tue, Apr 21, 2026 at 02:16:48PM +0800, Kairui Song via B4 Relay wrote:
...
> static struct folio *swap_cache_read_folio(swp_entry_t entry, gfp_t gfp,
> struct mempolicy *mpol, pgoff_t ilx,
> struct swap_iocb **plug, bool readahead)
> {
> - struct swap_info_struct *si = __swap_entry_to_info(entry);
> struct folio *folio;
>
> /* Check the swap cache again for readahead path. */
> @@ -594,16 +700,12 @@ static struct folio *swap_cache_read_folio(swp_entry_t entry, gfp_t gfp,
> if (folio)
> return folio;
> - /* Skip allocation for unused and bad swap slot for readahead. */
> - if (!swap_entry_swapped(si, entry))
> - return NULL;
> -

Hello Kairui

With the swap_entry_swapped() check gone, the swap_cache_get_folio()
above the do-while is now just a duplicate of the loop's first
iteration. Might as well drop it (and the now-stale "again for readahead
path" comment) here.

Best regrads
Youngjun Park

> do {
> folio = swap_cache_get_folio(entry);
> if (folio)
> return folio;
>
> - folio = swap_cache_alloc_folio(entry, gfp, mpol, ilx);
> + folio = swap_cache_alloc_folio(entry, gfp, 0, NULL, mpol, ilx);
> } while (IS_ERR(folio) && PTR_ERR(folio) == -EEXIST);