8/9: ckrm_cpu_hotplug

Adds cpu hotplug notifier for the CKRM CPU controller.

Signed-off-by: MAEDA Naoaki <[EMAIL PROTECTED]>
Signed-off-by: Kurosawa Takahiro <[EMAIL PROTECTED]>

 kernel/ckrm/ckrm_cpu.c |   50 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+)

Index: linux-2.6.17-rc2/kernel/ckrm/ckrm_cpu.c
===================================================================
--- linux-2.6.17-rc2.orig/kernel/ckrm/ckrm_cpu.c
+++ linux-2.6.17-rc2/kernel/ckrm/ckrm_cpu.c
@@ -243,12 +243,61 @@ struct ckrm_controller cpu_ctlr = {
        .show_stats = cpu_show_stats,
 };
 
+static void clear_stat_and_propagate(struct ckrm_cpu * res, int cpu)
+{
+       struct ckrm_class *child = NULL;
+       struct ckrm_cpu *childres;
+
+       cpu_rc_clear_stat(&res->cpu_rc, cpu);
+
+       /* propagate to children */
+       spin_lock(&res->class->class_lock);
+       for_each_child(child, res->class) {
+               childres = get_class_cpu(child);
+               if (childres) {
+                   spin_lock(&child->class_lock);
+                   clear_stat_and_propagate(childres, cpu);
+                   spin_unlock(&child->class_lock);
+               }
+       }
+       spin_unlock(&res->class->class_lock);
+}
+
+static int __devinit ckrm_cpu_notify(struct notifier_block *self,
+                               unsigned long action, void *hcpu)
+{
+       struct ckrm_class *cls = &ckrm_default_class;
+       struct ckrm_cpu *res;
+       int     cpu = (long) hcpu;
+
+       switch (action) {
+
+       case CPU_DEAD:
+               res = get_class_cpu(cls);
+               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 ckrm_cpu_nb = {
+       .notifier_call  = ckrm_cpu_notify,
+};
+
 int __init init_ckrm_cpu_res(void)
 {
        if (cpu_ctlr.ctlr_id != CKRM_NO_RES_ID)
                return -EBUSY; /* already registered */
        cpu_rc_init_rcd(&grcd);
        printk(KERN_INFO "init_ckrm_cpu_res %d cpus available\n", grcd.numcpus);
+       /* Register notifier for non-boot CPUs */
+       register_cpu_notifier(&ckrm_cpu_nb);
        return ckrm_register_controller(&cpu_ctlr);
 }
 
@@ -259,6 +308,7 @@ void __exit exit_ckrm_cpu_res(void)
                rc = ckrm_unregister_controller(&cpu_ctlr);
        } while (rc == -EBUSY);
        BUG_ON(rc != 0);
+       unregister_cpu_notifier(&ckrm_cpu_nb);
 }
 
 module_init(init_ckrm_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

Reply via email to