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.
Showing the changes to kernel/cpu.c (1 of 2 files). Show all
Unified · Split
| @@ -62,7 +62,6 @@ struct cpuhp_cpu_state { · 61 unmodified lines | |||
| 62 | bool rollback; | 62 | bool rollback; |
| 63 | bool single; | 63 | bool single; |
| 64 | bool bringup; | 64 | bool bringup; |
| 65 | bool booted_once; | ||
| 66 | struct hlist_node *node; | 65 | struct hlist_node *node; |
| 67 | struct hlist_node *last; | 66 | struct hlist_node *last; |
| 68 | enum cpuhp_state cb_state; | 67 | enum cpuhp_state cb_state; |
| @@ -76,6 +75,10 @@ static DEFINE_PER_CPU(struct cpuhp_cpu_state, cpuhp_state) = { · 7 unmodified lines | |||
| 76 | .fail = CPUHP_INVALID, | 75 | .fail = CPUHP_INVALID, |
| 77 | }; | 76 | }; |
| 78 | 77 | ||
| 78 | #ifdef CONFIG_SMP | ||
| 79 | cpumask_t cpus_booted_once_mask; | ||
| 80 | #endif | ||
| 81 | |||
| 79 | #if defined(CONFIG_LOCKDEP) && defined(CONFIG_SMP) | 82 | #if defined(CONFIG_LOCKDEP) && defined(CONFIG_SMP) |
| 80 | static struct lockdep_map cpuhp_state_up_map = | 83 | static struct lockdep_map cpuhp_state_up_map = |
| 81 | STATIC_LOCKDEP_MAP_INIT("cpuhp_state-up", &cpuhp_state_up_map); | 84 | 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 | |||
| 433 | * CPU. Otherwise, a broadacasted MCE observing CR4.MCE=0b on any | 436 | * CPU. Otherwise, a broadacasted MCE observing CR4.MCE=0b on any |
| 434 | * core will shutdown the machine. | 437 | * core will shutdown the machine. |
| 435 | */ | 438 | */ |
| 436 | return !per_cpu(cpuhp_state, cpu).booted_once; | 439 | return !cpumask_test_cpu(cpu, &cpus_booted_once_mask); |
| 437 | } | 440 | } |
| 438 | #else | 441 | #else |
| 439 | static inline bool cpu_smt_allowed(unsigned int cpu) { return true; } | 442 | 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 | |||
| 1066 | int ret; | 1069 | int ret; |
| 1067 | 1070 | ||
| 1068 | rcu_cpu_starting(cpu); /* Enables RCU usage on this CPU. */ | 1071 | rcu_cpu_starting(cpu); /* Enables RCU usage on this CPU. */ |
| 1069 | st->booted_once = true; | 1072 | cpumask_set_cpu(cpu, &cpus_booted_once_mask); |
| 1070 | while (st->state < target) { | 1073 | while (st->state < target) { |
| 1071 | st->state++; | 1074 | st->state++; |
| 1072 | ret = cpuhp_invoke_callback(cpu, st->state, true, NULL, NULL); | 1075 | ret = cpuhp_invoke_callback(cpu, st->state, true, NULL, NULL); |
| @@ -2334,7 +2337,7 @@ void __init boot_cpu_init(void) · 1261 unmodified lines | |||
| 2334 | void __init boot_cpu_hotplug_init(void) | 2337 | void __init boot_cpu_hotplug_init(void) |
| 2335 | { | 2338 | { |
| 2336 | #ifdef CONFIG_SMP | 2339 | #ifdef CONFIG_SMP |
| 2337 | this_cpu_write(cpuhp_state.booted_once, true); | 2340 | cpumask_set_cpu(smp_processor_id(), &cpus_booted_once_mask); |
| 2338 | #endif | 2341 | #endif |
| 2339 | this_cpu_write(cpuhp_state.state, CPUHP_ONLINE); | 2342 | this_cpu_write(cpuhp_state.state, CPUHP_ONLINE); |
| 2340 | } | 2343 | } |