aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>2014-03-10 16:37:45 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-03-20 08:43:43 -0400
commit047868ce2952bb6a86ccea3ecc6fd59faa9062a7 (patch)
treeade13274637f883ded25641b37e78161c878e1b8 /arch/x86
parent7b7139d4abe8a94446db6a91882f1400920891d5 (diff)
x86, amd, ibs: Fix CPU hotplug callback registration
Subsystems that want to register CPU hotplug callbacks, as well as perform initialization for the CPUs that are already online, often do it as shown below: get_online_cpus(); for_each_online_cpu(cpu) init_cpu(cpu); register_cpu_notifier(&foobar_cpu_notifier); put_online_cpus(); This is wrong, since it is prone to ABBA deadlocks involving the cpu_add_remove_lock and the cpu_hotplug.lock (when running concurrently with CPU hotplug operations). Instead, the correct and race-free way of performing the callback registration is: cpu_notifier_register_begin(); for_each_online_cpu(cpu) init_cpu(cpu); /* Note the use of the double underscored version of the API */ __register_cpu_notifier(&foobar_cpu_notifier); cpu_notifier_register_done(); Fix the amd-ibs code in x86 by using this latter form of callback registration. Cc: Peter Zijlstra <peterz@infradead.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/cpu/perf_event_amd_ibs.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_amd_ibs.c b/arch/x86/kernel/cpu/perf_event_amd_ibs.c
index 4b8e4d3cd6ea..4c36bbe3173a 100644
--- a/arch/x86/kernel/cpu/perf_event_amd_ibs.c
+++ b/arch/x86/kernel/cpu/perf_event_amd_ibs.c
@@ -926,13 +926,13 @@ static __init int amd_ibs_init(void)
926 goto out; 926 goto out;
927 927
928 perf_ibs_pm_init(); 928 perf_ibs_pm_init();
929 get_online_cpus(); 929 cpu_notifier_register_begin();
930 ibs_caps = caps; 930 ibs_caps = caps;
931 /* make ibs_caps visible to other cpus: */ 931 /* make ibs_caps visible to other cpus: */
932 smp_mb(); 932 smp_mb();
933 perf_cpu_notifier(perf_ibs_cpu_notifier);
934 smp_call_function(setup_APIC_ibs, NULL, 1); 933 smp_call_function(setup_APIC_ibs, NULL, 1);
935 put_online_cpus(); 934 __perf_cpu_notifier(perf_ibs_cpu_notifier);
935 cpu_notifier_register_done();
936 936
937 ret = perf_event_ibs_init(); 937 ret = perf_event_ibs_init();
938out: 938out: