]> xenbits.xensource.com Git - xen.git/commitdiff
move register_cpu_notifier() into .init.text
authorJan Beulich <jbeulich@novell.com>
Sat, 2 Apr 2011 14:57:03 +0000 (15:57 +0100)
committerJan Beulich <jbeulich@novell.com>
Sat, 2 Apr 2011 14:57:03 +0000 (15:57 +0100)
With no modular drivers, all CPU notifier setup is supposed to happen
during boot. There also is a respective comment in the function.=20

Signed-off-by: Jan Beulich <jbeulich@novell.com>
xen/arch/x86/nmi.c
xen/arch/x86/setup.c
xen/common/cpu.c
xen/common/notifier.c
xen/common/sched_credit2.c
xen/common/schedule.c
xen/include/asm-x86/config.h
xen/include/xen/sched-if.h

index f3155e8b762aadae8ebbf3eae76a04e5b4745fd9..6730f29a0ab0700c73f375b2fe339c3db7b15c5c 100644 (file)
@@ -389,12 +389,12 @@ void watchdog_disable(void)
 
 void watchdog_enable(void)
 {
-    static unsigned long heartbeat_initialised;
-    unsigned int cpu;
+    atomic_dec(&watchdog_disable_count);
+}
 
-    if ( !atomic_dec_and_test(&watchdog_disable_count) ||
-         test_and_set_bit(0, &heartbeat_initialised) )
-        return;
+void __init watchdog_setup(void)
+{
+    unsigned int cpu;
 
     /*
      * Activate periodic heartbeats. We cannot do this earlier during 
@@ -403,6 +403,8 @@ void watchdog_enable(void)
     for_each_online_cpu ( cpu )
         cpu_nmi_callback(&cpu_nmi_nfb, CPU_UP_PREPARE, (void *)(long)cpu);
     register_cpu_notifier(&cpu_nmi_nfb);
+
+    watchdog_enable();
 }
 
 void nmi_watchdog_tick(struct cpu_user_regs * regs)
index 0478079dbc58c2911cac17242db5b7fc9e8aa731..de28445b6e0bd78a6ef6fed9eb7ce0a48f3d2c30 100644 (file)
@@ -1259,7 +1259,7 @@ void __init __start_xen(unsigned long mbi_p)
     do_initcalls();
 
     if ( opt_watchdog ) 
-        watchdog_enable();
+        watchdog_setup();
     
     if ( !tboot_protect_mem_regions() )
         panic("Could not protect TXT memory regions\n");
index 5cdfd0fb1064a967fe8995364cdbfebb96a451b2..396eb58ad8ceb92e153ae2e170ca2f108ad7acfa 100644 (file)
@@ -2,6 +2,7 @@
 #include <xen/cpumask.h>
 #include <xen/cpu.h>
 #include <xen/event.h>
+#include <xen/init.h>
 #include <xen/sched.h>
 #include <xen/stop_machine.h>
 
@@ -53,7 +54,7 @@ void cpu_hotplug_done(void)
 
 static NOTIFIER_HEAD(cpu_chain);
 
-void register_cpu_notifier(struct notifier_block *nb)
+void __init register_cpu_notifier(struct notifier_block *nb)
 {
     if ( !spin_trylock(&cpu_add_remove_lock) )
         BUG(); /* Should never fail as we are called only during boot. */
index ea1ebdeffe1284ee66eb1df5c42ece45adb62b0b..5924b56deb7c3a4049b4ab0a6d260f5f84fa6bb1 100644 (file)
@@ -19,7 +19,7 @@
  * Adds a notifier to a raw notifier chain.
  * All locking must be provided by the caller.
  */
-void notifier_chain_register(
+void __init notifier_chain_register(
     struct notifier_head *nh, struct notifier_block *n)
 {
     struct list_head *chain = &nh->head.chain;
@@ -44,7 +44,7 @@ void notifier_chain_register(
  * Removes a notifier from a raw notifier chain.
  * All locking must be provided by the caller.
  */
-void notifier_chain_unregister(
+void __init notifier_chain_unregister(
     struct notifier_head *nh, struct notifier_block *n)
 {
     list_del(&n->chain);
index 12810c3ba4ca53ef1c08cbb25c205455a0b753f1..792d6625751e033e9df622aa3e13bb227f3532fc 100644 (file)
@@ -2010,7 +2010,8 @@ csched_cpu_starting(int cpu)
     /* Hope this is safe from cpupools switching things around. :-) */
     ops = per_cpu(scheduler, cpu);
 
-    init_pcpu(ops, cpu);
+    if ( ops->alloc_pdata == csched_alloc_pdata )
+        init_pcpu(ops, cpu);
 
     return NOTIFY_DONE;
 }
@@ -2037,6 +2038,13 @@ static struct notifier_block cpu_credit2_nfb = {
     .notifier_call = cpu_credit2_callback
 };
 
+static int
+csched_global_init(void)
+{
+    register_cpu_notifier(&cpu_credit2_nfb);
+    return 0;
+}
+
 static int
 csched_init(struct scheduler *ops)
 {
@@ -2070,8 +2078,6 @@ csched_init(struct scheduler *ops)
     spin_lock_init(&prv->lock);
     INIT_LIST_HEAD(&prv->sdom);
 
-    register_cpu_notifier(&cpu_credit2_nfb);
-
     /* But un-initialize all runqueues */
     for ( i=0; i<NR_CPUS; i++)
     {
@@ -2120,6 +2126,7 @@ const struct scheduler sched_credit2_def = {
 
     .dump_cpu_state = csched_dump_pcpu,
     .dump_settings  = csched_dump,
+    .global_init    = csched_global_init,
     .init           = csched_init,
     .deinit         = csched_deinit,
     .alloc_vdata    = csched_alloc_vdata,
index 129abe44e4b3c0a44ab903842c3e41632413eb1a..5efb822a816877040fd50831139edfdcfc5ddf91 100644 (file)
@@ -66,7 +66,6 @@ static const struct scheduler *schedulers[] = {
     &sched_credit_def,
     &sched_credit2_def,
     &sched_arinc653_def,
-    NULL
 };
 
 static struct scheduler __read_mostly ops;
@@ -1324,17 +1323,25 @@ void __init scheduler_init(void)
 
     open_softirq(SCHEDULE_SOFTIRQ, schedule);
 
-    for ( i = 0; schedulers[i] != NULL; i++ )
+    for ( i = 0; i < ARRAY_SIZE(schedulers); i++ )
     {
-        ops = *schedulers[i];
-        if ( strcmp(ops.opt_name, opt_sched) == 0 )
-            break;
+        if ( schedulers[i]->global_init && schedulers[i]->global_init() < 0 )
+            schedulers[i] = NULL;
+        else if ( !ops.name && !strcmp(schedulers[i]->opt_name, opt_sched) )
+            ops = *schedulers[i];
     }
 
-    if ( schedulers[i] == NULL )
+    if ( !ops.name )
     {
         printk("Could not find scheduler: %s\n", opt_sched);
-        ops = *schedulers[0];
+        for ( i = 0; i < ARRAY_SIZE(schedulers); i++ )
+            if ( schedulers[i] )
+            {
+                ops = *schedulers[i];
+                break;
+            }
+        BUG_ON(!ops.name);
+        printk("Using '%s' (%s)\n", ops.name, ops.opt_name);
     }
 
     if ( cpu_schedule_up(0) )
@@ -1407,8 +1414,8 @@ struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr)
     int i;
     struct scheduler *sched;
 
-    for ( i = 0; schedulers[i] != NULL; i++ )
-        if ( schedulers[i]->sched_id == sched_id )
+    for ( i = 0; i < ARRAY_SIZE(schedulers); i++ )
+        if ( schedulers[i] && schedulers[i]->sched_id == sched_id )
             goto found;
     *perr = -ENOENT;
     return NULL;
index 27c766d2db823dba4198669522824b5d060cbd36..e3a7868caaa7524803ccdb3abdc86d4d739747ec 100644 (file)
@@ -393,6 +393,7 @@ extern unsigned long xenheap_phys_end;
 #ifndef __ASSEMBLY__
 extern void watchdog_disable(void);
 extern void watchdog_enable(void);
+extern void watchdog_setup(void);
 #endif
 
 #endif /* __X86_CONFIG_H__ */
index e8f0262a6bf15f968be67e20a309ef12a36ba98d..486b9fd704a1e505f99956da1f04a13292fc7e91 100644 (file)
@@ -141,6 +141,8 @@ struct scheduler {
     unsigned int sched_id;  /* ID for this scheduler             */
     void *sched_data;       /* global data pointer               */
 
+    int          (*global_init)    (void);
+
     int          (*init)           (struct scheduler *);
     void         (*deinit)         (const struct scheduler *);