From: sashiko-bot@kernel.org
To: "Shakeel Butt" <shakeel.butt@linux.dev>,
"Dennis Zhou" <dennis@kernel.org>, "Tejun Heo" <tj@kernel.org>,
"Christoph Lameter" <cl@gentwo.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Hocko" <mhocko@kernel.org>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"Muchun Song" <muchun.song@linux.dev>,
"Alexei Starovoitov" <ast@kernel.org>,
"David Vernet" <void@manifault.com>,
"Vlastimil Babka" <vbabka@kernel.org>,
linux-mm@kvack.org, bpf@vger.kernel.org,
"Meta kernel team" <kernel-team@meta.com>,
mkoutny@suse.com
Subject: Re: [PATCH 2/2] percpu_ref: defer the release function when the last put is in NMI
Date: Fri, 04 Dec 2026 23:00:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-250791@kernel.org> (raw)
In-Reply-To: <20261204224016.325944-3-shakeel.butt@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] percpu_ref: percpu_ref_resurrect() doc misstates deferred NMI
release rule
--
commit b7ced7ae84eee24dc735178694ab43386fd34329
Author: Shakeel Butt <shakeel.butt@linux.dev>
percpu_ref: defer the release function when the last put is in NMI
When a percpu_ref count drops to zero in NMI context, this commit queues the
ref on a per-CPU llist and defers invoking its release callback to irq_work,
reusing the rcu_head storage in struct percpu_ref_data for the list node.
> diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
> index 5def04e3a2c34..b12cc1568d293 100644
> --- a/lib/percpu-refcount.c
> +++ b/lib/percpu-refcount.c
[ ... ]
> @@ -498,7 +504,8 @@ EXPORT_SYMBOL_GPL(percpu_ref_reinit);
> *
> * If @ref->release() frees @ref then the caller is responsible for
> * guaranteeing that @ref->release() does not get called while this
> - * function is in progress.
> + * function is in progress. That includes a release that
> + * percpu_ref_put_many() deferred from NMI.
> *
> * Note that percpu_ref_tryget[_live]() are safe to perform on @ref while
> * this function is in progress.
[Severity: Low]
Should the NMI deferred release requirement here be unconditional rather than
tied to "If @ref->release() frees @ref"?
Even when release() does not free @ref, resurrecting it before
percpu_ref_nmi_release_fn() runs leaves data->nmi_release_node linked on the
per-CPU percpu_ref_nmi_release.refs list while the ref is live again. A
subsequent switch to atomic mode can then pass &ref->data->rcu to
call_rcu_hurry(), overwriting the aliased union member and corrupting the
per-CPU list.
Stating unconditionally that callers capable of dropping the last reference
in NMI must wait for the release function before calling
percpu_ref_resurrect() would match percpu_ref_put_many() and
percpu_ref_reinit().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204224016.325944-1-shakeel.butt@linux.dev?part=2
prev parent reply other threads:[~2026-12-04 23:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 22:40 [PATCH 0/2] percpu_ref: make gets, puts and releases NMI safe Shakeel Butt
2026-12-04 22:40 ` [PATCH 1/2] percpu_ref: make get and put NMI safe where this_cpu ops are not Shakeel Butt
2026-12-04 22:40 ` [PATCH 2/2] percpu_ref: defer the release function when the last put is in NMI Shakeel Butt
2026-12-04 23:00 ` sashiko-bot [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=sashiko-outbox-250791@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cl@gentwo.org \
--cc=dennis@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=tj@kernel.org \
--cc=vbabka@kernel.org \
--cc=void@manifault.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox