rcu/rcuscale: Fix using smp_processor_id() in preemptible warnings
Subsystems (2)
PATCH 1/1 rcu/rcuscale: Fix using smp_processor_id() in preemptible warnings
BUG: using smp_processor_id() in preemptible [00000000] code: rcu_scale_write/69 CPU: 0 PID: 66 Comm: rcu_scale_write Not tainted 5.18.0-rc7-next-20220517-yoctodev-standard+ caller is debug_smp_processor_id+0x17/0x20 Call Trace: <TASK> dump_stack_lvl+0x49/0x5e dump_stack+0x10/0x12 check_preemption_disabled+0xdf/0xf0 debug_smp_processor_id+0x17/0x20 rcu_scale_writer+0x2b5/0x580 kthread+0x177/0x1b0 ret_from_fork+0x22/0x30 </TASK>
Reproduction method:
runqemu kvm slirp nographic qemuparams="-m 4096 -smp 8" bootparams="isolcpus=2,3 nohz_full=2,3 rcu_nocbs=2,3 rcutree.dump_tree=1 rcuscale.shutdown=false rcuscale.gp_async=true" -d
when the CONFIG_DEBUG_PREEMPT is enabled, this_cpu_ptr() will call debug_smp_processor_id() get current CPU number, this warning is triggered by is_percpu_thread() in debug_smp_processor_id(), the is_percpu_thread() need to check whether 'current->nr_cpus_allowed == 1' and 'current->flags & PF_NO_SETAFFINITY', invoke set_cpus_allowed_ptr() only set kthreads->nr_cpus_allowed, but the PF_NO_SETAFFINITY is not set to kthread->flags, so add PF_NO_SETAFFINITY flags setting.
--- kernel/rcu/rcuscale.c | 1 + 1 file changed, 1 insertion(+)
kernel/rcu/rcuscale.c +1 -0
@@ -419,6 +419,7 @@ rcu_scale_writer(void *arg)VERBOSE_SCALEOUT_STRING ("rcu_scale_writer task started" );WARN_ON (!wdpp);set_cpus_allowed_ptr (current,cpumask_of (me % nr_cpu_ids)); + current->flags |=PF_NO_SETAFFINITY ;sched_set_fifo_low (current);if (holdoff)
Signature · 1 line
2.25.1
Paul E. McKenney
maintainerQuoted 27 lines · Zqiang
BUG: using smp_processor_id() in preemptible [00000000] code: rcu_scale_write/69 CPU: 0 PID: 66 Comm: rcu_scale_write Not tainted 5.18.0-rc7-next-20220517-yoctodev-standard+ caller is debug_smp_processor_id+0x17/0x20 Call Trace: <TASK> dump_stack_lvl+0x49/0x5e dump_stack+0x10/0x12 check_preemption_disabled+0xdf/0xf0 debug_smp_processor_id+0x17/0x20 rcu_scale_writer+0x2b5/0x580 kthread+0x177/0x1b0 ret_from_fork+0x22/0x30 </TASK>Reproduction method:
runqemu kvm slirp nographic qemuparams="-m 4096 -smp 8" bootparams="isolcpus=2,3 nohz_full=2,3 rcu_nocbs=2,3 rcutree.dump_tree=1 rcuscale.shutdown=false rcuscale.gp_async=true" -dwhen the
CONFIG_DEBUG_PREEMPTis enabled,this_cpu_ptr()will calldebug_smp_processor_id()get current CPU number, this warning is triggered byis_percpu_thread()indebug_smp_processor_id(), theis_percpu_thread()need to check whether 'current->nr_cpus_allowed== 1' and 'current->flags&PF_NO_SETAFFINITY', invokeset_cpus_allowed_ptr()only setkthreads->nr_cpus_allowed, but thePF_NO_SETAFFINITYis not set tokthread->flags, so addPF_NO_SETAFFINITYflags setting.
Quoted 1 line
Signed-off-by Zqiang <[email protected]>
Good catch! Queued for v5.20 (or v6.0, as Linus decides), thank you!
Thanx, Paul
Quoted 19 lines
--- kernel/rcu/rcuscale.c | 1 + 1 file changed, 1 insertion(+)kernel/rcu/rcuscale.c +1
-0@@ -419,6 +419,7 @@ rcu_scale_writer(void *arg)VERBOSE_SCALEOUT_STRING ("rcu_scale_writer task started" );WARN_ON (!wdpp);set_cpus_allowed_ptr (current,cpumask_of (me % nr_cpu_ids)); + current->flags |=PF_NO_SETAFFINITY ;sched_set_fifo_low (current);if (holdoff)Signature · 1 line
2.25.1