From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,yuanchu@google.com,youngjun.park@lge.com,
willy@infradead.org,weixugc@google.com,stable@vger.kernel.org,
shikemeng@huaweicloud.com,shakeel.butt@linux.dev,ryncsn@gmail.com,
qi.zheng@linux.dev,mhocko@kernel.org,ljs@kernel.org,kasong@tencent.com,
hannes@cmpxchg.org,david@kernel.org,chrisl@kernel.org,brauner@kernel.org,
baoquan.he@linux.dev,baolin.wang@linux.alibaba.com,baohua@kernel.org,
axelrasmussen@google.com,nphamcs@gmail.com,akpm@linux-foundation.org
Subject: [merged mm-hotfixes-stable] mm-swap-skip-relocation-of-tableless-clusters.patch removed from -mm tree
Date: Sun, 22 Nov 2026 22:25:01 -0800 [thread overview]
Message-ID: <20261123062502.609E51F000E0@smtp.kernel.org> (raw)
In-Reply-To: <20261110151407.789960-4-nphamcs@gmail.com>
The quilt patch titled
Subject: mm/swap: skip relocation of tableless clusters
has been removed from the -mm tree. Its filename was
mm-swap-skip-relocation-of-tableless-clusters.patch
This patch was dropped because it was merged into the mm-hotfixes-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Nhat Pham <nphamcs@gmail.com>
Subject: mm/swap: skip relocation of tableless clusters
Date: Tue, 10 Nov 2026 07:14:07 -0800
A stale reclaimer can reach relocate_cluster() after another allocator
re-isolates an emptied cluster and drops its locks to populate the table.
The cluster has zero count, CLUSTER_FLAG_NONE and no table, so relocation
can free it again and dereference NULL in the DEBUG_VM empty check.
CPU0 CPU1
Reclaimer Allocator
alloc_swap_scan_cluster()
cluster_reclaim_range()
spin_unlock(&ci->lock)
__try_to_reclaim_swap()
swap_cache_del_folio()
__swap_cache_del_folio()
__swap_cache_do_del_folio()
__swap_cluster_free_entries()
free_cluster()
__free_cluster()
swap_cluster_free_table()
swap_cluster_unlock(ci)
isolate_lock_cluster()
swap_cluster_populate()
drop ci and outer locks
swap_cluster_alloc_table()
spin_lock(&ci->lock)
relocate_cluster()
free_cluster()
__free_cluster()
swap_cluster_assert_empty()
__swap_table_get() /* NULL table */
Leave tableless clusters to the allocator under ci->lock. This also stops
a stale reclaimer from returning a cluster to the free list while table
population is pending, avoiding the resulting FREE-to-NONE state cycle.
The existing cluster lock serializes the table check and relocation with
population.
Link: https://patch.msgid.link/20261110151407.789960-4-nphamcs@gmail.com
Fixes: 07adc4cf1ecd ("mm, swap: implement dynamic allocation of swap table")
Signed-off-by: Nhat Pham <nphamcs@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/all/sashiko-outbox-203018@kernel.org/
Acked-by: Kairui Song <kasong@tencent.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Qi Zheng <qi.zheng@linux.dev>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Barry Song <baohua@kernel.org>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Cc: Wei Xu <weixugc@google.com>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Christopher Li <chrisl@kernel.org>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Youngjun Park <youngjun.park@lge.com>
Cc: <ryncsn@gmail.com>
Cc: <stable@vger.kernel.org>
mm/swapfile.c | 7 +++++++
1 file changed, 7 insertions(+)
--- a/mm/swapfile.c~mm-swap-skip-relocation-of-tableless-clusters
+++ a/mm/swapfile.c
@@ -815,6 +815,13 @@ static void relocate_cluster(struct swap
if (cluster_is_discard(ci))
return;
+ /*
+ * An allocator may still be preparing the table.
+ * Leave the cluster to it.
+ */
+ if (!cluster_table_is_alloced(ci))
+ return;
+
if (!ci->count) {
if (ci->flags != CLUSTER_FLAG_FREE)
free_cluster(si, ci);
_
Patches currently in -mm which might be from nphamcs@gmail.com are
prev parent reply other threads:[~2026-11-23 6:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 15:14 [PATCH v2 0/3] mm: fix swapcache writeout and cluster table races Nhat Pham
2026-11-10 15:14 ` [PATCH v2 1/3] mm: vmscan: allow writeout of swapcache folios without anon mappings Nhat Pham
2026-11-23 6:24 ` [merged mm-hotfixes-stable] mm-vmscan-allow-writeout-of-swapcache-folios-without-anon-mappings.patch removed from -mm tree Andrew Morton
2026-11-10 15:14 ` [PATCH v2 2/3] mm/swap: publish cluster tables after reacquiring allocator locks Nhat Pham
2026-11-15 12:56 ` Kairui Song
2026-11-10 15:14 ` [PATCH v2 3/3] mm/swap: skip relocation of tableless clusters Nhat Pham
2026-11-14 19:59 ` Kairui Song
2026-11-23 6:25 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123062502.609E51F000E0@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=brauner@kernel.org \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=ljs@kernel.org \
--cc=mhocko@kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=nphamcs@gmail.com \
--cc=qi.zheng@linux.dev \
--cc=ryncsn@gmail.com \
--cc=shakeel.butt@linux.dev \
--cc=shikemeng@huaweicloud.com \
--cc=stable@vger.kernel.org \
--cc=weixugc@google.com \
--cc=willy@infradead.org \
--cc=youngjun.park@lge.com \
--cc=yuanchu@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.