Re: [PATCH 2/2] mm/swap: publish cluster tables after reacquiring allocator locks

From: Nhat Pham

Date: Fri Nov 06 2026 - 15:00:00 EST


On Fri, Nov 6, 2026 at 9:04 AM Nhat Pham <nphamcs@xxxxxxxxx> wrote:
>
> Under memory pressure, swap_cluster_populate() can publish a table
> while its locks are dropped for a sleeping allocation. A cached
> allocator can consume and free that table before the populating
> allocator resumes, leaving the resumed scan with a NULL table.
>
> CPU0 CPU1
> swap_cluster_populate()
> drop local/global/ci locks
> allocate and publish table
> swap_alloc_fast()
> consume the table
> charge failure cleanup
> free the table
> reacquire local/global/ci
> return ci
> alloc_swap_scan_cluster()
> read the missing table
>
> Keep the count table, cgroup table and zero bitmap private until
> swap_cluster_alloc_table() restores all allocator locks. Install them
> under the cluster lock and retain it through the scan. Initial bad-slot
> setup takes only the cluster lock because the device is unpublished.
>
> A stale reclaimer can return the isolated cluster to allocation while
> its locks are dropped. Abandon installation if the list state changes or
> a table appears, freeing only private allocations. Restore locks on
> allocation failure too, so the caller can return a still-isolated
> cluster to its free list.
>
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Link: https://lore.kernel.org/all/sashiko-outbox-181084@xxxxxxxxxx/
> Link: https://lore.kernel.org/all/sashiko-outbox-181086@xxxxxxxxxx/
> Co-developed-by: Kairui Song <ryncsn@xxxxxxxxx>

I think I need a

Signed-off-by: Kairui Song <ryncsn@xxxxxxxxx>

here as well...

(Kairui - up to you if you feel like Co-developed-by + Signed-off-by
or Suggested-by + Acked-by is more appropriate here. I just filled in
the sketch you gave me.)