Skip to content

Commit e797bda

Browse files
committed
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. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20190722105219.818822855@linutronix.de
1 parent ad5e427 commit e797bda

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎include/linux/cpumask.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ extern struct cpumask __cpu_active_mask;
115115
#define cpu_active(cpu) ((cpu) == 0)
116116
#endif
117117

118+
extern cpumask_t cpus_booted_once_mask;
119+
118120
static inline void cpu_max_bits_warn(unsigned int cpu, unsigned int bits)
119121
{
120122
#ifdef CONFIG_DEBUG_PER_CPU_MAPS

‎kernel/cpu.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ struct cpuhp_cpu_state {
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) = {
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)
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)
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)
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
}

0 commit comments

Comments
 (0)