From: Bradley Morgan <brads@mainlining.org>
To: paulmck@kernel.org, "Paul E. McKenney" <paulmck@kernel.org>
Cc: Zqiang <qiang.zhang@linux.dev>,
boqun@kernel.org, frederic@kernel.org, joelagnelf@nvidia.com,
linux-kernel@vger.kernel.org, neeraj.upadhyay@kernel.org,
rcu@vger.kernel.org, urezki@gmail.com
Subject: Re: [PATCH] rcu-tasks: Warn on too-short RCU Tasks Rude grace period
Date: Sat, 17 Oct 2026 21:08:24 +0100 [thread overview]
Message-ID: <5568467D-34D6-4735-9F01-43B2CB8C207F@mainlining.org> (raw)
In-Reply-To: <82551705-77de-48d3-b310-ba23a5549903@paulmck-laptop>
On 17 October 2026 21:04:37 BST, "Paul E. McKenney" <paulmck@kernel.org>
wrote:
>On Sat, Oct 17, 2026 at 06:49:41PM +0100, Bradley Morgan wrote:
>> On 17 October 2026 18:46:25 BST, "Paul E. McKenney" <paulmck@kernel.org>
>> wrote:
>> >On Sat, Oct 17, 2026 at 12:16:48PM +0100, Bradley Morgan wrote:
>> >> On 17 October 2026 00:41:00 BST, Zqiang <qiang.zhang@linux.dev>
>wrote:
>> >> >>
>> >> >> On 15 October 2026 10:46:19 BST, Zqiang <qiang.zhang@linux.dev>
>> >wrote:
>> >> >>
>> >> >> >
>> >> >> > The RCU Tasks Rude grace period is implemented by invoking the
>> >> >> > schedule_on_each_cpu() with an empty work function, which forces
>> >> >> > a context switch on every online CPU and guarantees that all
>> >> >> > rude-tasks read-side critical sections have completed. However,
>> >> >> > schedule_on_each_cpu() can fail (via alloc_percpu() returning
>> >> >> > -ENOMEM) and returns immediately, in which case those context
>> >> >> > switches never happen, too-short grace period happen.
>> >> >> >
>> >> >> > This commit therefore wraps the schedule_on_each_cpu() call in
>> >> >> > WARN_ONCE() so that this failure is reported as a "Too-short
>> >> >> > grace period" warning.
>> >> >> >
>> >> >> NAK, this seems like a edge case, and potentially panicking the
>> >system
>> >> >> with panic on oops doesn't seem right to me, because we would
>reserve
>> >> >that
>> >> >> for when something definitely goes really wrong and we need to
>notify
>> >> >> the user.
>> >> >>
>> >> >> I don't believe this patch should go in for this reason, it's a
>heavy
>> >> >edge
>> >> >> case, that doesn't *have* nessesarily need to be accounted for.
>> >> >
>> >> >Indeed, this is a rare event, so I use WARN_ONCE() to mark it, the
>> >> >WARN_ONCE()
>> >> >not panicking system unless you set warn_on_oops true, this can help
>us
>> >> >troubleshoot
>> >> >UAF issues caused by a too short tasks-rude grace period.
>> >> >
>> >> >or maybe we can use DEFINE_PER_CPU(struct work_struct, rude_work) to
>> >> >replace
>> >> >alloc_percpu(struct work_struct) queue to all online CPUs.
>> >> >
>> >> >Anyway, Thank you for your reply. I would also like to hear the
>> >opinions
>> >> >of others.
>> >>
>> >> Fair enough, but me and Paul done some discussions:
>> >>
>> >> Here is the TL;DR
>> >>
>> >> My ^W^Wai slop^W^W tool helped me with this: if the too short grace
>> >> happens,
>> >> it falls back.
>> >>
>> >>
>> >> root@p10-linux-brads:~/linux# git diff kernel/rcu
>> >> diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
>> >> index 627295396cd9..65bb7d4ed632 100644
>> >> --- a/kernel/rcu/tasks.h
>> >> +++ b/kernel/rcu/tasks.h
>> >> @@ -1344,15 +1344,23 @@ void exit_tasks_rcu_finish(void) { }
>> >> // Ordering is provided by the scheduler's context-switch code.
>> >>
>> >> // Empty function to allow workqueues to force a context switch.
>> >> -static void rcu_tasks_be_rude(struct work_struct *work)
>> >> +static void __maybe_unused rcu_tasks_be_rude(struct work_struct
>*work)
>> >> {
>> >> }
>> >>
>> >> // Wait for one rude RCU-tasks grace period.
>> >> +static void rcu_tasks_rude_ipi(void *info)
>> >> +{
>> >> +}
>> >> +
>> >> static void rcu_tasks_rude_wait_gp(struct rcu_tasks *rtp)
>> >> {
>> >> + int cpu;
>> >> rtp->n_ipis += cpumask_weight(cpu_online_mask);
>> >> - schedule_on_each_cpu(rcu_tasks_be_rude);
>> >> + cpus_read_lock();
>> >> + for_each_online_cpu(cpu)
>> >> + smp_call_function_single(cpu, rcu_tasks_rude_ipi,
>NULL,
>> >1);
>> >> + cpus_read_unlock();
>> >> }
>> >>
>> >> static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t
>> >func);
>> >> root@p10-linux-brads:~/linux#
>> >>
>> >> On POWERPC, this passes 12 hours of rcutorture on the RUDE01 config.
>> >
>> >That is surprising, given that when I run your patch shown above on my
>> >x86 laptop, rcutorture reports a too-short grace period within 20
>seconds.
>>
>> Odd! I definitely ran it for 12 hours, on PowerPC, so this is certainly
>odd
>
>Those who care are free run it themselves on the systems of their choice.
root@p10-linux-brads:~/linux/tools/testing/selftests/rcutorture/res/2026.10.15-19.45.43/RUDE01#
uname -a && uname
Linux p10-linux-brads 7.0.0-34-generic #34-Ubuntu SMP PREEMPT_DYNAMIC Wed
Sep 2 16:05:10 UTC 2026 ppc64le GNU/Linux
Linux
root@p10-linux-brads:~/linux/tools/testing/selftests/rcutorture/res/2026.10.15-19.45.43/RUDE01#
tail -n 20 console.log
[43269.029077][ T73] tasks-rude-torture: rcu_torture_read_exit: Start of
episode
[43269.033954][ T73] tasks-rude-torture: rcu_torture_read_exit: End of
episode
[43282.341070][ T73] tasks-rude-torture: rcu_torture_read_exit: Start of
episode
[43282.345268][ T73] tasks-rude-torture: rcu_torture_read_exit: End of
episode
[43295.653087][ T73] tasks-rude-torture: rcu_torture_read_exit: Start of
episode
[43295.657260][ T73] tasks-rude-torture: rcu_torture_read_exit: End of
episode
[43308.965081][ T73] tasks-rude-torture: rcu_torture_read_exit: Start of
episode
[43308.969151][ T73] tasks-rude-torture: rcu_torture_read_exit: End of
episode
[43322.277071][ T73] tasks-rude-torture: rcu_torture_read_exit: Start of
episode
[43322.281345][ T73] tasks-rude-torture: rcu_torture_read_exit: End of
episode
[43335.589160][ T73] tasks-rude-torture: rcu_torture_read_exit: Start of
episode
[43335.593159][ T73] tasks-rude-torture: rcu_torture_read_exit: End of
episode
[43348.901077][ T73] tasks-rude-torture: rcu_torture_read_exit: Start of
episode
[43348.905165][ T73] tasks-rude-torture: rcu_torture_read_exit: End of
episode
[43362.213069][ T73] tasks-rude-torture: rcu_torture_read_exit: Start of
episode
[43362.217298][ T73] tasks-rude-torture: rcu_torture_read_exit: End of
episode
[43375.525085][ T73] tasks-rude-torture: rcu_torture_read_exit: Start of
episode
[43375.529207][ T73] tasks-rude-torture: rcu_torture_read_exit: End of
episode
[43388.837074][ T73] tasks-rude-torture: rcu_torture_read_exit: Start of
episode
[43388.841160][ T73] tasks-rude-torture: rcu_torture_read_exit: End of
episode
root@p10-linux-brads:~/linux/tools/testing/selftests/rcutorture/res/2026.10.15-19.45.43/RUDE01#
I certainly ran it :(
>
> Thanx, Paul
>
>> >> If you plan on submitting this into a patch, please add my
>authorship,
>> >or
>> >> my c-d-b.
>> >>
>> >> Feel free to rcutorture test it ;d
>> >>
>> >> BTW: have you reproduced this on your own system?
>> >>
>> >> >
>> >> >Thanks
>> >> >Zqiang
>> >> >
>> >> >
>> >> >>
>> >> >> Zqiang, have you reproduced this OOM on your own system, if so,
>could
>> >> >you
>> >> >> tell me more details, you may turn my frown into a smiley face ;)
>> >> >>
>> >> >> >
>> >> >> > Signed-off-by: Zqiang <qiang.zhang@linux.dev>
>> >> >> > ---
>> >> >> > kernel/rcu/tasks.h | 3 ++-
>> >> >> > 1 file changed, 2 insertions(+), 1 deletion(-)
>> >> >> >
>> >> >> > diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
>> >> >> > index fcac7361ec51..91c25717402e 100644
>> >> >> > --- a/kernel/rcu/tasks.h
>> >> >> > +++ b/kernel/rcu/tasks.h
>> >> >> > @@ -1361,7 +1361,8 @@ static void rcu_tasks_be_rude(struct
>> >work_struct
>> >> >*work)
>> >> >> > static void rcu_tasks_rude_wait_gp(struct rcu_tasks *rtp)
>> >> >> > {
>> >> >> > rtp->n_ipis += cpumask_weight(cpu_online_mask);
>> >> >> > - schedule_on_each_cpu(rcu_tasks_be_rude);
>> >> >> > + WARN_ONCE(schedule_on_each_cpu(rcu_tasks_be_rude),
>> >> >> > + "%s: Too-short grace period, OOM is now expected
>behavior!!!\n",
>> >> >rtp->name);
>> >> >> >
>> >> >> Good message, makes sense. But I don't think this is right, see
>> >above.
>> >> >>
>> >> >> >
>> >> >> > }
>> >> >> >
>> >> >> > static void call_rcu_tasks_rude(struct rcu_head *rhp,
>> >rcu_callback_t
>> >> >> > func);
>> >> >> >
>> >> >> --- Thanks!
>> >> >> "I'm not a very positive person" - Linus torvalds
>> >> >>
>> >>
>> >> --- Thanks!
>> >> "I'm not a very positive person" - Linus torvalds
>>
>> --- Thanks!
>> "I'm not a very positive person" - Linus torvalds
--- Thanks!
"I'm not a very positive person" - Linus torvalds
next prev parent reply other threads:[~2026-10-17 20:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 9:46 Zqiang
2026-10-15 16:31 ` Bradley Morgan
2026-10-16 23:41 ` Zqiang
2026-10-17 11:16 ` Bradley Morgan
2026-10-17 12:14 ` Zqiang
2026-10-17 12:20 ` Bradley Morgan
2026-10-17 12:25 ` Bradley Morgan
2026-10-17 13:37 ` Zqiang
2026-10-17 14:08 ` Bradley Morgan
2026-10-17 17:46 ` Paul E. McKenney
2026-10-17 17:49 ` Bradley Morgan
2026-10-17 20:04 ` Paul E. McKenney
2026-10-17 20:08 ` Bradley Morgan [this message]
2026-10-17 15:02 ` Joel Fernandes
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=5568467D-34D6-4735-9F01-43B2CB8C207F@mainlining.org \
--to=brads@mainlining.org \
--cc=boqun@kernel.org \
--cc=frederic@kernel.org \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=qiang.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=urezki@gmail.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
all inboxes | Powered by JetHome®