Skip to contentSkip to conversation

Hot unplug CPU 4/4

PATCH New Rusty Russell 1 participant 1 message Sep 13, 2002

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Hot unplug CPU 4/4

[ Patrick, I put the cpus as root/sys/cpus/0000/xxx, is that OK? ]

[ Ingo, scheduler changes in two places (online checks before pulling
tasks), plus the extraction of common code from migration thread ]

[ Kimio, I added the CPU_DEAD notifier ]

Name: Hotplug CPU Remove Generic Code
Author: Rusty Russell
Status: Experimental
Depends: Hotcpu/set-cpus-can-fail.patch.gz
Depends: Misc/daemonize-reparent.patch.2.5.33.gz

D: This adds the generic infrastructure to allow removing of CPUs
D: in a running kernel.

arch/i386/kernel/smpboot.c +11 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7234-linux-2.5.34/arch/i386/kernel/smpboot.c .7234-linux-2.5.34.updated/arch/i386/kernel/smpboot.c
@@ -1220,6 +1220,17 @@ int __devinit __cpu_up(unsigned int cpu)
 	return 0;
 }
 
+int __cpu_disable(void)
+{
+	return -ENOSYS;
+}
+
+/* Since we fail __cpu_disable, this is never called. */
+void __cpu_die(unsigned int cpu)
+{
+	BUG();
+}
+
 void __init smp_cpus_done(unsigned int max_cpus)
 {
 	zap_low_mappings();
arch/ppc/kernel/smp.c +11 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7234-linux-2.5.34/arch/ppc/kernel/smp.c .7234-linux-2.5.34.updated/arch/ppc/kernel/smp.c
@@ -438,6 +438,17 @@ int __cpu_up(unsigned int cpu)
 	return 0;
 }
 
+int __cpu_disable(unsigned int cpu)
+{
+	return -ENOSYS;
+}
+
+/* Since we fail __cpu_disable, this is never called. */
+void __cpu_die(unsigned int cpu)
+{
+	BUG();
+}
+
 void smp_cpus_done(unsigned int max_cpus)
 {
 	smp_ops->setup_cpu(0);
include/asm-i386/smp.h +3 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7234-linux-2.5.34/include/asm-i386/smp.h .7234-linux-2.5.34.updated/include/asm-i386/smp.h
@@ -123,6 +123,9 @@ static inline int num_booting_cpus(void)
 	return hweight32(cpu_callout_map);
 }
 
+extern int __cpu_disable(void);
+extern void __cpu_die(unsigned int cpu);
+
 #endif /* !__ASSEMBLY__ */
 
 #define NO_PROC_ID		0xFF		/* No processor magic marker */
include/asm-ppc/smp.h +2 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7234-linux-2.5.34/include/asm-ppc/smp.h .7234-linux-2.5.34.updated/include/asm-ppc/smp.h
@@ -68,6 +68,8 @@ static inline int any_online_cpu(const u
 }
 
 extern int __cpu_up(unsigned int cpu);
+extern int __cpu_disable(void);
+extern void __cpu_die(unsigned int cpu);
 
 extern int smp_hw_index[];
 #define hard_smp_processor_id() (smp_hw_index[smp_processor_id()])
include/linux/notifier.h +2 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7234-linux-2.5.34/include/linux/notifier.h .7234-linux-2.5.34.updated/include/linux/notifier.h
@@ -60,7 +60,9 @@ extern int notifier_call_chain(struct no
 
 #define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
 
+#define CPU_OFFLINE	0x0001 /* CPU (unsigned)v going down */
 #define CPU_ONLINE	0x0002 /* CPU (unsigned)v coming up */
+#define CPU_DEAD	0x0003 /* CPU (unsigned)v dead */
 
 #endif /* __KERNEL__ */
 #endif /* _LINUX_NOTIFIER_H */
include/linux/sched.h +3 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7234-linux-2.5.34/include/linux/sched.h .7234-linux-2.5.34.updated/include/linux/sched.h
@@ -431,6 +431,9 @@ do { if (atomic_dec_and_test(&(tsk)->usa
 
 #if CONFIG_SMP
 extern int set_cpus_allowed(task_t *p, const unsigned long new_mask[]);
+#ifdef CONFIG_HOTPLUG
+extern void migrate_all_tasks(void);
+#endif
 #else
 static inline int set_cpus_allowed(struct task_struct *p,
 				   const unsigned long *new_mask)
include/linux/smp.h +5 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7234-linux-2.5.34/include/linux/smp.h .7234-linux-2.5.34.updated/include/linux/smp.h
@@ -78,6 +78,7 @@ extern int register_cpu_notifier(struct 
 extern void unregister_cpu_notifier(struct notifier_block *nb);
 
 int cpu_up(unsigned int cpu);
+int cpu_down(unsigned int cpu);
 #else /* !SMP */
 
 /*
@@ -106,6 +107,10 @@ static inline int register_cpu_notifier(
 static inline void unregister_cpu_notifier(struct notifier_block *nb)
 {
 }
+
+/* Bring a CPU down/up */
+static inline int cpu_down(unsigned int cpu) { return -EBUSY; }
+static inline int cpu_up(unsigned int cpu) { return -ENOSYS; }
 #endif /* !SMP */
 
 #define get_cpu()		({ preempt_disable(); smp_processor_id(); })
kernel/cpu.c +211 -0

231 lines not on this page · raw message

kernel/sched.c +137 -28

207 lines not on this page · raw message

kernel/softirq.c +87 -4

130 lines not on this page · raw message

net/core/dev.c +65 -0

74 lines not on this page · raw message

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.