Simplify RCU CPU-hotplug notification
PATCH 1/1 Simplify RCU CPU-hotplug notification
Simplify RCU's CPU-hotplug notifiers so that there is only one notifier. This makes it trivial to provide the ordering guarantee that rcu_barrier() depends on. This change also allows rcu_barrier() to rely on locking wholly contained in _cpu_down(), rather than that of its callers, making the locking more straightforward.
---
rcupdate.c | 8 ++++++-- rcupreempt.c | 22 +++++----------------- rcutree.c | 18 +++++++++--------- 3 files changed, 20 insertions(+), 28 deletions(-)
kernel/rcupdate.c +6 -2
@@ -217,9 +217,13 @@ static void rcu_migrate_callback(struct rcu_head *notused)wake_up (&rcu_migrate_wq); } +extern int rcu_cpu_notify (struct notifier_block *self, +unsigned long action,void *hcpu); +static int __cpuinit rcu_barrier_cpu_hotplug (struct notifier_block *self,unsigned long action,void *hcpu) { +rcu_cpu_notify (self, action, hcpu);if (action ==CPU_DYING ) {/* * preempt_disable() in on_each_cpu() prevents stop_machine(),
@@ -234,7 +238,7 @@ static int __cpuinit rcu_barrier_cpu_hotplug(struct notifier_block *self,call_rcu_bh (rcu_migrate_head, rcu_migrate_callback);call_rcu_sched (rcu_migrate_head +1 , rcu_migrate_callback);call_rcu (rcu_migrate_head +2 , rcu_migrate_callback); - }else if (action ==CPU_POST_DEAD ) { + }else if (action ==CPU_DEAD ) {/* rcu_migrate_head is protected by cpu_add_remove_lock */ wait_migrated_callbacks (); }
@@ -244,8 +248,8 @@ static int __cpuinit rcu_barrier_cpu_hotplug(struct notifier_block *self,void __init rcu_init (void ) { -__rcu_init ();hotcpu_notifier (rcu_barrier_cpu_hotplug,0 ); +__rcu_init (); }void rcu_scheduler_starting (void )
kernel/rcupreempt.c +5 -17
@@ -1417,7 +1417,7 @@ int rcu_pending(int cpu)return 0 ; } -static int __cpuinit rcu_cpu_notify (struct notifier_block *self, +int __cpuinit rcu_cpu_notify (struct notifier_block *self,unsigned long action,void *hcpu) {long cpu = (long )hcpu;
@@ -1439,10 +1439,6 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self,return NOTIFY_OK ; } -static struct notifier_block __cpuinitdata rcu_nb = { - .notifier_call = rcu_cpu_notify, -}; -void __init __rcu_init (void ) {int cpu;
@@ -1471,22 +1467,14 @@ void __init __rcu_init(void) rdp->waitschedtail = &rdp->waitschedlist; rdp->rcu_sched_sleeping =0 ; } -register_cpu_notifier (&rcu_nb);/* -* We don't need protection against CPU-Hotplug here -* since -* a) If a CPU comes online while we are iterating over the -* cpu_online_mask below, we would only end up making a -* duplicate call to rcu_online_cpu() which sets the corresponding -* CPU's mask in the rcu_cpu_online_map. -* -* b) A CPU cannot go offline at this point in time since the user -* does not have access to the sysfs interface, nor do we -* suspend the system. +* We don't need protection against CPU-hotplug here because +* this is called early in boot, before either interrupts +* or the scheduler are operational. */ for_each_online_cpu (cpu) -rcu_cpu_notify (&rcu_nb,CPU_UP_PREPARE , (void *)(long ) cpu); +rcu_cpu_notify (NULL ,CPU_UP_PREPARE , (void *)(long ) cpu);open_softirq (RCU_SOFTIRQ , rcu_process_callbacks); }
kernel/rcutree.c +9 -9
@@ -1407,13 +1407,12 @@ static void __cpuinit rcu_online_cpu(int cpu) {rcu_init_percpu_data (cpu, &rcu_state);rcu_init_percpu_data (cpu, &rcu_bh_state); -open_softirq (RCU_SOFTIRQ , rcu_process_callbacks); }/* * Handle CPU online/offline notifcation events. */ -static int __cpuinit rcu_cpu_notify (struct notifier_block *self, +int __cpuinit rcu_cpu_notify (struct notifier_block *self,unsigned long action,void *hcpu) {long cpu = (long )hcpu;
@@ -1523,10 +1522,6 @@ do { \ } \ }while (0 ) -static struct notifier_block __cpuinitdata rcu_nb = { - .notifier_call = rcu_cpu_notify, -}; - void __init __rcu_init(void) {int i;/* All used by RCU_DATA_PTR_INIT(). */
@@ -1542,10 +1537,15 @@ void __init __rcu_init(void)rcu_init_one (&rcu_bh_state);RCU_DATA_PTR_INIT (&rcu_bh_state, rcu_bh_data); +/* +* We don't need protection against CPU-hotplug here because +* this is called early in boot, before either interrupts +* or the scheduler are operational. +*/ for_each_online_cpu (i) -rcu_cpu_notify (&rcu_nb,CPU_UP_PREPARE , (void *)(long )i); -/* Register notifier for non-boot CPUs */ -register_cpu_notifier (&rcu_nb); +rcu_cpu_notify (NULL ,CPU_UP_PREPARE , (void *)(long )i); + +open_softirq (RCU_SOFTIRQ , rcu_process_callbacks); }module_param (blimit, int,0 );
[tip:core/rcu] rcu: Simplify RCU CPU-hotplug notification
Commit-ID: 7fe616c5dd50a50f334edec1ea0580b90b7af0d9 Gitweb: http://git.kernel.org/tip/7fe616c5dd50a50f334edec1ea0580b90b7af0d9 Author: Paul E. McKenney <[email protected]> AuthorDate: Thu, 9 Jul 2009 17:48:28 -0700 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 14 Jul 2009 08:16:52 +0200
rcu: Simplify RCU CPU-hotplug notification
Simplify RCU's CPU-hotplug notifiers so that there is only one notifier. This makes it trivial to provide the ordering guarantee that rcu_barrier() depends on. This change also allows rcu_barrier() to rely on locking wholly contained in _cpu_down(), rather than that of its callers, making the locking more straightforward.
LKML-Reference: <[email protected]>
--- kernel/rcupdate.c | 8 ++++++-- kernel/rcupreempt.c | 22 +++++----------------- kernel/rcutree.c | 18 +++++++++--------- 3 files changed, 20 insertions(+), 28 deletions(-)
kernel/rcupdate.c +6 -2
@@ -217,9 +217,13 @@ static void rcu_migrate_callback(struct rcu_head *notused)wake_up (&rcu_migrate_wq); } +extern int rcu_cpu_notify (struct notifier_block *self, +unsigned long action,void *hcpu); +static int __cpuinit rcu_barrier_cpu_hotplug (struct notifier_block *self,unsigned long action,void *hcpu) { +rcu_cpu_notify (self, action, hcpu);if (action ==CPU_DYING ) {/* * preempt_disable() in on_each_cpu() prevents stop_machine(),
@@ -234,7 +238,7 @@ static int __cpuinit rcu_barrier_cpu_hotplug(struct notifier_block *self,call_rcu_bh (rcu_migrate_head, rcu_migrate_callback);call_rcu_sched (rcu_migrate_head +1 , rcu_migrate_callback);call_rcu (rcu_migrate_head +2 , rcu_migrate_callback); - }else if (action ==CPU_POST_DEAD ) { + }else if (action ==CPU_DEAD ) {/* rcu_migrate_head is protected by cpu_add_remove_lock */ wait_migrated_callbacks (); }
@@ -244,8 +248,8 @@ static int __cpuinit rcu_barrier_cpu_hotplug(struct notifier_block *self,void __init rcu_init (void ) { -__rcu_init ();hotcpu_notifier (rcu_barrier_cpu_hotplug,0 ); +__rcu_init (); }void rcu_scheduler_starting (void )
kernel/rcupreempt.c +5 -17
@@ -1417,7 +1417,7 @@ int rcu_pending(int cpu)return 0 ; } -static int __cpuinit rcu_cpu_notify (struct notifier_block *self, +int __cpuinit rcu_cpu_notify (struct notifier_block *self,unsigned long action,void *hcpu) {long cpu = (long )hcpu;
@@ -1439,10 +1439,6 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self,return NOTIFY_OK ; } -static struct notifier_block __cpuinitdata rcu_nb = { - .notifier_call = rcu_cpu_notify, -}; -void __init __rcu_init (void ) {int cpu;
@@ -1471,22 +1467,14 @@ void __init __rcu_init(void) rdp->waitschedtail = &rdp->waitschedlist; rdp->rcu_sched_sleeping =0 ; } -register_cpu_notifier (&rcu_nb);/* -* We don't need protection against CPU-Hotplug here -* since -* a) If a CPU comes online while we are iterating over the -* cpu_online_mask below, we would only end up making a -* duplicate call to rcu_online_cpu() which sets the corresponding -* CPU's mask in the rcu_cpu_online_map. -* -* b) A CPU cannot go offline at this point in time since the user -* does not have access to the sysfs interface, nor do we -* suspend the system. +* We don't need protection against CPU-hotplug here because +* this is called early in boot, before either interrupts +* or the scheduler are operational. */ for_each_online_cpu (cpu) -rcu_cpu_notify (&rcu_nb,CPU_UP_PREPARE , (void *)(long ) cpu); +rcu_cpu_notify (NULL ,CPU_UP_PREPARE , (void *)(long ) cpu);open_softirq (RCU_SOFTIRQ , rcu_process_callbacks); }
kernel/rcutree.c +9 -9
@@ -1407,13 +1407,12 @@ static void __cpuinit rcu_online_cpu(int cpu) {rcu_init_percpu_data (cpu, &rcu_state);rcu_init_percpu_data (cpu, &rcu_bh_state); -open_softirq (RCU_SOFTIRQ , rcu_process_callbacks); }/* * Handle CPU online/offline notifcation events. */ -static int __cpuinit rcu_cpu_notify (struct notifier_block *self, +int __cpuinit rcu_cpu_notify (struct notifier_block *self,unsigned long action,void *hcpu) {long cpu = (long )hcpu;
@@ -1523,10 +1522,6 @@ do { \ } \ }while (0 ) -static struct notifier_block __cpuinitdata rcu_nb = { - .notifier_call = rcu_cpu_notify, -}; - void __init __rcu_init(void) {int i;/* All used by RCU_DATA_PTR_INIT(). */
@@ -1542,10 +1537,15 @@ void __init __rcu_init(void)rcu_init_one (&rcu_bh_state);RCU_DATA_PTR_INIT (&rcu_bh_state, rcu_bh_data); +/* +* We don't need protection against CPU-hotplug here because +* this is called early in boot, before either interrupts +* or the scheduler are operational. +*/ for_each_online_cpu (i) -rcu_cpu_notify (&rcu_nb,CPU_UP_PREPARE , (void *)(long )i); -/* Register notifier for non-boot CPUs */ -register_cpu_notifier (&rcu_nb); +rcu_cpu_notify (NULL ,CPU_UP_PREPARE , (void *)(long )i); + +open_softirq (RCU_SOFTIRQ , rcu_process_callbacks); }module_param (blimit, int,0 );