Commit 6b2c2847 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Ingo Molnar

x86/x2apic: Convert to CPU hotplug state machine

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarAnna-Maria Gleixner <anna-maria@linutronix.de>
Cc: Len Brown <len.brown@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathias Krause <minipli@googlemail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160713153337.736898691@linutronix.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent e722d8da
...@@ -152,68 +152,48 @@ static void init_x2apic_ldr(void) ...@@ -152,68 +152,48 @@ static void init_x2apic_ldr(void)
} }
} }
/* /*
* At CPU state changes, update the x2apic cluster sibling info. * At CPU state changes, update the x2apic cluster sibling info.
*/ */
static int int x2apic_prepare_cpu(unsigned int cpu)
update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
{ {
unsigned int this_cpu = (unsigned long)hcpu; if (!zalloc_cpumask_var(&per_cpu(cpus_in_cluster, cpu), GFP_KERNEL))
unsigned int cpu; return -ENOMEM;
int err = 0;
if (!zalloc_cpumask_var(&per_cpu(ipi_mask, cpu), GFP_KERNEL)) {
switch (action) { free_cpumask_var(per_cpu(cpus_in_cluster, cpu));
case CPU_UP_PREPARE: return -ENOMEM;
if (!zalloc_cpumask_var(&per_cpu(cpus_in_cluster, this_cpu),
GFP_KERNEL)) {
err = -ENOMEM;
} else if (!zalloc_cpumask_var(&per_cpu(ipi_mask, this_cpu),
GFP_KERNEL)) {
free_cpumask_var(per_cpu(cpus_in_cluster, this_cpu));
err = -ENOMEM;
}
break;
case CPU_UP_CANCELED:
case CPU_UP_CANCELED_FROZEN:
case CPU_DEAD:
for_each_online_cpu(cpu) {
if (x2apic_cluster(this_cpu) != x2apic_cluster(cpu))
continue;
cpumask_clear_cpu(this_cpu, per_cpu(cpus_in_cluster, cpu));
cpumask_clear_cpu(cpu, per_cpu(cpus_in_cluster, this_cpu));
}
free_cpumask_var(per_cpu(cpus_in_cluster, this_cpu));
free_cpumask_var(per_cpu(ipi_mask, this_cpu));
break;
} }
return notifier_from_errno(err); return 0;
} }
static struct notifier_block x2apic_cpu_notifier = { int x2apic_dead_cpu(unsigned int this_cpu)
.notifier_call = update_clusterinfo,
};
static int x2apic_init_cpu_notifier(void)
{ {
int cpu = smp_processor_id(); int cpu;
zalloc_cpumask_var(&per_cpu(cpus_in_cluster, cpu), GFP_KERNEL);
zalloc_cpumask_var(&per_cpu(ipi_mask, cpu), GFP_KERNEL);
BUG_ON(!per_cpu(cpus_in_cluster, cpu) || !per_cpu(ipi_mask, cpu)); for_each_online_cpu(cpu) {
if (x2apic_cluster(this_cpu) != x2apic_cluster(cpu))
cpumask_set_cpu(cpu, per_cpu(cpus_in_cluster, cpu)); continue;
register_hotcpu_notifier(&x2apic_cpu_notifier); cpumask_clear_cpu(this_cpu, per_cpu(cpus_in_cluster, cpu));
return 1; cpumask_clear_cpu(cpu, per_cpu(cpus_in_cluster, this_cpu));
}
free_cpumask_var(per_cpu(cpus_in_cluster, this_cpu));
free_cpumask_var(per_cpu(ipi_mask, this_cpu));
return 0;
} }
static int x2apic_cluster_probe(void) static int x2apic_cluster_probe(void)
{ {
if (x2apic_mode) int cpu = smp_processor_id();
return x2apic_init_cpu_notifier();
else if (!x2apic_mode)
return 0; return 0;
cpumask_set_cpu(cpu, per_cpu(cpus_in_cluster, cpu));
cpuhp_setup_state(CPUHP_X2APIC_PREPARE, "X2APIC_PREPARE",
x2apic_prepare_cpu, x2apic_dead_cpu);
return 1;
} }
static const struct cpumask *x2apic_cluster_target_cpus(void) static const struct cpumask *x2apic_cluster_target_cpus(void)
......
...@@ -17,6 +17,7 @@ enum cpuhp_state { ...@@ -17,6 +17,7 @@ enum cpuhp_state {
CPUHP_WORKQUEUE_PREP, CPUHP_WORKQUEUE_PREP,
CPUHP_HRTIMERS_PREPARE, CPUHP_HRTIMERS_PREPARE,
CPUHP_PROFILE_PREPARE, CPUHP_PROFILE_PREPARE,
CPUHP_X2APIC_PREPARE,
CPUHP_TIMERS_DEAD, CPUHP_TIMERS_DEAD,
CPUHP_NOTIFY_PREPARE, CPUHP_NOTIFY_PREPARE,
CPUHP_BRINGUP_CPU, CPUHP_BRINGUP_CPU,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment