Re: [PATCH] mm/swap: publish cluster tables after full initialization

Andrew Morton <[email protected]>
Newsgroups dev.linux.lists.sashiko,org.kernel.vger.stable,org.kvack.linux-mm
Message-ID <[email protected]>
On Thu, 13 Aug 2026 23:03:16 +0800 Longlong Xia <[email protected]> wrote:

> From: Longlong Xia <[email protected]>
> 
> swap_cluster_populate() drops the local, global, and cluster locks
> before its sleeping allocation.  The allocation helper publishes ci->table
> before allocating the memcg table and, on some 32-bit configurations, the
> zero bitmap.
> 
> A stale per-CPU or global cluster cursor can reach the isolated cluster in
> that window.  Since CLUSTER_FLAG_NONE and a non-NULL table make the cluster
> appear usable, it can allocate a slot without the auxiliary state.  An
> auxiliary allocation failure can then tear down a table which is already in
> use.
> 
> Allocate the complete set of tables into a private carrier.  Install the
> auxiliary pointers and publish the main table only while holding ci->lock;
> the slow path does this after reacquiring all allocator locks.  Allocation
> failures now free only unpublished resources.

This is a complex patch, for a problem which I'm assuming nobody has
ever encountered.

> Fixes: b197d41462c2 ("mm/memcg, swap: store cgroup id in cluster table directly")

For the eleven thousandth time (I'm not blaming you - this is endemic). 
When fixing a bug, please fully describe the userspace-visible runtime
effects of this bug.

If there is a report then document this.  If there is a testcase which
triggers this then document it.  If there is neither then document
that.

> Cc: [email protected]

Especially when proposing a backport.

Think of the -stable maintainers, and of everyone downstream of them. 
They're looking at this thing wondering "should I merge this into my
kernel".  We're providing them no reason for doing that!  We should do
this.  We're the swap experts, aren't we?  They depend upon us to
explain these things.

> Assisted-by: Codex:gpt-5.6-sol

Doesn't have a great track record, in my drive-by experience.  Sashiko
has found real bugs in things which gpt accepted.  And a second opinion
is always welcome.

Sashiko review says "No regressions", but it also says "Status:
Skipped".  I cannot figure out what this means.  Let me
cc:[email protected].  Folks, can you please explain?

https://sashiko.dev/#/patchset/[email protected]

> Signed-off-by: Longlong Xia <[email protected]>

Thanks.

>  mm/swapfile.c | 167 +++++++++++++++++++++++++++++++++++---------------

I'll take a pass on this and shall await comment from the swap
maintainers.  And please understand that it'll be a lot of work for
them, and without that statement of "userspace-visible runtime
effects", their motivation will not be high.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.