diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-04-07 05:15:40 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-07 05:15:40 -0400 |
commit | 5e34437840d33554f69380584311743b39e8fbeb (patch) | |
tree | e081135619ee146af5efb9ee883afca950df5757 /kernel/rcupdate.c | |
parent | 77d05632baee21b1cef8730d7c06aa69601e4dca (diff) | |
parent | d508afb437daee7cf07da085b635c44a4ebf9b38 (diff) |
Merge branch 'linus' into core/softlockup
Conflicts:
kernel/sysctl.c
Diffstat (limited to 'kernel/rcupdate.c')
-rw-r--r-- | kernel/rcupdate.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c index d92a76a881aa..2c7b8457d0d2 100644 --- a/kernel/rcupdate.c +++ b/kernel/rcupdate.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/cpu.h> | 44 | #include <linux/cpu.h> |
45 | #include <linux/mutex.h> | 45 | #include <linux/mutex.h> |
46 | #include <linux/module.h> | 46 | #include <linux/module.h> |
47 | #include <linux/kernel_stat.h> | ||
47 | 48 | ||
48 | enum rcu_barrier { | 49 | enum rcu_barrier { |
49 | RCU_BARRIER_STD, | 50 | RCU_BARRIER_STD, |
@@ -55,6 +56,7 @@ static DEFINE_PER_CPU(struct rcu_head, rcu_barrier_head) = {NULL}; | |||
55 | static atomic_t rcu_barrier_cpu_count; | 56 | static atomic_t rcu_barrier_cpu_count; |
56 | static DEFINE_MUTEX(rcu_barrier_mutex); | 57 | static DEFINE_MUTEX(rcu_barrier_mutex); |
57 | static struct completion rcu_barrier_completion; | 58 | static struct completion rcu_barrier_completion; |
59 | int rcu_scheduler_active __read_mostly; | ||
58 | 60 | ||
59 | /* | 61 | /* |
60 | * Awaken the corresponding synchronize_rcu() instance now that a | 62 | * Awaken the corresponding synchronize_rcu() instance now that a |
@@ -80,6 +82,10 @@ void wakeme_after_rcu(struct rcu_head *head) | |||
80 | void synchronize_rcu(void) | 82 | void synchronize_rcu(void) |
81 | { | 83 | { |
82 | struct rcu_synchronize rcu; | 84 | struct rcu_synchronize rcu; |
85 | |||
86 | if (rcu_blocking_is_gp()) | ||
87 | return; | ||
88 | |||
83 | init_completion(&rcu.completion); | 89 | init_completion(&rcu.completion); |
84 | /* Will wake me after RCU finished. */ | 90 | /* Will wake me after RCU finished. */ |
85 | call_rcu(&rcu.head, wakeme_after_rcu); | 91 | call_rcu(&rcu.head, wakeme_after_rcu); |
@@ -116,6 +122,8 @@ static void rcu_barrier_func(void *type) | |||
116 | } | 122 | } |
117 | } | 123 | } |
118 | 124 | ||
125 | static inline void wait_migrated_callbacks(void); | ||
126 | |||
119 | /* | 127 | /* |
120 | * Orchestrate the specified type of RCU barrier, waiting for all | 128 | * Orchestrate the specified type of RCU barrier, waiting for all |
121 | * RCU callbacks of the specified type to complete. | 129 | * RCU callbacks of the specified type to complete. |
@@ -141,6 +149,7 @@ static void _rcu_barrier(enum rcu_barrier type) | |||
141 | complete(&rcu_barrier_completion); | 149 | complete(&rcu_barrier_completion); |
142 | wait_for_completion(&rcu_barrier_completion); | 150 | wait_for_completion(&rcu_barrier_completion); |
143 | mutex_unlock(&rcu_barrier_mutex); | 151 | mutex_unlock(&rcu_barrier_mutex); |
152 | wait_migrated_callbacks(); | ||
144 | } | 153 | } |
145 | 154 | ||
146 | /** | 155 | /** |
@@ -170,8 +179,55 @@ void rcu_barrier_sched(void) | |||
170 | } | 179 | } |
171 | EXPORT_SYMBOL_GPL(rcu_barrier_sched); | 180 | EXPORT_SYMBOL_GPL(rcu_barrier_sched); |
172 | 181 | ||
182 | static atomic_t rcu_migrate_type_count = ATOMIC_INIT(0); | ||
183 | static struct rcu_head rcu_migrate_head[3]; | ||
184 | static DECLARE_WAIT_QUEUE_HEAD(rcu_migrate_wq); | ||
185 | |||
186 | static void rcu_migrate_callback(struct rcu_head *notused) | ||
187 | { | ||
188 | if (atomic_dec_and_test(&rcu_migrate_type_count)) | ||
189 | wake_up(&rcu_migrate_wq); | ||
190 | } | ||
191 | |||
192 | static inline void wait_migrated_callbacks(void) | ||
193 | { | ||
194 | wait_event(rcu_migrate_wq, !atomic_read(&rcu_migrate_type_count)); | ||
195 | } | ||
196 | |||
197 | static int __cpuinit rcu_barrier_cpu_hotplug(struct notifier_block *self, | ||
198 | unsigned long action, void *hcpu) | ||
199 | { | ||
200 | if (action == CPU_DYING) { | ||
201 | /* | ||
202 | * preempt_disable() in on_each_cpu() prevents stop_machine(), | ||
203 | * so when "on_each_cpu(rcu_barrier_func, (void *)type, 1);" | ||
204 | * returns, all online cpus have queued rcu_barrier_func(), | ||
205 | * and the dead cpu(if it exist) queues rcu_migrate_callback()s. | ||
206 | * | ||
207 | * These callbacks ensure _rcu_barrier() waits for all | ||
208 | * RCU callbacks of the specified type to complete. | ||
209 | */ | ||
210 | atomic_set(&rcu_migrate_type_count, 3); | ||
211 | call_rcu_bh(rcu_migrate_head, rcu_migrate_callback); | ||
212 | call_rcu_sched(rcu_migrate_head + 1, rcu_migrate_callback); | ||
213 | call_rcu(rcu_migrate_head + 2, rcu_migrate_callback); | ||
214 | } else if (action == CPU_POST_DEAD) { | ||
215 | /* rcu_migrate_head is protected by cpu_add_remove_lock */ | ||
216 | wait_migrated_callbacks(); | ||
217 | } | ||
218 | |||
219 | return NOTIFY_OK; | ||
220 | } | ||
221 | |||
173 | void __init rcu_init(void) | 222 | void __init rcu_init(void) |
174 | { | 223 | { |
175 | __rcu_init(); | 224 | __rcu_init(); |
225 | hotcpu_notifier(rcu_barrier_cpu_hotplug, 0); | ||
176 | } | 226 | } |
177 | 227 | ||
228 | void rcu_scheduler_starting(void) | ||
229 | { | ||
230 | WARN_ON(num_online_cpus() != 1); | ||
231 | WARN_ON(nr_context_switches() > 0); | ||
232 | rcu_scheduler_active = 1; | ||
233 | } | ||