[PATCH 2/3] cpu: add a CPU_DOWN_PREPARE notifier

From: Nick Piggin
Date: Wed Sep 08 2004 - 09:08:52 EST


2/3

Rusty, can I do this?

Add a CPU_DOWN_PREPARE hotplug CPU notifier. This is needed so we can
dettach all sched-domains before a CPU goes down, thus we can build
domains from online cpumasks, and not have to check for the possibility
of a CPU coming up or going down.

Signed-off-by: Nick Piggin <nickpiggin@xxxxxxxxxxxx>


---

linux-2.6-npiggin/include/linux/notifier.h | 9 +++++----
linux-2.6-npiggin/kernel/cpu.c | 9 +++++++++
2 files changed, 14 insertions(+), 4 deletions(-)

diff -puN kernel/cpu.c~hotplug-cpu_down_prepare-notifier kernel/cpu.c
--- linux-2.6/kernel/cpu.c~hotplug-cpu_down_prepare-notifier 2004-09-08 22:39:28.000000000 +1000
+++ linux-2.6-npiggin/kernel/cpu.c 2004-09-08 22:39:28.000000000 +1000
@@ -119,6 +119,15 @@ int cpu_down(unsigned int cpu)
goto out;
}

+ err = notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE,
+ (void *)(long)cpu);
+ if (err == NOTIFY_BAD) {
+ printk("%s: attempt to take down CPU %u failed\n",
+ __FUNCTION__, cpu);
+ err = -EINVAL;
+ goto out;
+ }
+
/* Ensure that we are not runnable on dying cpu */
old_allowed = current->cpus_allowed;
tmp = CPU_MASK_ALL;
diff -puN include/linux/notifier.h~hotplug-cpu_down_prepare-notifier include/linux/notifier.h
--- linux-2.6/include/linux/notifier.h~hotplug-cpu_down_prepare-notifier 2004-09-08 22:39:28.000000000 +1000
+++ linux-2.6-npiggin/include/linux/notifier.h 2004-09-08 22:39:28.000000000 +1000
@@ -60,10 +60,11 @@ extern int notifier_call_chain(struct no

#define NETLINK_URELEASE 0x0001 /* Unicast netlink socket released */

-#define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */
-#define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */
-#define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */
-#define CPU_DEAD 0x0006 /* CPU (unsigned)v dead */
+#define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */
+#define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */
+#define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */
+#define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */
+#define CPU_DEAD 0x0006 /* CPU (unsigned)v dead */

#endif /* __KERNEL__ */
#endif /* _LINUX_NOTIFIER_H */

_