[PATCH 25/25] x86/mcheck: Move CPU_DEAD to hotplug state machine
From: Sebastian Andrzej Siewior
Date: Thu Nov 03 2016 - 10:51:39 EST
This moves the last piece of the old hotplug notifier code in MCE to the
new hotplug state machine.
Cc: Tony Luck <tony.luck@xxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: linux-edac@xxxxxxxxxxxxxxx
Cc: x86@xxxxxxxxxx
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
arch/x86/kernel/cpu/mcheck/mce.c | 53 +++++++++++++++++-----------------------
include/linux/cpuhotplug.h | 1 +
2 files changed, 23 insertions(+), 31 deletions(-)
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index b1770ebcb8de..1e2036e012e0 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2480,28 +2480,6 @@ static void mce_disable_cpu(void)
vendor_disable_error_reporting();
}
-/* Get notified when a cpu comes on/off. Be hotplug friendly. */
-static int
-mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
-{
- unsigned int cpu = (unsigned long)hcpu;
-
- switch (action & ~CPU_TASKS_FROZEN) {
- case CPU_DEAD:
- if (threshold_cpu_callback_dead)
- threshold_cpu_callback_dead(cpu);
- mce_device_remove(cpu);
- mce_intel_hcpu_update(cpu);
-
- /* intentionally ignoring frozen here */
- if (!(action & CPU_TASKS_FROZEN))
- cmci_rediscover();
- break;
- }
-
- return NOTIFY_OK;
-}
-
static int mce_cpu_online(unsigned int cpu)
{
int ret;
@@ -2518,6 +2496,19 @@ static int mce_cpu_online(unsigned int cpu)
return 0;
}
+static int mce_cpu_dead(unsigned int cpu)
+{
+ if (threshold_cpu_callback_dead)
+ threshold_cpu_callback_dead(cpu);
+ mce_device_remove(cpu);
+ mce_intel_hcpu_update(cpu);
+
+ /* intentionally ignoring frozen here */
+ if (!cpuhp_tasks_frozen)
+ cmci_rediscover();
+ return 0;
+}
+
static int mce_cpu_down_dying(unsigned int cpu)
{
struct timer_list *t = this_cpu_ptr(&mce_timer);
@@ -2527,10 +2518,6 @@ static int mce_cpu_down_dying(unsigned int cpu)
return 0;
}
-static struct notifier_block mce_cpu_notifier = {
- .notifier_call = mce_cpu_callback,
-};
-
static __init void mce_init_banks(void)
{
int i;
@@ -2580,20 +2567,21 @@ static __init int mcheck_init_device(void)
if (err)
goto err_init_pool;
+ err = cpuhp_setup_state(CPUHP_X86_MCE_DEAD, "x86/mce:dead", NULL,
+ mce_cpu_dead);
+ if (err)
+ goto err_init_pool;
+
err = cpuhp_setup_state(CPUHP_AP_X86_MCE_STARTING, "x86/mce:starting",
mcheck_cpu_starting, mce_cpu_down_dying);
if (err)
- goto err_init_pool;
+ goto err_hp_starting;
err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/mce:online",
mce_cpu_online, NULL);
if (err < 0)
goto err_hp_online;
hp_online = err;
- cpu_notifier_register_begin();
- __register_hotcpu_notifier(&mce_cpu_notifier);
- cpu_notifier_register_done();
-
register_syscore_ops(&mce_syscore_ops);
/* register character device /dev/mcelog */
@@ -2610,6 +2598,9 @@ static __init int mcheck_init_device(void)
err_hp_online:
cpuhp_remove_state(CPUHP_AP_X86_MCE_STARTING);
+err_hp_starting:
+ cpuhp_remove_state(CPUHP_X86_MCE_DEAD);
+
err_init_pool:
mca_cfg.banks = 0;
kfree(mce_banks);
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 4fe2ba418471..acb37a7f7831 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -16,6 +16,7 @@ enum cpuhp_state {
CPUHP_PERF_SUPERH,
CPUHP_X86_HPET_DEAD,
CPUHP_X86_APB_DEAD,
+ CPUHP_X86_MCE_DEAD,
CPUHP_VIRT_NET_DEAD,
CPUHP_SLUB_DEAD,
CPUHP_MM_WRITEBACK_DEAD,
--
2.10.2