From: Harry Yoo <harry@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>,
Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Suren Baghdasaryan <surenb@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
syzbot+527fed49e5b988882c9a@syzkaller.appspotmail.com,
Breno Leitao <leitao@debian.org>
Subject: Re: [PATCH] mm/slub: don't let kmemleak report rcu sheaves
Date: Fri, 4 Dec 2026 13:04:42 +0000 [thread overview]
Message-ID: <axKxt_M_jhbaj5Eq@thinkstation> (raw)
In-Reply-To: <axKZT5kyaNJW56yb@arm.com>
On Fri, Dec 04, 2026 at 10:43:27AM +0000, Catalin Marinas wrote:
> On Wed, Nov 25, 2026 at 02:10:45PM +0000, Harry Yoo wrote:
> > On Wed, Nov 18, 2026 at 04:06:29PM +0000, Catalin Marinas wrote:
> > > On Tue, Nov 17, 2026 at 11:05:28PM +0000, Catalin Marinas wrote:
> > > > diff --git a/mm/slub.c b/mm/slub.c
> > > > index 45e077c7526c..13b8e57d6dae 100644
> > > > --- a/mm/slub.c
> > > > +++ b/mm/slub.c
> > > > @@ -6278,6 +6278,14 @@ bool __kfree_rcu_sheaf(struct kmem_cache *s, void *obj, unsigned int free_flags)
> > > >
> > > > local_unlock(&s->cpu_sheaves->lock);
> > > >
> > > > + /*
> > > > + * A sheaf allocated with kmalloc_nolock() is not tracked by
> > > > + * kmemleak, so neither its objects nor the rcu callback queued
> > > > + * after it would be scanned. Fall back to defer_kfree_rcu().
> > > > + */
> > > > + if (IS_ENABLED(CONFIG_DEBUG_KMEMLEAK) && !allow_spin)
> > > > + goto fail;
> > > > +
> > > > /* Don't wake up kswapd, it will cause deadlock under pi_lock */
> > > > empty = alloc_empty_sheaf(s, __GFP_NOWARN, alloc_flags);
> > > >
> > >
> > > For the objects queued in a sheaf, rather than the !allow_spin fallback
> > > above, it's simpler to move the kmemleak_ignore() call in
> > > kvfree_call_rcu() before kfree_rcu_sheaf(), so they are treated the same
> > > as on the non-sheaf path.
> >
> > No strong opinion on this but kmemleak_not_leak() would let kmemleak
> > track objects queued in a sheaf?
> >
> > Wondering it'd make sense to mark bnodes with kmemleak_not_leak() as
> > well instead of calling kmemleak_ignore() on all objects.
>
> bnodes are allocated with __get_free_page() and these objects are not
> tracked by kmemleak.
Ouch, right :)
> Instead we'd need kmalloc_alloc/free() on bnodes
> but I think the existing kmemleak_ignore() is simpler, it covers other
> cases as well.
Agreed.
I'm kinda debating whether v2 is ready to be queued to slab tree as
it doesn't handle a sheaf allocated with !allow_spin and you suggested:
> For the objects queued in a sheaf, rather than the !allow_spin
> fallback above, it's simpler to move the kmemleak_ignore() call in
> kvfree_call_rcu() before kfree_rcu_sheaf(), so they are treated the
> same as on the non-sheaf path.
https://lore.kernel.org/linux-mm/av3NBYxYXyYk_tjS@arm.com
Thoughts?
--
Cheers,
Harry / Hyeonggon
next prev parent reply other threads:[~2026-12-04 13:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 15:18 [PATCH] mm/slub: don't let kmemleak report rcu sheaves Nguyen Ngoc Thang
2026-11-16 10:54 ` Vlastimil Babka (SUSE)
2026-11-17 23:05 ` Catalin Marinas
2026-11-18 16:06 ` Catalin Marinas
2026-11-25 14:10 ` Harry Yoo
2026-12-04 10:43 ` Catalin Marinas
2026-12-04 13:04 ` Harry Yoo [this message]
2026-12-05 12:06 ` Catalin Marinas
2026-11-18 16:10 ` Catalin Marinas
2026-11-23 15:23 ` [PATCH v2] " Nguyen Ngoc Thang
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=axKxt_M_jhbaj5Eq@thinkstation \
--to=harry@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=cl@gentwo.org \
--cc=hao.li@linux.dev \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ngocthang2710.1999@gmail.com \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=surenb@google.com \
--cc=syzbot+527fed49e5b988882c9a@syzkaller.appspotmail.com \
--cc=vbabka@kernel.org \
/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.