rcu: Let dump_cpu_task() be used without preemption disabled
authorRyo Takakura <takakura@valinux.co.jp>
Fri, 28 Jun 2024 04:18:26 +0000 (13:18 +0900)
committerNeeraj Upadhyay <neeraj.upadhyay@kernel.org>
Wed, 14 Aug 2024 18:40:50 +0000 (00:10 +0530)
The commit 2d7f00b2f0130 ("rcu: Suppress smp_processor_id() complaint
in synchronize_rcu_expedited_wait()") disabled preemption around
dump_cpu_task() to suppress warning on its usage within preemtible context.

Calling dump_cpu_task() doesn't required to be in non-preemptible context
except for suppressing the smp_processor_id() warning.
As the smp_processor_id() is evaluated along with in_hardirq()
to check if it's in interrupt context, this patch removes the need
for its preemtion disablement by reordering the condition so that
smp_processor_id() only gets evaluated when it's in interrupt context.

Signed-off-by: Ryo Takakura <takakura@valinux.co.jp>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
kernel/rcu/tree_exp.h
kernel/sched/core.c

index d4be644afb50fcd37be160d46aba1d70771c7164..c5d9a7eb08034cca56f8d1a91bad2613e7c91fe4 100644 (file)
@@ -597,9 +597,7 @@ static void synchronize_rcu_expedited_stall(unsigned long jiffies_start, unsigne
                        mask = leaf_node_cpu_bit(rnp, cpu);
                        if (!(READ_ONCE(rnp->expmask) & mask))
                                continue;
-                       preempt_disable(); // For smp_processor_id() in dump_cpu_task().
                        dump_cpu_task(cpu);
-                       preempt_enable();
                }
                rcu_exp_print_detail_task_stall_rnp(rnp);
        }
index a9f655025607b977a790adbc7f33b1265fce6636..78ae888a1fa2f314b03152b68408eb19bf2d8755 100644 (file)
@@ -9726,7 +9726,7 @@ struct cgroup_subsys cpu_cgrp_subsys = {
 
 void dump_cpu_task(int cpu)
 {
-       if (cpu == smp_processor_id() && in_hardirq()) {
+       if (in_hardirq() && cpu == smp_processor_id()) {
                struct pt_regs *regs;
 
                regs = get_irq_regs();