From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> To: linux-kernel@vger.kernel.org Cc: rt@linutronix.de, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Tony Luck <tony.luck@intel.com>, Fenghua Yu <fenghua.yu@intel.com>, linux-ia64@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de> Subject: [PATCH 14/25] ia64/err-inject: Convert to hotplug state machine Date: Thu, 3 Nov 2016 15:50:10 +0100 [thread overview] Message-ID: <20161103145021.28528-15-bigeasy@linutronix.de> (raw) In-Reply-To: <20161103145021.28528-1-bigeasy@linutronix.de> Install the callbacks via the state machine and let the core invoke the callbacks on the already online CPUs. The removal of the files happens now in the prepare down stage as there is no reason to keep them around until the cpu has actually died. Cc: Tony Luck <tony.luck@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: linux-ia64@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> --- arch/ia64/kernel/err_inject.c | 78 +++++++++++-------------------------------- 1 file changed, 19 insertions(+), 59 deletions(-) diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c index 5ed0ea92c5bf..85bba43e7d5d 100644 --- a/arch/ia64/kernel/err_inject.c +++ b/arch/ia64/kernel/err_inject.c @@ -224,85 +224,45 @@ static struct attribute_group err_inject_attr_group = { .name = "err_inject" }; /* Add/Remove err_inject interface for CPU device */ -static int err_inject_add_dev(struct device *sys_dev) +static int err_inject_add_dev(unsigned int cpu) { + struct device *sys_dev = get_cpu_device(cpu); + return sysfs_create_group(&sys_dev->kobj, &err_inject_attr_group); } -static int err_inject_remove_dev(struct device *sys_dev) +static int err_inject_remove_dev(unsigned int cpu) { + struct device *sys_dev = get_cpu_device(cpu); + sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group); return 0; } -static int err_inject_cpu_callback(struct notifier_block *nfb, - unsigned long action, void *hcpu) + +static enum cpuhp_state hp_online; + +static int __init err_inject_init(void) { - unsigned int cpu = (unsigned long)hcpu; - struct device *sys_dev; - - sys_dev = get_cpu_device(cpu); - switch (action) { - case CPU_ONLINE: - case CPU_ONLINE_FROZEN: - err_inject_add_dev(sys_dev); - break; - case CPU_DEAD: - case CPU_DEAD_FROZEN: - err_inject_remove_dev(sys_dev); - break; - } - - return NOTIFY_OK; -} - -static struct notifier_block err_inject_cpu_notifier = -{ - .notifier_call = err_inject_cpu_callback, -}; - -static int __init -err_inject_init(void) -{ - int i; - + int ret; #ifdef ERR_INJ_DEBUG printk(KERN_INFO "Enter error injection driver.\n"); #endif - cpu_notifier_register_begin(); - - for_each_online_cpu(i) { - err_inject_cpu_callback(&err_inject_cpu_notifier, CPU_ONLINE, - (void *)(long)i); + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "ia64/err_inj:online", + err_inject_add_dev, err_inject_remove_dev); + if (ret >= 0) { + hp_online = ret; + ret = 0; } - - __register_hotcpu_notifier(&err_inject_cpu_notifier); - - cpu_notifier_register_done(); - - return 0; + return ret; } -static void __exit -err_inject_exit(void) +static void __exit err_inject_exit(void) { - int i; - struct device *sys_dev; - #ifdef ERR_INJ_DEBUG printk(KERN_INFO "Exit error injection driver.\n"); #endif - - cpu_notifier_register_begin(); - - for_each_online_cpu(i) { - sys_dev = get_cpu_device(i); - sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group); - } - - __unregister_hotcpu_notifier(&err_inject_cpu_notifier); - - cpu_notifier_register_done(); + cpuhp_remove_state(hp_online); } module_init(err_inject_init); -- 2.10.2
WARNING: multiple messages have this Message-ID (diff)
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> To: linux-kernel@vger.kernel.org Cc: rt@linutronix.de, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Tony Luck <tony.luck@intel.com>, Fenghua Yu <fenghua.yu@intel.com>, linux-ia64@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de> Subject: [PATCH 14/25] ia64/err-inject: Convert to hotplug state machine Date: Thu, 03 Nov 2016 14:50:10 +0000 [thread overview] Message-ID: <20161103145021.28528-15-bigeasy@linutronix.de> (raw) In-Reply-To: <20161103145021.28528-1-bigeasy@linutronix.de> Install the callbacks via the state machine and let the core invoke the callbacks on the already online CPUs. The removal of the files happens now in the prepare down stage as there is no reason to keep them around until the cpu has actually died. Cc: Tony Luck <tony.luck@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: linux-ia64@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> --- arch/ia64/kernel/err_inject.c | 78 +++++++++++-------------------------------- 1 file changed, 19 insertions(+), 59 deletions(-) diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c index 5ed0ea92c5bf..85bba43e7d5d 100644 --- a/arch/ia64/kernel/err_inject.c +++ b/arch/ia64/kernel/err_inject.c @@ -224,85 +224,45 @@ static struct attribute_group err_inject_attr_group = { .name = "err_inject" }; /* Add/Remove err_inject interface for CPU device */ -static int err_inject_add_dev(struct device *sys_dev) +static int err_inject_add_dev(unsigned int cpu) { + struct device *sys_dev = get_cpu_device(cpu); + return sysfs_create_group(&sys_dev->kobj, &err_inject_attr_group); } -static int err_inject_remove_dev(struct device *sys_dev) +static int err_inject_remove_dev(unsigned int cpu) { + struct device *sys_dev = get_cpu_device(cpu); + sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group); return 0; } -static int err_inject_cpu_callback(struct notifier_block *nfb, - unsigned long action, void *hcpu) + +static enum cpuhp_state hp_online; + +static int __init err_inject_init(void) { - unsigned int cpu = (unsigned long)hcpu; - struct device *sys_dev; - - sys_dev = get_cpu_device(cpu); - switch (action) { - case CPU_ONLINE: - case CPU_ONLINE_FROZEN: - err_inject_add_dev(sys_dev); - break; - case CPU_DEAD: - case CPU_DEAD_FROZEN: - err_inject_remove_dev(sys_dev); - break; - } - - return NOTIFY_OK; -} - -static struct notifier_block err_inject_cpu_notifier = -{ - .notifier_call = err_inject_cpu_callback, -}; - -static int __init -err_inject_init(void) -{ - int i; - + int ret; #ifdef ERR_INJ_DEBUG printk(KERN_INFO "Enter error injection driver.\n"); #endif - cpu_notifier_register_begin(); - - for_each_online_cpu(i) { - err_inject_cpu_callback(&err_inject_cpu_notifier, CPU_ONLINE, - (void *)(long)i); + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "ia64/err_inj:online", + err_inject_add_dev, err_inject_remove_dev); + if (ret >= 0) { + hp_online = ret; + ret = 0; } - - __register_hotcpu_notifier(&err_inject_cpu_notifier); - - cpu_notifier_register_done(); - - return 0; + return ret; } -static void __exit -err_inject_exit(void) +static void __exit err_inject_exit(void) { - int i; - struct device *sys_dev; - #ifdef ERR_INJ_DEBUG printk(KERN_INFO "Exit error injection driver.\n"); #endif - - cpu_notifier_register_begin(); - - for_each_online_cpu(i) { - sys_dev = get_cpu_device(i); - sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group); - } - - __unregister_hotcpu_notifier(&err_inject_cpu_notifier); - - cpu_notifier_register_done(); + cpuhp_remove_state(hp_online); } module_init(err_inject_init); -- 2.10.2
next prev parent reply other threads:[~2016-11-03 14:53 UTC|newest] Thread overview: 108+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-11-03 14:49 cpu hotplug: convert more drivers (batch #4) Sebastian Andrzej Siewior 2016-11-03 14:49 ` [PATCH 01/25] fs/buffer: Convert to hotplug state machine Sebastian Andrzej Siewior 2016-11-09 22:52 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-10 16:24 ` [PATCH 01/25] " Al Viro 2016-11-10 16:31 ` Thomas Gleixner 2016-11-03 14:49 ` [PATCH 02/25] kernel/printk: " Sebastian Andrzej Siewior 2016-11-09 22:52 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:49 ` [PATCH 03/25] mm/memcg: " Sebastian Andrzej Siewior 2016-11-09 22:53 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 04/25] lib/percpu_counter: " Sebastian Andrzej Siewior 2016-11-09 22:53 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 05/25] lib/radix-tree: " Sebastian Andrzej Siewior 2016-11-09 22:54 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 06/25] mm/page_alloc: " Sebastian Andrzej Siewior 2016-11-09 22:54 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 07/25] mm/vmscan: " Sebastian Andrzej Siewior 2016-11-09 22:55 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 08/25] net/dev: " Sebastian Andrzej Siewior 2016-11-09 22:55 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 09/25] net/flowcache: " Sebastian Andrzej Siewior 2016-11-09 22:56 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 10/25] s390/smp: Make cpu notifier symetric Sebastian Andrzej Siewior 2016-11-04 14:22 ` Heiko Carstens 2016-11-04 14:41 ` [PATCH 10/25 v2] " Sebastian Andrzej Siewior 2016-11-09 22:56 ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner 2016-11-03 14:50 ` [PATCH 11/25] s390/smp: Convert to hotplug state machine Sebastian Andrzej Siewior 2016-11-04 14:34 ` Heiko Carstens 2016-11-04 14:45 ` [PATCH 11/25 v2] " Sebastian Andrzej Siewior 2016-11-09 22:57 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 12/25] drivers base/cacheinfo: " Sebastian Andrzej Siewior 2016-11-09 22:57 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 13/25] drivers base/topology: " Sebastian Andrzej Siewior 2016-11-09 22:57 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` Sebastian Andrzej Siewior [this message] 2016-11-03 14:50 ` [PATCH 14/25] ia64/err-inject: " Sebastian Andrzej Siewior 2016-11-09 22:58 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 15/25] ia64/palinfo: " Sebastian Andrzej Siewior 2016-11-03 14:50 ` Sebastian Andrzej Siewior 2016-11-09 22:58 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 16/25] ia64/salinfo: " Sebastian Andrzej Siewior 2016-11-03 14:50 ` Sebastian Andrzej Siewior 2016-11-03 15:45 ` kbuild test robot 2016-11-03 15:45 ` kbuild test robot 2016-11-03 17:31 ` [PATCH 16/25 v2] " Sebastian Andrzej Siewior 2016-11-03 17:31 ` Sebastian Andrzej Siewior 2016-11-09 22:59 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 16:22 ` [PATCH 16/25] " kbuild test robot 2016-11-03 16:22 ` kbuild test robot 2016-11-03 14:50 ` [PATCH 17/25] ia64/topology: " Sebastian Andrzej Siewior 2016-11-03 14:50 ` Sebastian Andrzej Siewior 2016-11-03 15:53 ` kbuild test robot 2016-11-03 15:53 ` kbuild test robot 2016-11-03 17:33 ` [PATCH 17/25 v2] " Sebastian Andrzej Siewior 2016-11-03 17:33 ` Sebastian Andrzej Siewior 2016-11-09 22:59 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 18/25] x86/mcheck: Move threshold_create_device() Sebastian Andrzej Siewior 2016-11-07 10:32 ` Borislav Petkov 2016-11-03 14:50 ` [PATCH 19/25] x86/mcheck: Explicit cleanup on failure in mce_amd Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 20/25] x86/mcheck: Be prepared for a rollback back to the ONLINE state Sebastian Andrzej Siewior 2016-11-07 10:32 ` Borislav Petkov 2016-11-07 10:40 ` Sebastian Andrzej Siewior 2016-11-07 12:31 ` Borislav Petkov 2016-11-07 17:23 ` Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 21/25] x86/mcheck: Split threshold_cpu_callback into two callbacks Sebastian Andrzej Siewior 2016-11-07 13:20 ` Borislav Petkov 2016-11-07 13:25 ` Sebastian Andrzej Siewior 2016-11-07 15:07 ` Borislav Petkov 2016-11-07 15:14 ` Sebastian Andrzej Siewior 2016-11-07 17:26 ` Sebastian Andrzej Siewior 2016-11-07 18:19 ` Borislav Petkov 2016-11-03 14:50 ` [PATCH 22/25] x86/mcheck: Do the init in one place Sebastian Andrzej Siewior 2016-11-07 18:45 ` Borislav Petkov 2016-11-07 18:55 ` Luck, Tony 2016-11-07 20:12 ` Borislav Petkov 2016-11-08 9:23 ` Borislav Petkov 2016-11-09 14:22 ` Sebastian Andrzej Siewior 2016-11-09 15:38 ` Borislav Petkov 2016-11-09 16:24 ` Sebastian Andrzej Siewior 2016-11-09 17:01 ` Borislav Petkov 2016-11-09 17:22 ` Sebastian Andrzej Siewior 2016-11-09 18:37 ` Luck, Tony 2016-11-10 9:00 ` Sebastian Andrzej Siewior 2016-11-10 9:18 ` Borislav Petkov 2016-11-10 17:44 ` x86/mcheck: convert to hotplug state engine, take #2 Sebastian Andrzej Siewior 2016-11-10 17:44 ` [PATCH 1/7] x86/mcheck: Move threshold_create_device() Sebastian Andrzej Siewior 2016-11-16 8:39 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-10 17:44 ` [PATCH 2/7] x86/mcheck: Explicit cleanup on failure in mce_amd Sebastian Andrzej Siewior 2016-11-16 8:40 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-10 17:44 ` [PATCH 3/7] x86/mcheck: Be prepared for a rollback back to the ONLINE state Sebastian Andrzej Siewior 2016-11-16 8:40 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-10 17:44 ` [PATCH 4/7] x86/mcheck: Split threshold_cpu_callback into two callbacks Sebastian Andrzej Siewior 2016-11-16 8:41 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-10 17:44 ` [PATCH 5/7] x86/mcheck: reorganize the hotplug callbacks Sebastian Andrzej Siewior 2016-11-11 18:44 ` Borislav Petkov 2016-11-11 19:36 ` Sebastian Andrzej Siewior 2016-11-11 19:57 ` Borislav Petkov 2016-11-14 10:47 ` [PATCH 5/7 v2] " Sebastian Andrzej Siewior 2016-11-16 8:41 ` [tip:smp/hotplug] x86/mcheck: Reorganize " tip-bot for Sebastian Andrzej Siewior 2016-11-10 17:44 ` [PATCH 6/7] x86/mcheck: Move CPU_ONLINE and CPU_DOWN_PREPARE to hotplug state machine Sebastian Andrzej Siewior 2016-11-16 8:42 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-10 17:44 ` [PATCH 7/7] x86/mcheck: Move CPU_DEAD " Sebastian Andrzej Siewior 2016-11-11 20:18 ` Borislav Petkov 2016-11-16 8:42 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior 2016-11-10 10:22 ` [PATCH 22/25] x86/mcheck: Do the init in one place Thomas Gleixner 2016-11-10 10:27 ` Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 23/25] x86/mcheck: Make CPU_DOWN_PREPARE the counter part of CPU_STARTING Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 24/25] x86/mcheck: Move CPU_ONLINE to hotplug state machine Sebastian Andrzej Siewior 2016-11-03 14:50 ` [PATCH 25/25] x86/mcheck: Move CPU_DEAD " Sebastian Andrzej Siewior
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20161103145021.28528-15-bigeasy@linutronix.de \ --to=bigeasy@linutronix.de \ --cc=fenghua.yu@intel.com \ --cc=linux-ia64@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=rt@linutronix.de \ --cc=tglx@linutronix.de \ --cc=tony.luck@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.