]> git.baikalelectronics.ru Git - kernel.git/commitdiff
x86/smpboot: Move rcu_cpu_starting() earlier
authorPaul E. McKenney <paulmck@kernel.org>
Wed, 21 Oct 2020 04:13:55 +0000 (21:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Dec 2022 11:24:15 +0000 (12:24 +0100)
commit 1b2b292555b18727c2935735818abe804fca43cc upstream.

The call to rcu_cpu_starting() in mtrr_ap_init() is not early enough
in the CPU-hotplug onlining process, which results in lockdep splats
as follows:

=============================
WARNING: suspicious RCU usage
5.9.0+ #268 Not tainted
-----------------------------
kernel/kprobes.c:300 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.

stack backtrace:
CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.9.0+ #268
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.10.2-1ubuntu1 04/01/2014
Call Trace:
 dump_stack+0x77/0x97
 __is_insn_slot_addr+0x15d/0x170
 kernel_text_address+0xba/0xe0
 ? get_stack_info+0x22/0xa0
 __kernel_text_address+0x9/0x30
 show_trace_log_lvl+0x17d/0x380
 ? dump_stack+0x77/0x97
 dump_stack+0x77/0x97
 __lock_acquire+0xdf7/0x1bf0
 lock_acquire+0x258/0x3d0
 ? vprintk_emit+0x6d/0x2c0
 _raw_spin_lock+0x27/0x40
 ? vprintk_emit+0x6d/0x2c0
 vprintk_emit+0x6d/0x2c0
 printk+0x4d/0x69
 start_secondary+0x1c/0x100
 secondary_startup_64_no_verify+0xb8/0xbb

This is avoided by moving the call to rcu_cpu_starting up 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.

Link: https://lore.kernel.org/lkml/160223032121.7002.1269740091547117869.tip-bot2@tip-bot2/
Reported-by: Qian Cai <cai@redhat.com>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Joel Fernandes <joel@joelfernandes.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kernel/cpu/mtrr/mtrr.c
arch/x86/kernel/smpboot.c

index 507039c20128a6870e1e660d5f5bb3b470cfb18f..4482819bb13ca628e95a5ccab889ebd456ac0f47 100644 (file)
@@ -794,8 +794,6 @@ void mtrr_ap_init(void)
        if (!use_intel() || mtrr_aps_delayed_init)
                return;
 
-       rcu_cpu_starting(smp_processor_id());
-
        /*
         * Ideally we should hold mtrr_mutex here to avoid mtrr entries
         * changed, but this routine will be called in cpu boot time,
index 8367bd7a9a810cc303bd3e7644a8accb3e5add22..1699d18bd1548470389529c02c5b74a78c660120 100644 (file)
@@ -224,6 +224,7 @@ static void notrace start_secondary(void *unused)
 #endif
        load_current_idt();
        cpu_init();
+       rcu_cpu_starting(raw_smp_processor_id());
        x86_cpuinit.early_percpu_clock_init();
        preempt_disable();
        smp_callin();