From: sashiko-bot@kernel.org
To: "Harry Yoo (Oracle)" <harry@kernel.org>
Cc: linux-rt-devel@lists.linux.dev, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH slab/for-next v4 4/8] mm/slab: extend deferred free mechanism to handle rcu sheaves
Date: Mon, 20 Jul 2026 13:03:32 +0000 [thread overview]
Message-ID: <20260720130332.ED34A1F00A3F@smtp.kernel.org> (raw)
In-Reply-To: <20260720-kfree_rcu_nolock-v4-4-964e03c41a4e@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] `__kfree_rcu_sheaf()` acquires a lock using `local_trylock()`, which triggers a lockdep 'Invalid wait context' warning when called via `kvfree_call_rcu()`.
--
--- Patch [4]: [PATCH slab/for-next v4 4/8] mm/slab: extend deferred free mechanism to handle rcu sheaves ---
commit 136141e9d7cd5370bbb83aa5e26b9b28ea8267ad
Author: Harry Yoo (Oracle) <harry@kernel.org>
mm/slab: extend deferred free mechanism to handle rcu sheaves
This commit extends the deferred free mechanism to handle RCU sheaves when
spinning is not allowed and IRQs are disabled. It queues the RCU sheaf on
an IRQ work to safely invoke call_rcu() later, and updates barrier syncs.
> diff --git a/mm/slub.c b/mm/slub.c
> index 680fe64aff72e..8afa6b47b1f2b 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
[ ... ]
> @@ -6154,8 +6161,22 @@ bool __kfree_rcu_sheaf(struct kmem_cache *s, void *obj, unsigned int free_flags)
> * we flush before local_unlock to make sure a racing
> * flush_all_rcu_sheaves() doesn't miss this sheaf
> */
> - if (rcu_sheaf)
> - call_rcu(&rcu_sheaf->rcu_head, rcu_free_sheaf);
> + if (rcu_sheaf) {
> + /*
> + * With !allow_spin, we might have interrupted call_rcu()'s
> + * IRQ-disabled critical section. If IRQs are not disabled,
> + * we know that's not the case.
> + */
> + if (unlikely(!allow_spin && irqs_disabled())) {
> + struct deferred_percpu_work *dpw;
> +
> + dpw = this_cpu_ptr(&deferred_percpu_work);
> + if (llist_add(&rcu_sheaf->llnode, &dpw->rcu_sheaves))
> + irq_work_queue(&dpw->work);
> + } else {
> + call_rcu(&rcu_sheaf->rcu_head, rcu_free_sheaf);
> + }
> + }
[Severity: High]
This isn't a bug introduced by this patch, but since this modifies
__kfree_rcu_sheaf(), I wanted to ask about a preexisting locking issue in
this execution path.
Earlier in __kfree_rcu_sheaf(), the code unconditionally acquires a lock via
local_trylock(&s->cpu_sheaves->lock). However, this function is reachable from
kvfree_call_rcu(), which can be called under a raw_spinlock_t (like pi_lock)
and from hardirq context:
mm/slab_common.c:kvfree_call_rcu() {
...
if (kfree_rcu_sheaf(ptr))
return;
...
}
which routes to:
mm/slub.c:__kfree_rcu_sheaf() {
...
if (!local_trylock(&s->cpu_sheaves->lock))
goto fail;
...
}
Will acquiring a local_trylock within this wait context trigger a lockdep
"Invalid wait context" warning, since it statically violates the raw
spinlock locking rules?
>
> local_unlock(&s->cpu_sheaves->lock);
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260720-kfree_rcu_nolock-v4-0-964e03c41a4e@kernel.org?part=4
next prev parent reply other threads:[~2026-07-20 13:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 12:44 [PATCH slab/for-next v4 0/8] mm/slab: introduce kfree_rcu_nolock() and improve slub_kunit coverage Harry Yoo (Oracle)
2026-07-20 12:44 ` [PATCH slab/for-next v4 1/8] mm/slab, slub_kunit: register kprobe to trigger _nolock APIs Harry Yoo (Oracle)
2026-07-20 12:56 ` sashiko-bot
2026-07-20 12:44 ` [PATCH slab/for-next v4 2/8] mm/slab: handle the !allow_spin case in kfree_rcu_sheaf() Harry Yoo (Oracle)
2026-07-20 13:11 ` sashiko-bot
2026-07-20 12:44 ` [PATCH slab/for-next v4 3/8] mm/slab: use call_rcu() in unknown context if irqs are enabled Harry Yoo (Oracle)
2026-07-20 13:01 ` sashiko-bot
2026-07-20 12:44 ` [PATCH slab/for-next v4 4/8] mm/slab: extend deferred free mechanism to handle rcu sheaves Harry Yoo (Oracle)
2026-07-20 13:03 ` sashiko-bot [this message]
2026-07-20 12:44 ` [PATCH slab/for-next v4 5/8] mm/slab: allow kfree_rcu_sheaf() on PREEMPT_RT Harry Yoo (Oracle)
2026-07-20 12:56 ` sashiko-bot
2026-07-20 12:44 ` [PATCH slab/for-next v4 6/8] mm/slab: introduce struct kvfree_rcu_head for kvfree_rcu batching Harry Yoo (Oracle)
2026-07-20 13:09 ` sashiko-bot
2026-07-20 12:44 ` [PATCH slab/for-next v4 7/8] mm/slab: introduce kfree_rcu_nolock() Harry Yoo (Oracle)
2026-07-20 13:07 ` sashiko-bot
2026-07-20 12:44 ` [PATCH slab/for-next v4 8/8] slub_kunit: extend the test for kfree_rcu_nolock() Harry Yoo (Oracle)
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=20260720130332.ED34A1F00A3F@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=harry@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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