From: "Jan Beulich" Subject: [PATCH 4/7] move register_cpu_notifier() into .init.text Date: Thu, 31 Mar 2011 16:56:12 +0100 Message-ID: <4D94C03C02000078000396C5@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part1935CD0C.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part1935CD0C.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 --- a/xen/arch/x86/nmi.c +++ b/xen/arch/x86/nmi.c @@ -389,12 +389,12 @@ void watchdog_disable(void) =20 void watchdog_enable(void) { - static unsigned long heartbeat_initialised; - unsigned int cpu; + atomic_dec(&watchdog_disable_count); +} =20 - if ( !atomic_dec_and_test(&watchdog_disable_count) || - test_and_set_bit(0, &heartbeat_initialised) ) - return; +void __init watchdog_setup(void) +{ + unsigned int cpu; =20 /* * Activate periodic heartbeats. We cannot do this earlier during=20 @@ -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(); } =20 void nmi_watchdog_tick(struct cpu_user_regs * regs) --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1259,7 +1259,7 @@ void __init __start_xen(unsigned long mb do_initcalls(); =20 if ( opt_watchdog )=20 - watchdog_enable(); + watchdog_setup(); =20 if ( !tboot_protect_mem_regions() ) panic("Could not protect TXT memory regions\n"); --- a/xen/common/cpu.c +++ b/xen/common/cpu.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include =20 @@ -53,7 +54,7 @@ void cpu_hotplug_done(void) =20 static NOTIFIER_HEAD(cpu_chain); =20 -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. */ --- a/xen/common/notifier.c +++ b/xen/common/notifier.c @@ -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 =3D &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); --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -66,7 +66,6 @@ static const struct scheduler *scheduler &sched_credit_def, &sched_credit2_def, &sched_arinc653_def, - NULL }; =20 static struct scheduler __read_mostly ops; @@ -1324,17 +1323,25 @@ void __init scheduler_init(void) =20 open_softirq(SCHEDULE_SOFTIRQ, schedule); =20 - for ( i =3D 0; schedulers[i] !=3D NULL; i++ ) + for ( i =3D 0; i < ARRAY_SIZE(schedulers); i++ ) { - ops =3D *schedulers[i]; - if ( strcmp(ops.opt_name, opt_sched) =3D=3D 0 ) - break; + if ( schedulers[i]->global_init && schedulers[i]->global_init() < = 0 ) + schedulers[i] =3D NULL; + else if ( !ops.name && !strcmp(schedulers[i]->opt_name, opt_sched)= ) + ops =3D *schedulers[i]; } =20 - if ( schedulers[i] =3D=3D NULL ) + if ( !ops.name ) { printk("Could not find scheduler: %s\n", opt_sched); - ops =3D *schedulers[0]; + for ( i =3D 0; i < ARRAY_SIZE(schedulers); i++ ) + if ( schedulers[i] ) + { + ops =3D *schedulers[i]; + break; + } + BUG_ON(!ops.name); + printk("Using '%s' (%s)\n", ops.name, ops.opt_name); } =20 if ( cpu_schedule_up(0) ) @@ -1407,8 +1414,8 @@ struct scheduler *scheduler_alloc(unsign int i; struct scheduler *sched; =20 - for ( i =3D 0; schedulers[i] !=3D NULL; i++ ) - if ( schedulers[i]->sched_id =3D=3D sched_id ) + for ( i =3D 0; i < ARRAY_SIZE(schedulers); i++ ) + if ( schedulers[i] && schedulers[i]->sched_id =3D=3D sched_id ) goto found; *perr =3D -ENOENT; return NULL; --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -2010,7 +2010,8 @@ csched_cpu_starting(int cpu) /* Hope this is safe from cpupools switching things around. :-) */ ops =3D per_cpu(scheduler, cpu); =20 - init_pcpu(ops, cpu); + if ( ops->alloc_pdata =3D=3D csched_alloc_pdata ) + init_pcpu(ops, cpu); =20 return NOTIFY_DONE; } @@ -2038,6 +2039,13 @@ static struct notifier_block cpu_credit2 }; =20 static int +csched_global_init(void) +{ + register_cpu_notifier(&cpu_credit2_nfb); + return 0; +} + +static int csched_init(struct scheduler *ops) { int i; @@ -2070,8 +2078,6 @@ csched_init(struct scheduler *ops) spin_lock_init(&prv->lock); INIT_LIST_HEAD(&prv->sdom); =20 - register_cpu_notifier(&cpu_credit2_nfb); - /* But un-initialize all runqueues */ for ( i=3D0; i=0A=0A--- a/xen/arch/x86/nmi.c=0A+= ++ b/xen/arch/x86/nmi.c=0A@@ -389,12 +389,12 @@ void watchdog_disable(void)= =0A =0A void watchdog_enable(void)=0A {=0A- static unsigned long = heartbeat_initialised;=0A- unsigned int cpu;=0A+ atomic_dec(&watchdog= _disable_count);=0A+}=0A =0A- if ( !atomic_dec_and_test(&watchdog_disabl= e_count) ||=0A- test_and_set_bit(0, &heartbeat_initialised) )=0A- = return;=0A+void __init watchdog_setup(void)=0A+{=0A+ unsigned int = cpu;=0A =0A /*=0A * Activate periodic heartbeats. We cannot do = this earlier during =0A@@ -403,6 +403,8 @@ void watchdog_enable(void)=0A = for_each_online_cpu ( cpu )=0A cpu_nmi_callback(&cpu_nmi_nfb, = CPU_UP_PREPARE, (void *)(long)cpu);=0A register_cpu_notifier(&cpu_nmi_n= fb);=0A+=0A+ watchdog_enable();=0A }=0A =0A void nmi_watchdog_tick(struc= t cpu_user_regs * regs)=0A--- a/xen/arch/x86/setup.c=0A+++ b/xen/arch/x86/s= etup.c=0A@@ -1259,7 +1259,7 @@ void __init __start_xen(unsigned long mb=0A = do_initcalls();=0A =0A if ( opt_watchdog ) =0A- watchdog_ena= ble();=0A+ watchdog_setup();=0A =0A if ( !tboot_protect_mem_= regions() )=0A panic("Could not protect TXT memory regions\n");=0A-= -- a/xen/common/cpu.c=0A+++ b/xen/common/cpu.c=0A@@ -2,6 +2,7 @@=0A = #include =0A #include =0A #include = =0A+#include =0A #include =0A #include =0A =0A@@ -53,7 +54,7 @@ void cpu_hotplug_done(void)=0A =0A = static NOTIFIER_HEAD(cpu_chain);=0A =0A-void register_cpu_notifier(struct = notifier_block *nb)=0A+void __init register_cpu_notifier(struct notifier_bl= ock *nb)=0A {=0A if ( !spin_trylock(&cpu_add_remove_lock) )=0A = BUG(); /* Should never fail as we are called only during boot. */=0A--- = a/xen/common/notifier.c=0A+++ b/xen/common/notifier.c=0A@@ -19,7 +19,7 = @@=0A * Adds a notifier to a raw notifier chain.=0A * All locking must = be provided by the caller.=0A */=0A-void notifier_chain_register(=0A+void = __init notifier_chain_register(=0A struct notifier_head *nh, struct = notifier_block *n)=0A {=0A struct list_head *chain =3D &nh->head.chain;= =0A@@ -44,7 +44,7 @@ void notifier_chain_register(=0A * Removes a = notifier from a raw notifier chain.=0A * All locking must be provided by = the caller.=0A */=0A-void notifier_chain_unregister(=0A+void __init = notifier_chain_unregister(=0A struct notifier_head *nh, struct = notifier_block *n)=0A {=0A list_del(&n->chain);=0A--- a/xen/common/sche= dule.c=0A+++ b/xen/common/schedule.c=0A@@ -66,7 +66,6 @@ static const = struct scheduler *scheduler=0A &sched_credit_def,=0A &sched_credit2= _def,=0A &sched_arinc653_def,=0A- NULL=0A };=0A =0A static struct = scheduler __read_mostly ops;=0A@@ -1324,17 +1323,25 @@ void __init = scheduler_init(void)=0A =0A open_softirq(SCHEDULE_SOFTIRQ, schedule);= =0A =0A- for ( i =3D 0; schedulers[i] !=3D NULL; i++ )=0A+ for ( i = =3D 0; i < ARRAY_SIZE(schedulers); i++ )=0A {=0A- ops =3D = *schedulers[i];=0A- if ( strcmp(ops.opt_name, opt_sched) =3D=3D 0 = )=0A- break;=0A+ if ( schedulers[i]->global_init && = schedulers[i]->global_init() < 0 )=0A+ schedulers[i] =3D = NULL;=0A+ else if ( !ops.name && !strcmp(schedulers[i]->opt_name, = opt_sched) )=0A+ ops =3D *schedulers[i];=0A }=0A =0A- if = ( schedulers[i] =3D=3D NULL )=0A+ if ( !ops.name )=0A {=0A = printk("Could not find scheduler: %s\n", opt_sched);=0A- ops =3D = *schedulers[0];=0A+ for ( i =3D 0; i < ARRAY_SIZE(schedulers); i++ = )=0A+ if ( schedulers[i] )=0A+ {=0A+ = ops =3D *schedulers[i];=0A+ break;=0A+ }=0A+ = BUG_ON(!ops.name);=0A+ printk("Using '%s' (%s)\n", ops.name, = ops.opt_name);=0A }=0A =0A if ( cpu_schedule_up(0) )=0A@@ -1407,8 = +1414,8 @@ struct scheduler *scheduler_alloc(unsign=0A int i;=0A = struct scheduler *sched;=0A =0A- for ( i =3D 0; schedulers[i] !=3D = NULL; i++ )=0A- if ( schedulers[i]->sched_id =3D=3D sched_id )=0A+ = for ( i =3D 0; i < ARRAY_SIZE(schedulers); i++ )=0A+ if ( = schedulers[i] && schedulers[i]->sched_id =3D=3D sched_id )=0A = goto found;=0A *perr =3D -ENOENT;=0A return NULL;=0A--- a/xen/commo= n/sched_credit2.c=0A+++ b/xen/common/sched_credit2.c=0A@@ -2010,7 +2010,8 = @@ csched_cpu_starting(int cpu)=0A /* Hope this is safe from cpupools = switching things around. :-) */=0A ops =3D per_cpu(scheduler, cpu);=0A = =0A- init_pcpu(ops, cpu);=0A+ if ( ops->alloc_pdata =3D=3D csched_all= oc_pdata )=0A+ init_pcpu(ops, cpu);=0A =0A return NOTIFY_DONE;= =0A }=0A@@ -2038,6 +2039,13 @@ static struct notifier_block cpu_credit2=0A = };=0A =0A static int=0A+csched_global_init(void)=0A+{=0A+ register_cpu_n= otifier(&cpu_credit2_nfb);=0A+ return 0;=0A+}=0A+=0A+static int=0A = csched_init(struct scheduler *ops)=0A {=0A int i;=0A@@ -2070,8 +2078,6 = @@ csched_init(struct scheduler *ops)=0A spin_lock_init(&prv->lock);=0A= INIT_LIST_HEAD(&prv->sdom);=0A =0A- register_cpu_notifier(&cpu_cred= it2_nfb);=0A-=0A /* But un-initialize all runqueues */=0A for ( = i=3D0; i