History

smp/hotplug: Track booted once CPUs in a cpumask

The booted once information which is required to deal with the MCE broadcast issue on X86 correctly is stored in the per cpu hotplug state, which is perfectly fine for the intended purpose. X86 needs that information for supporting NMI broadcasting via shortcuts, but retrieving it from per cpu data is cumbersome. Move it to a cpumask so the information can be checked against the cpu_present_mask quickly. No functional change intended.

Thomas Gleixner committed 7 years ago

Commit e797bda1 parent ad5e4272 files · +9 −4Browse files

Showing the changes to kernel/cpu.c (1 of 2 files). Show all

Unified · Split

kernel/cpu.c+7−4
@@ -62,7 +62,6 @@ struct cpuhp_cpu_state { · 61 unmodified lines
6262 bool rollback;
6363 bool single;
6464 bool bringup;
65− bool booted_once;
6665 struct hlist_node *node;
6766 struct hlist_node *last;
6867 enum cpuhp_state cb_state;
@@ -76,6 +75,10 @@ static DEFINE_PER_CPU(struct cpuhp_cpu_state, cpuhp_state) = { · 7 unmodified lines
7675 .fail = CPUHP_INVALID,
7776 };
7877
78+#ifdef CONFIG_SMP
79+cpumask_t cpus_booted_once_mask;
80+#endif
81+
7982 #if defined(CONFIG_LOCKDEP) && defined(CONFIG_SMP)
8083 static struct lockdep_map cpuhp_state_up_map =
8184 STATIC_LOCKDEP_MAP_INIT("cpuhp_state-up", &cpuhp_state_up_map);
@@ -433,7 +436,7 @@ static inline bool cpu_smt_allowed(unsigned int cpu) · 351 unmodified lines
433436 * CPU. Otherwise, a broadacasted MCE observing CR4.MCE=0b on any
434437 * core will shutdown the machine.
435438 */
436− return !per_cpu(cpuhp_state, cpu).booted_once;
439+ return !cpumask_test_cpu(cpu, &cpus_booted_once_mask);
437440 }
438441 #else
439442 static inline bool cpu_smt_allowed(unsigned int cpu) { return true; }
@@ -1066,7 +1069,7 @@ void notify_cpu_starting(unsigned int cpu) · 626 unmodified lines
10661069 int ret;
10671070
10681071 rcu_cpu_starting(cpu); /* Enables RCU usage on this CPU. */
1069− st->booted_once = true;
1072+ cpumask_set_cpu(cpu, &cpus_booted_once_mask);
10701073 while (st->state < target) {
10711074 st->state++;
10721075 ret = cpuhp_invoke_callback(cpu, st->state, true, NULL, NULL);
@@ -2334,7 +2337,7 @@ void __init boot_cpu_init(void) · 1261 unmodified lines
23342337 void __init boot_cpu_hotplug_init(void)
23352338 {
23362339 #ifdef CONFIG_SMP
2337− this_cpu_write(cpuhp_state.booted_once, true);
2340+ cpumask_set_cpu(smp_processor_id(), &cpus_booted_once_mask);
23382341 #endif
23392342 this_cpu_write(cpuhp_state.state, CPUHP_ONLINE);
23402343 }