From: <hu.shengming@zte.com.cn>
To: <harry@kernel.org>
Cc: <vbabka@kernel.org>, <akpm@linux-foundation.org>,
<hao.li@linux.dev>, <cl@gentwo.org>, <rientjes@google.com>,
<roman.gushchin@linux.dev>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>, <zhang.run@zte.com.cn>,
<xu.xin16@zte.com.cn>, <yang.tao172@zte.com.cn>,
<yang.yang29@zte.com.cn>
Subject: Re: [PATCH v5] mm/slub: defer freelist construction until after bulk allocation from a new slab
Date: Mon, 13 Apr 2026 14:20:09 +0800 (CST) [thread overview]
Message-ID: <20260413142009771oJn6KdfOwqg6hop17-6bF@zte.com.cn> (raw)
In-Reply-To: <adx-2p09xEKz5Zdb@hyeyoo>
Harry wrote:
> On Mon, Apr 13, 2026 at 01:14:23PM +0800, hu.shengming@zte.com.cn wrote:
> > Harry wrote:
> > > On Thu, Apr 09, 2026 at 08:43:52PM +0800, hu.shengming@zte.com.cn wrote:
> > > > From: Shengming Hu <hu.shengming@zte.com.cn>
> > > > [...]
> > > > - inc_slabs_node(s, nid, slab->objects);
> > > > spin_unlock_irqrestore(&n->list_lock, flags);
> > > >
> > > > + inc_slabs_node(s, slab_nid(slab), slab->objects);
> > >
> > > Ouch, I didn't catch this when it was added in v4. When slab debugging
> > > feature is enabled for the cache, inc_slabs_node() should be done within
> > > the spinlock to avoid race conditions with slab validation.
> > >
> > > Perhaps it's worth adding a comment mentioning this :)
> > >
> > > See commit c7323a5ad078 ("mm/slub: restrict sysfs validation to debug
> > > caches and make it safe") for more details.
> > >
> > > With this fixed, please feel free to add:
> > > Reviewed-by: Harry Yoo (Oracle) <harry@kernel.org>
> > >
> >
> > You are right about the inc_slabs_node() placement. I missed that change when
> > it was introduced in v4. Thank you very much for catching it.
> >
> > After reading commit c7323a5ad078 ("mm/slub: restrict sysfs validation to debug
> > caches and make it safe"), my understanding is that inc_slabs_node() should
> > remain under n->list_lock for debug caches, so that validation cannot observe
> > inconsistent state during list transitions. I will fix that in the next revision
> > and add a comment along these lines.
> >
> > Would a comment like the following look good? :-)
> >
> > /*
> > * Debug caches require nr_slabs updates under n->list_lock so validation
> > * cannot race with list transitions and observe inconsistent state.
> > */
>
> Mostly LGTM, but perhaps it's better to say
> "validation cannot race with slab (de)allocations"
> because it's not about transitions between lists,
> but rather about slabs being added to or removed from the node while
> validation code is iterating over partial and full lists.
>
> Thanks!
>
Thanks, that makes sense.
You're right that the issue is better described in terms of slab
(de)allocations rather than list transitions.
I'll update the comment.
--
Cheers,
Shengming
prev parent reply other threads:[~2026-04-13 6:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 12:43 hu.shengming
2026-04-13 3:45 ` Harry Yoo (Oracle)
2026-04-13 5:14 ` hu.shengming
2026-04-13 5:27 ` Harry Yoo (Oracle)
2026-04-13 6:20 ` hu.shengming [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=20260413142009771oJn6KdfOwqg6hop17-6bF@zte.com.cn \
--to=hu.shengming@zte.com.cn \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@kernel.org \
--cc=xu.xin16@zte.com.cn \
--cc=yang.tao172@zte.com.cn \
--cc=yang.yang29@zte.com.cn \
--cc=zhang.run@zte.com.cn \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox