Skip to contentSkip to conversation

HotPlug CPU patch against 2.4.5

ANNOUNCE Rusty Russell 4 participants 5 messages Jun 16, 2001 – Jun 26, 2001

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

Hi all,

http://sourceforge.net/projects/lhcs/

Version 0.3 (untested) of the HotPlug CPU Patch is out, with
ia64 and x86 support. Bringing CPUs down and up is as simple as:

	# Down...
	echo 0 > /proc/sys/cpu/1
	# Up...
	echo 1 > /proc/sys/cpu/1

	Apologies for the slow release, and *huge* kudos to the people

who did the real work for this release:

Kimio Suganuma (ia64)
Jason McMullan (x86)

Thanks!
Rusty.
--
Premature optmztion is rt of all evl. --DK

#1 lore raw
Quoted 11 lines · In article <m15BG8K-001UIwC@mozart> you wrote:

Hi all,

http://sourceforge.net/projects/lhcs/

Version 0.3 (untested) of the HotPlug CPU Patch is out, with
ia64 and x86 support. Bringing CPUs down and up is as simple as:

	# Down...
	echo 0 > /proc/sys/cpu/1
	# Up...
	echo 1 > /proc/sys/cpu/1

Wouldn't /proc/sys/cpu/<num>/enable be better? This way other per-cpu sysctls could be added more easily...

</nitpick>

Christoph

Signature · 1 line
Of course it doesn't work. We've performed a software upgrade.
#2 lore raw

In message <[email protected]> you write:

Quoted 6 lines
Quoted 2 lines · In article <m15BG8K-001UIwC@mozart> you wrote:
	# Up...
	echo 1 > /proc/sys/cpu/1

Wouldn't /proc/sys/cpu/<num>/enable be better? This way other per-cpu sysctls could be added more easily...

Yep. But rewrite the sysctl crap first to make dynamically adding and deleting entries sane.

Cheers,
Rusty.
--
Premature optmztion is rt of all evl. --DK

#3 lore raw
Quoted 10 lines · Rusty Russell

In message <[email protected]> you write:

Quoted 6 lines
Quoted 2 lines · In article <m15BG8K-001UIwC@mozart> you wrote:
	# Up...
	echo 1 > /proc/sys/cpu/1

Wouldn't /proc/sys/cpu/<num>/enable be better? This way other per-cpu sysctls could be added more easily...

Yep. But rewrite the sysctl crap first to make dynamically adding and deleting entries sane.

I had, actually. 2.5 stuff, but as soon as fs/super.c merge gets into the sane area I'll see what can be safely merged into 2.4. Sorry - it touches quite a few places and running two splitups in parallel... <shudder> As soon as this fscking roll of barbwire^W^W^Wset of locking changes gets untangled...

#4 lore raw
In reply to Rusty Russell
Quoted 6 lines · Rusty Russell

Hi all,

http://sourceforge.net/projects/lhcs/

Version 0.3 (untested) of the HotPlug CPU Patch is out, with
ia64 and x86 support.

Here's a patch to the patch that adds /sbin/hotplug support (sorry, I couldn't resist...)

It also fixes a '}' problem in fs/proc/proc_misc.c

thanks,

greg k-h

fs/proc/proc_misc.c +1 -0
diff -Naur -X /home/greg/linux/dontdiff linux-2.4.5-hotplug/fs/proc/proc_misc.c linux-2.4.5-hotplug-greg/fs/proc/proc_misc.c
@@ -295,6 +295,7 @@
 			jif - (  kstat.per_cpu_user[i] \
 			           + kstat.per_cpu_nice[i] \
 			           + kstat.per_cpu_system[i]));
+	}
 	len += sprintf(page + len,
 		"page %u %u\n"
                 "swap %u %u\n"
kernel/cpu.c +37 -0
diff -Naur -X /home/greg/linux/dontdiff linux-2.4.5-hotplug/kernel/cpu.c linux-2.4.5-hotplug-greg/kernel/cpu.c
@@ -8,6 +8,7 @@
 #include <linux/notifier.h>
 #include <linux/sched.h>
 #include <linux/sched.h>
+#include <linux/kmod.h>		/* for hotplug_path */
 #include <asm/semaphore.h>
 #include <asm/uaccess.h>
 
@@ -17,6 +18,38 @@
 
 static struct notifier_block *cpu_chain = NULL;
 
+#ifdef CONFIG_HOTPLUG
+/* Notify userspace when a cpu event occurs,
+ * by running '/sbin/hotplug cpu' with certain
+ * environment variables set.
+ */
+static int cpu_run_sbin_hotplug(unsigned int cpu, char *action)
+{
+	char *argv[3], *envp[5], cpu_str[12], action_str[32];
+	int i;
+
+	sprintf(cpu_str, "CPU=%d", cpu);
+	sprintf(action_str, "ACTION=%s", action);
+
+	i = 0;
+	argv[i++] = hotplug_path;
+	argv[i++] = "cpu";
+	argv[i] = 0;
+
+	i = 0;
+	/* minimal command environment */
+	envp [i++] = "HOME=/";
+	envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
+	envp [i++] = cpu_str;
+	envp [i++] = action_str;
+	envp [i] = 0;
+
+	return call_usermodehelper(argv [0], argv, envp);
+}
+#else
+#define cpu_run_sbin_hotplug(cpu, action) ({ 0; })
+#endif
+
 /* Should really be in a header somewhere. */
 asmlinkage long sys_sched_get_priority_max(int policy);
 
@@ -120,6 +153,8 @@
 	/* Die, CPU, die! */
 	__cpu_die(cpu);
 
+	cpu_run_sbin_hotplug(cpu, "remove");
+
  out:
 	up(&cpucontrol);
 	return ret;
@@ -145,6 +180,8 @@
 	/* Friendly to make sure everyone knows it's up before we
 	   return */
 	__synchronize_kernel();
+
+	cpu_run_sbin_hotplug(cpu, "add");
 
  out:
 	up(&cpucontrol);