Skip to contentSkip to conversation

rcu-tasks: Warn on too-short RCU Tasks Rude grace period

PATCH NAK Zqiang 4 participants 16 messages Oct 15 – Oct 19 RCU

lore
Share & tools
lore

Zqiang

author reviewer
#0 lore raw

PATCH 1/1 rcu-tasks: Warn on too-short RCU Tasks Rude grace period

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.

---
 kernel/rcu/tasks.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tasks.h +2 -1
index fcac7361ec51..91c25717402e 100644
@@ -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);
 }
 
 static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 11 lines · Zqiang

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.

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 ;)

Quoted 11 lines

---
kernel/rcu/tasks.h | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct *work) · line 1365

Quoted 6 lines
kernel/rcu/tasks.h +2 -1
@@ -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.

Quoted 5 lines
kernel/rcu/tasks.h +0 -0
 }
 

static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func);

--- Thanks!
"I'm not a very positive person" - Linus torvalds

author reviewer
#2 lore raw
Quoted 16 lines · Zqiang
Quoted 10 lines

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.

Quoted 4 lines

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.

Quoted 7 lines

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.

Thanks
Zqiang

Quoted 33 lines

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 ;)

Quoted 11 lines
---
 kernel/rcu/tasks.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct *work) · line 1366

Quoted 7 lines
kernel/rcu/tasks.h +2 -1
@@ -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.

Quoted 6 lines
kernel/rcu/tasks.h +0 -0
 }
 

static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func);

--- Thanks!
"I'm not a very positive person" - Linus torvalds

#3 lore raw
Quoted 32 lines · Zqiang
Quoted 12 lines · Zqiang
Quoted 10 lines

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.

Quoted 6 lines
Quoted 4 lines

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

Quoted 4 lines

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

Quoted 1 line

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.

Quoted 6 lines

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
kernel/rcu/tasks.h +10 -2
index 627295396cd9..65bb7d4ed632 100644
@@ -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.

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?

Quoted 22 lines

Thanks
Zqiang

Quoted 2 lines

Zqiang, have you reproduced this OOM on your own system, if so, could

you

Quoted 8 lines

tell me more details, you may turn my frown into a smiley face ;)

Quoted 6 lines
---
 kernel/rcu/tasks.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 5 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct

Quoted 5 lines
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644
@@ -1361,7 +1361,8 @@ static void rcu_tasks_be_rude(struct work_struct

*work)

Quoted 19 lines
Quoted 6 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct · line 1365

Quoted 6 lines
kernel/rcu/tasks.h +2 -1
 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);

Quoted 12 lines
Quoted 1 line

Good message, makes sense. But I don't think this is right, see above.

Quoted 6 lines

}

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

author reviewer
#4 lore raw
Quoted 76 lines · Zqiang
Quoted 40 lines
Quoted 14 lines · Zqiang
Quoted 10 lines

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.

Quoted 7 lines
Quoted 4 lines

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

Quoted 6 lines

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

Quoted 3 lines

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.

Quoted 7 lines

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# mailto:root@p10-linux-brads:~/linux#  git diff kernel/rcu
kernel/rcu/tasks.h +5 -1
index 627295396cd9..65bb7d4ed632 100644
@@ -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)
+{
+}
+

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { } · line 1364

Quoted 10 lines
kernel/rcu/tasks.h +5 -1
 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();
 }

RCU Tasks Rude use preempt_disable/enable as the read critical section, you use smp_call_function_single() to send ipi to each online CPUs, it's not forces a context sched switch, and not wait the preempt_disable/enable read critical section to exit, this is the wrong mechanism. ;-(

Obviously, we only need to not apply alloc_percpu dynamic allocation:

kernel/rcu/tasks.h +15 -1
index fcac7361ec51..49b629b0010b 100644
@@ -1357,11 +1357,25 @@ static void rcu_tasks_be_rude(struct work_struct *work)
 {
 }
 
+static DEFINE_PER_CPU(struct work_struct, tasks_rude_work);
+
 // Wait for one rude RCU-tasks grace period.
 static void rcu_tasks_rude_wait_gp(struct rcu_tasks *rtp)
 {
+       int cpu;
+
+       guard(cpus_read_lock)();
        rtp->n_ipis += cpumask_weight(cpu_online_mask);
-       schedule_on_each_cpu(rcu_tasks_be_rude);
+
+       for_each_online_cpu(cpu) {
+               struct work_struct *work = &per_cpu(tasks_rude_work, cpu);
+
+               INIT_WORK(work, rcu_tasks_be_rude);
+               schedule_work_on(cpu, work);
+       }
+
+       for_each_online_cpu(cpu)
+               flush_work(&per_cpu(tasks_rude_work, cpu));
 }
 
 static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func);

Thanks
Zqiang

Quoted 66 lines
kernel/rcu/tasks.h +0 -0
 static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func);
root@p10-linux-brads:~/linux# mailto:root@p10-linux-brads:~/linux# 

On POWERPC, this passes 12 hours of rcutorture on the RUDE01 config.

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?

Quoted 27 lines

Thanks
Zqiang

Quoted 3 lines

Zqiang, have you reproduced this OOM on your own system, if so, could

you

Quoted 9 lines

tell me more details, you may turn my frown into a smiley face ;)

Quoted 6 lines

---
kernel/rcu/tasks.h | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 6 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct

Quoted 5 lines
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644
@@ -1361,7 +1361,8 @@ static void rcu_tasks_be_rude(struct work_struct

*work)

Quoted 1 line
Quoted 23 lines
Quoted 7 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct · line 1365

Quoted 6 lines
kernel/rcu/tasks.h +2 -1
 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);

Quoted 13 lines
Quoted 2 lines

Good message, makes sense. But I don't think this is right, see above.

Quoted 6 lines

}

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

Reviewed-by
#5 lore raw
Quoted 133 lines · Zqiang
Quoted 6 lines · Zqiang
Quoted 4 lines
Quoted 4 lines

On 15 October 2026 10:46:19 BST, Zqiang <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

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.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line

with panic on oops doesn't seem right to me, because we would

reserve

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

that

Quoted 2 lines

for when something definitely goes really wrong and we need to

notify

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the user.

I don't believe this patch should go in for this reason, it's a

heavy

Quoted 9 lines
Quoted 9 lines
Quoted 1 line

edge

Quoted 3 lines

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

Quoted 8 lines
Quoted 8 lines

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

Quoted 11 lines
Quoted 2 lines

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# mailto:root@p10-linux-brads:~/linux#  git

diff kernel/rcu

Quoted 18 lines
kernel/rcu/tasks.h +5 -1
index 627295396cd9..65bb7d4ed632 100644
@@ -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)
+{
+}
+

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { } · line 1364

Quoted 10 lines
kernel/rcu/tasks.h +5 -1
 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();
 }

RCU Tasks Rude use preempt_disable/enable as the read critical section, you use smp_call_function_single() to send ipi to each online CPUs, it's not forces a context sched switch, and not wait the preempt_disable/enable
read critical section to exit, this is the wrong mechanism. ;-(

Obviously, we only need to not apply alloc_percpu dynamic allocation:

kernel/rcu/tasks.h +15 -1
index fcac7361ec51..49b629b0010b 100644
@@ -1357,11 +1357,25 @@ static void rcu_tasks_be_rude(struct work_struct *work)
 {
 }
 
+static DEFINE_PER_CPU(struct work_struct, tasks_rude_work);
+
 // Wait for one rude RCU-tasks grace period.
 static void rcu_tasks_rude_wait_gp(struct rcu_tasks *rtp)
 {
+       int cpu;
+
+       guard(cpus_read_lock)();
       rtp->n_ipis += cpumask_weight(cpu_online_mask);
-       schedule_on_each_cpu(rcu_tasks_be_rude);
+
+       for_each_online_cpu(cpu) {
+               struct work_struct *work = &per_cpu(tasks_rude_work, cpu);
+
+               INIT_WORK(work, rcu_tasks_be_rude);
+               schedule_work_on(cpu, work);
+       }
+
+       for_each_online_cpu(cpu)
+               flush_work(&per_cpu(tasks_rude_work, cpu));
 }
 
Quoted 3 lines

static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func);

Wow!

Quoted 62 lines

Thanks
Zqiang

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { } · line 1365

Quoted 2 lines
kernel/rcu/tasks.h +0 -0
 static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t

func);

Quoted 5 lines
root@p10-linux-brads:~/linux# mailto:root@p10-linux-brads:~/linux# 

On POWERPC, this passes 12 hours of rcutorture on the RUDE01 config.

If you plan on submitting this into a patch, please add my authorship,

or

Quoted 12 lines

my c-d-b.

Feel free to rcutorture test it ;d

BTW: have you reproduced this on your own system?

Quoted 6 lines

Thanks
Zqiang

Quoted 2 lines

Zqiang, have you reproduced this OOM on your own system, if so,

could

Quoted 12 lines
Quoted 12 lines
Quoted 1 line

you

Quoted 9 lines

tell me more details, you may turn my frown into a smiley face ;)

Quoted 6 lines

---
kernel/rcu/tasks.h | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct

Quoted 5 lines
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644
@@ -1361,7 +1361,8 @@ static void rcu_tasks_be_rude(struct

work_struct

Quoted 10 lines
Quoted 10 lines
Quoted 1 line

*work)

Quoted 7 lines
Quoted 7 lines
kernel/rcu/tasks.h +2 -1
 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",

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

rtp->name);

Quoted 2 lines
Quoted 2 lines
Quoted 17 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Good message, makes sense. But I don't think this is right, see

above.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

}

static void call_rcu_tasks_rude(struct rcu_head *rhp,

rcu_callback_t

Quoted 9 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

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

#6 lore raw
Quoted 136 lines · Bradley Morgan

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct

Quoted 108 lines · Zqiang
Quoted 6 lines · Zqiang
Quoted 4 lines
Quoted 4 lines

On 15 October 2026 10:46:19 BST, Zqiang <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

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.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line

with panic on oops doesn't seem right to me, because we would

reserve

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

that

Quoted 2 lines

for when something definitely goes really wrong and we need to

notify

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the user.

I don't believe this patch should go in for this reason, it's a

heavy

Quoted 9 lines
Quoted 9 lines
Quoted 1 line

edge

Quoted 3 lines

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

Quoted 8 lines
Quoted 8 lines

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

Quoted 11 lines
Quoted 2 lines

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# mailto:root@p10-linux-brads:~/linux#  git

diff kernel/rcu

Quoted 18 lines
kernel/rcu/tasks.h +5 -1
index 627295396cd9..65bb7d4ed632 100644
@@ -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)
+{
+}
+

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { } · line 1364

Quoted 10 lines
kernel/rcu/tasks.h +5 -1
 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();
 }

RCU Tasks Rude use preempt_disable/enable as the read critical section, you use smp_call_function_single() to send ipi to each online CPUs, it's not forces a context sched switch, and not wait the preempt_disable/enable
read critical section to exit, this is the wrong mechanism. ;-(

Obviously, we only need to not apply alloc_percpu dynamic allocation:

kernel/rcu/tasks.h +0 -0
index fcac7361ec51..49b629b0010b 100644
@@ -1357,11 +1357,25 @@ static void rcu_tasks_be_rude(struct work_struct

*work)

Quoted 6 lines
kernel/rcu/tasks.h +2 -0
 {
 }
 
+static DEFINE_PER_CPU(struct work_struct, tasks_rude_work);
+
 // Wait for one rude RCU-tasks grace period.

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct *work)

Quoted 10 lines
kernel/rcu/tasks.h +6 -1
 static void rcu_tasks_rude_wait_gp(struct rcu_tasks *rtp)
 {
+       int cpu;
+
+       guard(cpus_read_lock)();
       rtp->n_ipis += cpumask_weight(cpu_online_mask);
-       schedule_on_each_cpu(rcu_tasks_be_rude);
+
+       for_each_online_cpu(cpu) {
+               struct work_struct *work = &per_cpu(tasks_rude_work,

cpu);

Quoted 9 lines
kernel/rcu/tasks.h +7 -0
+
+               INIT_WORK(work, rcu_tasks_be_rude);
+               schedule_work_on(cpu, work);
+       }
+
+       for_each_online_cpu(cpu)
+               flush_work(&per_cpu(tasks_rude_work, cpu));
 }
 
Quoted 7 lines
Quoted 3 lines

static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func);

Wow!

Gimme a sec I'll submit the patch..

Quoted 77 lines
Quoted 77 lines

Thanks
Zqiang

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { } · line 1365

Quoted 2 lines
kernel/rcu/tasks.h +0 -0
 static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t

func);

Quoted 5 lines
root@p10-linux-brads:~/linux# mailto:root@p10-linux-brads:~/linux# 

On POWERPC, this passes 12 hours of rcutorture on the RUDE01 config.

If you plan on submitting this into a patch, please add my authorship,

or

Quoted 12 lines

my c-d-b.

Feel free to rcutorture test it ;d

BTW: have you reproduced this on your own system?

Quoted 6 lines

Thanks
Zqiang

Quoted 2 lines

Zqiang, have you reproduced this OOM on your own system, if so,

could

Quoted 12 lines
Quoted 12 lines
Quoted 1 line

you

Quoted 9 lines

tell me more details, you may turn my frown into a smiley face ;)

Quoted 6 lines

---
kernel/rcu/tasks.h | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct

Quoted 5 lines
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644
@@ -1361,7 +1361,8 @@ static void rcu_tasks_be_rude(struct

work_struct

Quoted 10 lines
Quoted 10 lines
Quoted 1 line

*work)

Quoted 7 lines
Quoted 7 lines
kernel/rcu/tasks.h +2 -1
 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",

Quoted 6 lines
Quoted 6 lines
Quoted 1 line

rtp->name);

Quoted 3 lines
Quoted 2 lines

Good message, makes sense. But I don't think this is right, see

above.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

}

static void call_rcu_tasks_rude(struct rcu_head *rhp,

rcu_callback_t

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

func);

--- Thanks!
"I'm not a very positive person" - Linus torvalds

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

--- 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

author reviewer
#7 lore raw
Quoted 172 lines
Quoted 168 lines · Bradley Morgan

On 17 October 2026 13:14:29 BST, Zqiang <[email protected]> wrote:

Quoted 67 lines · Zqiang
Quoted 3 lines

On 15 October 2026 10:46:19 BST, Zqiang <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines

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.

Quoted 5 lines
Quoted 4 lines

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

Quoted 1 line

with panic on oops doesn't seem right to me, because we would

reserve

Quoted 1 line

that

Quoted 2 lines

for when something definitely goes really wrong and we need to

notify

Quoted 3 lines

the user.

I don't believe this patch should go in for this reason, it's a

heavy

Quoted 1 line

edge

Quoted 3 lines

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.

Quoted 7 lines

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# mailto:root@p10-linux-brads:~/linux#  mailto:root@p10-linux-brads:~/linux# git
Quoted 3 lines

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();
}

Quoted 14 lines

RCU Tasks Rude use preempt_disable/enable as the read critical section, you use smp_call_function_single() to send ipi to each online CPUs, it's not forces a context sched switch, and not wait the preempt_disable/enable
read critical section to exit, this is the wrong mechanism. ;-(

Obviously, we only need to not apply alloc_percpu dynamic allocation:

kernel/rcu/tasks.h +0 -0
index fcac7361ec51..49b629b0010b 100644

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct · line 1357

Quoted 1 line
kernel/rcu/tasks.h +0 -0
@@ -1357,11 +1357,25 @@ static void rcu_tasks_be_rude(struct work_struct
 

*work)

Quoted 8 lines
kernel/rcu/tasks.h +2 -0
 {
 }
 
+static DEFINE_PER_CPU(struct work_struct, tasks_rude_work);
+
 // Wait for one rude RCU-tasks grace period.
 static void rcu_tasks_rude_wait_gp(struct rcu_tasks *rtp)

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct *work) · line 1380

Quoted 10 lines
kernel/rcu/tasks.h +6 -1
 {
+ int cpu;
+
+ guard(cpus_read_lock)();
 rtp->n_ipis += cpumask_weight(cpu_online_mask);
- schedule_on_each_cpu(rcu_tasks_be_rude);
+
+ for_each_online_cpu(cpu) {
+ struct work_struct *work = &per_cpu(tasks_rude_work,
 

cpu);

Quoted 10 lines
kernel/rcu/tasks.h +7 -0
+
+ INIT_WORK(work, rcu_tasks_be_rude);
+ schedule_work_on(cpu, work);
+ }
+
+ for_each_online_cpu(cpu)
+ flush_work(&per_cpu(tasks_rude_work, cpu));
 }
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func);

Wow!

Gimme a sec I'll submit the patch..

Actually, I don't mind you send this fix directly, due to you use an incorrect IPI mechanism to implement it, I would like to know wether you truly understand the tasks-rude and how schedule_on_each_cpu() ensures memory order.

Quoted 106 lines
Quoted 97 lines
Quoted 6 lines

Thanks
Zqiang

static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t

Quoted 3 lines

func);

 root@p10-linux-brads:~/linux# mailto:root@p10-linux-brads:~/linux#  mailto:root@p10-linux-brads:~/linux# 

On POWERPC, this passes 12 hours of rcutorture on the RUDE01 config.

If you plan on submitting this into a patch, please add my authorship,

Quoted 3 lines

or

my c-d-b.

Feel free to rcutorture test it ;d

BTW: have you reproduced this on your own system?

Quoted 57 lines

Thanks
Zqiang

Quoted 2 lines

Zqiang, have you reproduced this OOM on your own system, if so,

could

Quoted 1 line

you

Quoted 9 lines

tell me more details, you may turn my frown into a smiley face ;)

Quoted 6 lines

---
kernel/rcu/tasks.h | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 5 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct

Quoted 5 lines
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644
@@ -1361,7 +1361,8 @@ static void rcu_tasks_be_rude(struct

work_struct

Quoted 1 line

*work)

Quoted 7 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct *work)

Quoted 7 lines
kernel/rcu/tasks.h +2 -1
 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",

Quoted 1 line

rtp->name);

Quoted 3 lines
Quoted 2 lines

Good message, makes sense. But I don't think this is right, see

above.

Quoted 2 lines
Quoted 2 lines
Quoted 13 lines
Quoted 3 lines
Quoted 3 lines

}

static void call_rcu_tasks_rude(struct rcu_head *rhp,

rcu_callback_t

Quoted 5 lines
Quoted 2 lines

func);

--- Thanks!
"I'm not a very positive person" - Linus torvalds

Quoted 6 lines

--- 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

#8 lore raw
Quoted 189 lines · Zqiang
Quoted 8 lines
Quoted 4 lines · Bradley Morgan

On 17 October 2026 13:14:29 BST, Zqiang <[email protected]> wrote:

On 17 October 2026 00:41:00 BST, Zqiang <[email protected]>

Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

On 15 October 2026 10:46:19 BST, Zqiang <[email protected]>

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines · wrote:
Quoted 4 lines

The RCU Tasks Rude grace period is implemented by invoking the schedule_on_each_cpu() with an empty work function, which

forces

Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 11 lines
Quoted 10 lines

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

Quoted 1 line

with panic on oops doesn't seem right to me, because we would

reserve

Quoted 1 line

that

Quoted 2 lines

for when something definitely goes really wrong and we need to

notify

Quoted 3 lines

the user.

I don't believe this patch should go in for this reason, it's a

heavy

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

edge

Quoted 3 lines

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

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 12 lines
Quoted 12 lines
Quoted 10 lines

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:

Quoted 7 lines
Quoted 7 lines

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# mailto:root@p10-linux-brads:~/linux# 
mailto:root@p10-linux-brads:~/linux# git
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines

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.

Quoted 3 lines
Quoted 3 lines

// 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)

Quoted 20 lines
Quoted 20 lines

{
}

// 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();
}

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

RCU Tasks Rude use preempt_disable/enable as the read critical

section,

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

you use smp_call_function_single() to send ipi to each online CPUs, it's not forces a context sched switch, and not wait the preempt_disable/enable
read critical section to exit, this is the wrong mechanism. ;-(

Obviously, we only need to not apply alloc_percpu dynamic

allocation:

Quoted 6 lines
Quoted 6 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct

Quoted 6 lines
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..49b629b0010b 100644
@@ -1357,11 +1357,25 @@ static void rcu_tasks_be_rude(struct

work_struct

Quoted 33 lines
Quoted 33 lines
Quoted 1 line

*work)

Quoted 8 lines

{
}

kernel/rcu/tasks.h +2 -0
+static DEFINE_PER_CPU(struct work_struct, tasks_rude_work);
+
 // Wait for one rude RCU-tasks grace period.

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct *work)

Quoted 10 lines
kernel/rcu/tasks.h +6 -1
 static void rcu_tasks_rude_wait_gp(struct rcu_tasks *rtp)
 {
+ int cpu;
+
+ guard(cpus_read_lock)();
 rtp->n_ipis += cpumask_weight(cpu_online_mask);
- schedule_on_each_cpu(rcu_tasks_be_rude);
+
+ for_each_online_cpu(cpu) {
+ struct work_struct *work = &per_cpu(tasks_rude_work,

cpu);

Quoted 10 lines
kernel/rcu/tasks.h +7 -0
+
+ INIT_WORK(work, rcu_tasks_be_rude);
+ schedule_work_on(cpu, work);
+ }
+
+ for_each_online_cpu(cpu)
+ flush_work(&per_cpu(tasks_rude_work, cpu));
 }
Quoted 1 line
Quoted 1 line
Quoted 1 line

static void call_rcu_tasks_rude(struct rcu_head *rhp,

rcu_callback_t

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

func);

Wow!

Quoted 7 lines
Quoted 1 line

Gimme a sec I'll submit the patch..

Actually, I don't mind you send this fix directly, due to you use an incorrect IPI
mechanism to implement it, I would like to know wether you truly understand the tasks-rude
and how schedule_on_each_cpu() ensures memory order.

Hi, I do understand how it all works.

The reasons why you would suspect I wouldn't

1: I used a ai slop tool to suggest *my* fix, and I tested it on rcutorture 2: I'm sometimes a bit dumb, it happens :(

You said you "don't mind", does that mean you DONT want your fix submitted (but I already submitted it ;c), or that you are okay with your fix being sent.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 8 lines

Thanks
Zqiang

static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t

Quoted 3 lines

func);

Quoted 96 lines
Quoted 1 line
Quoted 1 line
 root@p10-linux-brads:~/linux# mailto:root@p10-linux-brads:~/linux# 

mailto:root@p10-linux-brads:~/linux#

Quoted 4 lines
Quoted 4 lines

On POWERPC, this passes 12 hours of rcutorture on the RUDE01 config.

If you plan on submitting this into a patch, please add my

authorship,

Quoted 89 lines
Quoted 80 lines
Quoted 4 lines

or

my c-d-b.

Feel free to rcutorture test it ;d

BTW: have you reproduced this on your own system?

Quoted 57 lines

Thanks
Zqiang

Quoted 2 lines

Zqiang, have you reproduced this OOM on your own system, if so,

could

Quoted 1 line

you

Quoted 9 lines

tell me more details, you may turn my frown into a smiley face ;)

Quoted 6 lines

---
kernel/rcu/tasks.h | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 5 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct

Quoted 5 lines
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644
@@ -1361,7 +1361,8 @@ static void rcu_tasks_be_rude(struct

work_struct

Quoted 1 line

*work)

Quoted 7 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct *work)

Quoted 7 lines
kernel/rcu/tasks.h +2 -1
 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",

Quoted 1 line

rtp->name);

Quoted 3 lines
Quoted 2 lines

Good message, makes sense. But I don't think this is right, see

above.

Quoted 2 lines
Quoted 2 lines
Quoted 13 lines
Quoted 3 lines
Quoted 3 lines

}

static void call_rcu_tasks_rude(struct rcu_head *rhp,

rcu_callback_t

Quoted 5 lines
Quoted 2 lines

func);

--- Thanks!
"I'm not a very positive person" - Linus torvalds

Quoted 6 lines

--- 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!
https://lore.kernel.org/all/[email protected]/

maintainer
#13 lore raw
In reply to Zqiang
Quoted 26 lines · Zqiang

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.

---
kernel/rcu/tasks.h | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct *work) · line 1365

Quoted 6 lines
kernel/rcu/tasks.h +2 -1
@@ -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);

Is that the best error message? OOM is expected when grace periods do not conclude.

Thanks.

Quoted 6 lines
kernel/rcu/tasks.h +0 -1
 }
 
 static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func);
--

2.17.1

maintainer
#9 lore raw
In reply to Bradley Morgan
Quoted 82 lines · Bradley Morgan
Quoted 32 lines · Zqiang
Quoted 12 lines · Zqiang
Quoted 10 lines

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.

Quoted 6 lines
Quoted 4 lines

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

Quoted 4 lines

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

Quoted 1 line

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.

Quoted 6 lines

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
kernel/rcu/tasks.h +10 -2
index 627295396cd9..65bb7d4ed632 100644
@@ -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#

Quoted 1 line

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.

Thanx, Paul

Quoted 51 lines

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?

Quoted 22 lines

Thanks
Zqiang

Quoted 2 lines

Zqiang, have you reproduced this OOM on your own system, if so, could

you

Quoted 8 lines

tell me more details, you may turn my frown into a smiley face ;)

Quoted 6 lines
---
 kernel/rcu/tasks.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 5 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct work_struct

Quoted 5 lines
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644
@@ -1361,7 +1361,8 @@ static void rcu_tasks_be_rude(struct work_struct

*work)

Quoted 19 lines
Quoted 6 lines

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { }

Quoted 6 lines
kernel/rcu/tasks.h +2 -1
 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);

Quoted 12 lines
Quoted 1 line

Good message, makes sense. But I don't think this is right, see above.

Quoted 6 lines

}

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

#10 lore raw
Quoted 84 lines · Paul E. McKenney
Quoted 3 lines · Bradley Morgan
Quoted 2 lines · Zqiang
Quoted 2 lines

On 15 October 2026 10:46:19 BST, Zqiang <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

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.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

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

Quoted 15 lines
Quoted 15 lines
Quoted 1 line

with panic on oops doesn't seem right to me, because we would reserve

that

Quoted 4 lines

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

Quoted 1 line

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.

Quoted 5 lines
Quoted 5 lines

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

Quoted 28 lines
Quoted 1 line

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
kernel/rcu/tasks.h +3 -1
index 627295396cd9..65bb7d4ed632 100644
@@ -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)
+{

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { } · line 1362

Quoted 10 lines
kernel/rcu/tasks.h +6 -1
+}
+
 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);

Quoted 3 lines
kernel/rcu/tasks.h +1 -0
+       cpus_read_unlock();
 }
 
Quoted 8 lines

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { } · line 1366

Quoted 1 line
kernel/rcu/tasks.h +0 -0
 static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t

func);

Quoted 3 lines

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

Quoted 42 lines

Thanx, Paul

Quoted 1 line

If you plan on submitting this into a patch, please add my authorship,

or

Quoted 22 lines

my c-d-b.

Feel free to rcutorture test it ;d

BTW: have you reproduced this on your own system?

Quoted 16 lines

Thanks
Zqiang

Quoted 2 lines

Zqiang, have you reproduced this OOM on your own system, if so, could

you

Quoted 8 lines

tell me more details, you may turn my frown into a smiley face ;)

Quoted 6 lines
---
 kernel/rcu/tasks.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct

Quoted 5 lines
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644
@@ -1361,7 +1361,8 @@ static void rcu_tasks_be_rude(struct

work_struct

Quoted 9 lines
Quoted 9 lines

*work)

Quoted 6 lines

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { }

Quoted 6 lines
kernel/rcu/tasks.h +2 -1
 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);

Quoted 1 line
Quoted 1 line
Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Good message, makes sense. But I don't think this is right, see

above.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

}

static void call_rcu_tasks_rude(struct rcu_head *rhp,

rcu_callback_t

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

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

maintainer
#11 lore raw
Quoted 88 lines · Bradley Morgan
Quoted 86 lines · Paul E. McKenney
Quoted 3 lines · Bradley Morgan
Quoted 2 lines · Zqiang
Quoted 2 lines

On 15 October 2026 10:46:19 BST, Zqiang <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

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.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

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

Quoted 15 lines
Quoted 15 lines
Quoted 1 line

with panic on oops doesn't seem right to me, because we would reserve

that

Quoted 4 lines

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

Quoted 1 line

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.

Quoted 5 lines
Quoted 5 lines

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

Quoted 28 lines
Quoted 1 line

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
kernel/rcu/tasks.h +3 -1
index 627295396cd9..65bb7d4ed632 100644
@@ -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)
+{

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { } · line 1362

Quoted 10 lines
kernel/rcu/tasks.h +6 -1
+}
+
 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);

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { }

Quoted 4 lines
kernel/rcu/tasks.h +1 -0
+       cpus_read_unlock();
 }
 
 static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t

func);

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

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.

Thanx, Paul

Quoted 58 lines
Quoted 39 lines
Quoted 1 line

If you plan on submitting this into a patch, please add my authorship,

or

Quoted 22 lines

my c-d-b.

Feel free to rcutorture test it ;d

BTW: have you reproduced this on your own system?

Quoted 16 lines

Thanks
Zqiang

Quoted 2 lines

Zqiang, have you reproduced this OOM on your own system, if so, could

you

Quoted 8 lines

tell me more details, you may turn my frown into a smiley face ;)

Quoted 6 lines
---
 kernel/rcu/tasks.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct

Quoted 5 lines
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644
@@ -1361,7 +1361,8 @@ static void rcu_tasks_be_rude(struct

work_struct

Quoted 9 lines
Quoted 9 lines

*work)

Quoted 6 lines

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { }

Quoted 6 lines
kernel/rcu/tasks.h +2 -1
 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);

Quoted 1 line
Quoted 1 line
Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Good message, makes sense. But I don't think this is right, see

above.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

}

static void call_rcu_tasks_rude(struct rcu_head *rhp,

rcu_callback_t

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

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

#12 lore raw
Quoted 100 lines · Paul E. McKenney
Quoted 4 lines · Bradley Morgan
Quoted 2 lines · Paul E. McKenney
Quoted 1 line · Bradley Morgan

On 17 October 2026 00:41:00 BST, Zqiang <[email protected]>

Quoted 13 lines · wrote:
Quoted 13 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On 15 October 2026 10:46:19 BST, Zqiang <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

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.

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line

with panic on oops doesn't seem right to me, because we would

reserve

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

that

Quoted 1 line

for when something definitely goes really wrong and we need to

notify

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the user.

I don't believe this patch should go in for this reason, it's a

heavy

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

edge

Quoted 1 line

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

Quoted 28 lines
Quoted 28 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 19 lines
Quoted 1 line

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
kernel/rcu/tasks.h +0 -0
index 627295396cd9..65bb7d4ed632 100644
@@ -1344,15 +1344,23 @@ void exit_tasks_rcu_finish(void) { }
 // Ordering is provided by the scheduler's context-switch code.
 
Quoted 3 lines
Quoted 3 lines

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { }

Quoted 3 lines
kernel/rcu/tasks.h +1 -1
 // 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)

Quoted 16 lines
Quoted 16 lines
Quoted 6 lines
kernel/rcu/tasks.h +2 -0
 {
 }
 
 // Wait for one rude RCU-tasks grace period.
+static void rcu_tasks_rude_ipi(void *info)
+{

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { }

Quoted 10 lines
kernel/rcu/tasks.h +6 -1
+}
+
 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,

Quoted 10 lines
Quoted 10 lines

1);

kernel/rcu/tasks.h void exit_tasks_rcu_finish(void) { }

Quoted 4 lines
kernel/rcu/tasks.h +1 -0
+       cpus_read_unlock();
 }
 
 static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t

func);

Quoted 3 lines

root@p10-linux-brads:~/linux#

On POWERPC, this passes 12 hours of rcutorture on the RUDE01 config.

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

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.

Quoted 2 lines

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 :(

Quoted 35 lines

Thanx, Paul

Quoted 1 line
Quoted 1 line
Quoted 1 line

If you plan on submitting this into a patch, please add my

authorship,

Quoted 8 lines
Quoted 8 lines

or

Quoted 7 lines

my c-d-b.

Feel free to rcutorture test it ;d

BTW: have you reproduced this on your own system?

Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Thanks
Zqiang

Quoted 2 lines

Zqiang, have you reproduced this OOM on your own system, if so,

could

Quoted 15 lines
Quoted 15 lines
Quoted 9 lines
Quoted 9 lines

you

Quoted 8 lines

tell me more details, you may turn my frown into a smiley face ;)

Quoted 6 lines
---
 kernel/rcu/tasks.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

kernel/rcu/tasks.h static void rcu_tasks_be_rude(struct

Quoted 5 lines
kernel/rcu/tasks.h +0 -0
index fcac7361ec51..91c25717402e 100644
@@ -1361,7 +1361,8 @@ static void rcu_tasks_be_rude(struct

work_struct

Quoted 29 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

*work)

Quoted 6 lines
Quoted 6 lines
kernel/rcu/tasks.h +2 -1
 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",

Quoted 21 lines
Quoted 18 lines
Quoted 3 lines
Quoted 3 lines

rtp->name);

Quoted 2 lines
Quoted 1 line

Good message, makes sense. But I don't think this is right, see

above.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

}

static void call_rcu_tasks_rude(struct rcu_head *rhp,

rcu_callback_t

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

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

author reviewer
#14 lore raw
In reply to Joel Fernandes
Quoted 33 lines
Quoted 21 lines · Zqiang

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.

---

 kernel/rcu/tasks.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines

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);

Quoted 2 lines

Is that the best error message? OOM is expected when grace periods do not conclude.

Hi, Joel

I will resend v2, use DEFINE_PER_CPU() to replace alloc_percpu() to allocate work_struct objects.

Thanks
Zqiang

Quoted 10 lines

Thanks.

Quoted 7 lines

}

static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func); --
2.17.1

maintainer
#15 lore raw
Quoted 33 lines · Zqiang
Quoted 33 lines
Quoted 33 lines · Zqiang

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.

---

 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);

Quoted 6 lines
Quoted 2 lines

Is that the best error message? OOM is expected when grace periods do not conclude.

Hi, Joel

I will resend v2, use DEFINE_PER_CPU() to replace alloc_percpu() to allocate work_struct objects.

Thank you! Looking forward to it,

Joel Fernandes