8/9: cpu_hotplug
Adds cpu hotplug notifier for the Resouce Groups CPU controller.
Signed-off-by: MAEDA Naoaki <[EMAIL PROTECTED]>
Signed-off-by: Kurosawa Takahiro <[EMAIL PROTECTED]>
kernel/res_group/cpu.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+)
Index: linux-2.6.17-rc3/kernel/res_group/cpu.c
===================================================================
--- linux-2.6.17-rc3.orig/kernel/res_group/cpu.c
+++ linux-2.6.17-rc3/kernel/res_group/cpu.c
@@ -231,6 +231,50 @@ static ssize_t cpu_show_stats(struct res
return i;
}
+static void clear_stat_and_propagate(struct cpu_res * res, int cpu)
+{
+ struct resource_group *child = NULL;
+ struct cpu_res *childres;
+
+ cpu_rc_clear_stat(&res->cpu_rc, cpu);
+
+ /* propagate to children */
+ spin_lock(&res->rgroup->group_lock);
+ for_each_child(child, res->rgroup) {
+ childres = get_res_group_cpu(child);
+ if (childres)
+ clear_stat_and_propagate(childres, cpu);
+ }
+ spin_unlock(&res->rgroup->group_lock);
+}
+
+static int __devinit cpu_notify(struct notifier_block *self,
+ unsigned long action, void *hcpu)
+{
+ struct resource_group *root = &default_res_group;
+ struct cpu_res *res;
+ int cpu = (long) hcpu;
+
+ switch (action) {
+
+ case CPU_DEAD:
+ res = get_res_group_cpu(root);
+ clear_stat_and_propagate(res, cpu);
+ /* FALL THROUGH */
+ case CPU_ONLINE:
+ grcd.cpus = cpu_online_map;
+ grcd.numcpus = cpus_weight(cpu_online_map);
+ break;
+ default:
+ break;
+ }
+ return NOTIFY_OK;
+}
+
+static struct notifier_block cpu_nb = {
+ .notifier_call = cpu_notify,
+};
+
struct res_controller cpu_ctlr = {
.name = res_ctlr_name,
.depth_supported = 3,
@@ -246,6 +290,8 @@ int __init init_cpu_res(void)
if (cpu_ctlr.ctlr_id != NO_RES_ID)
return -EBUSY; /* already registered */
cpu_rc_init_rcd(&grcd);
+ /* Register notifier for hot plugged/unplugged CPUs */
+ register_cpu_notifier(&cpu_nb);
return register_controller(&cpu_ctlr);
}
@@ -256,6 +302,7 @@ void __exit exit_cpu_res(void)
rc = unregister_controller(&cpu_ctlr);
} while (rc == -EBUSY);
BUG_ON(rc != 0);
+ unregister_cpu_notifier(&cpu_nb);
}
module_init(init_cpu_res)
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
ckrm-tech mailing list
https://lists.sourceforge.net/lists/listinfo/ckrm-tech