Skip to content

Commit 99f070b

Browse files
Qian Caimpe
Qian Cai
authored andcommitted
powerpc/smp: Call rcu_cpu_starting() earlier
The call to rcu_cpu_starting() in start_secondary() is not early enough in the CPU-hotplug onlining process, which results in lockdep splats as follows (with CONFIG_PROVE_RCU_LIST=y): WARNING: suspicious RCU usage ----------------------------- kernel/locking/lockdep.c:3497 RCU-list traversed in non-reader section!! other info that might help us debug this: RCU used illegally from offline CPU! rcu_scheduler_active = 1, debug_locks = 1 no locks held by swapper/1/0. Call Trace: dump_stack+0xec/0x144 (unreliable) lockdep_rcu_suspicious+0x128/0x14c __lock_acquire+0x1060/0x1c60 lock_acquire+0x140/0x5f0 _raw_spin_lock_irqsave+0x64/0xb0 clockevents_register_device+0x74/0x270 register_decrementer_clockevent+0x94/0x110 start_secondary+0x134/0x800 start_secondary_prolog+0x10/0x14 This is avoided by adding a call to rcu_cpu_starting() near the beginning of the start_secondary() function. Note that the raw_smp_processor_id() is required in order to avoid calling into lockdep before RCU has declared the CPU to be watched for readers. It's safe to call rcu_cpu_starting() in the arch code as well as later in generic code, as explained by Paul: It uses a per-CPU variable so that RCU pays attention only to the first call to rcu_cpu_starting() if there is more than one of them. This is even intentional, due to there being a generic arch-independent call to rcu_cpu_starting() in notify_cpu_starting(). So multiple calls to rcu_cpu_starting() are fine by design. Fixes: 4d00409 ("lockdep: Fix lockdep recursion") Signed-off-by: Qian Cai <[email protected]> Acked-by: Paul E. McKenney <[email protected]> [mpe: Add Fixes tag, reword slightly & expand change log] Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fd552e0 commit 99f070b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/powerpc/kernel/smp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,13 +1393,14 @@ static void add_cpu_to_masks(int cpu)
13931393
/* Activate a secondary processor. */
13941394
void start_secondary(void *unused)
13951395
{
1396-
unsigned int cpu = smp_processor_id();
1396+
unsigned int cpu = raw_smp_processor_id();
13971397

13981398
mmgrab(&init_mm);
13991399
current->active_mm = &init_mm;
14001400

14011401
smp_store_cpu_info(cpu);
14021402
set_dec(tb_ticks_per_jiffy);
1403+
rcu_cpu_starting(cpu);
14031404
preempt_disable();
14041405
cpu_callin_map[cpu] = 1;
14051406

0 commit comments

Comments
 (0)