diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-10-29 04:02:15 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-29 04:02:20 -0400 |
commit | 9de09ace8d518141a4375e1d216ab64db4377799 (patch) | |
tree | da8e7a77f4ea91eb3bb73fc6da72ecf8c99e1c16 /kernel | |
parent | 1beee96bae0daf7f491356777c3080cc436950f5 (diff) | |
parent | 6d3f1e12f46a2f9a1bb7e7aa433df8dd31ce5647 (diff) |
Merge branch 'tracing/urgent' into tracing/core
Merge reason: Pick up fixes and move base from -rc1 to -rc5.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/exit.c | 2 | ||||
-rw-r--r-- | kernel/fork.c | 10 | ||||
-rw-r--r-- | kernel/futex.c | 3 | ||||
-rw-r--r-- | kernel/hrtimer.c | 2 | ||||
-rw-r--r-- | kernel/irq/handle.c | 1 | ||||
-rw-r--r-- | kernel/lockdep.c | 20 | ||||
-rw-r--r-- | kernel/mutex-debug.c | 1 | ||||
-rw-r--r-- | kernel/panic.c | 3 | ||||
-rw-r--r-- | kernel/perf_event.c | 282 | ||||
-rw-r--r-- | kernel/power/suspend_test.c | 5 | ||||
-rw-r--r-- | kernel/rcupdate.c | 140 | ||||
-rw-r--r-- | kernel/rcutorture.c | 4 | ||||
-rw-r--r-- | kernel/rcutree.c | 330 | ||||
-rw-r--r-- | kernel/rcutree.h | 86 | ||||
-rw-r--r-- | kernel/rcutree_plugin.h | 103 | ||||
-rw-r--r-- | kernel/rcutree_trace.c | 4 | ||||
-rw-r--r-- | kernel/sched.c | 33 | ||||
-rw-r--r-- | kernel/time/tick-sched.c | 9 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 1 | ||||
-rw-r--r-- | kernel/trace/blktrace.c | 39 | ||||
-rw-r--r-- | kernel/trace/ftrace.c | 2 | ||||
-rw-r--r-- | kernel/trace/kmemtrace.c | 2 | ||||
-rw-r--r-- | kernel/trace/ring_buffer.c | 12 | ||||
-rw-r--r-- | kernel/trace/trace.c | 8 | ||||
-rw-r--r-- | kernel/trace/trace_output.c | 5 | ||||
-rw-r--r-- | kernel/trace/trace_syscalls.c | 4 | ||||
-rw-r--r-- | kernel/workqueue.c | 18 |
27 files changed, 698 insertions, 431 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 5859f598c951..e61891f80123 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -991,8 +991,6 @@ NORET_TYPE void do_exit(long code) | |||
991 | tsk->mempolicy = NULL; | 991 | tsk->mempolicy = NULL; |
992 | #endif | 992 | #endif |
993 | #ifdef CONFIG_FUTEX | 993 | #ifdef CONFIG_FUTEX |
994 | if (unlikely(!list_empty(&tsk->pi_state_list))) | ||
995 | exit_pi_state_list(tsk); | ||
996 | if (unlikely(current->pi_state_cache)) | 994 | if (unlikely(current->pi_state_cache)) |
997 | kfree(current->pi_state_cache); | 995 | kfree(current->pi_state_cache); |
998 | #endif | 996 | #endif |
diff --git a/kernel/fork.c b/kernel/fork.c index 266c6af6ef1b..4c20fff8c13a 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -570,12 +570,18 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm) | |||
570 | 570 | ||
571 | /* Get rid of any futexes when releasing the mm */ | 571 | /* Get rid of any futexes when releasing the mm */ |
572 | #ifdef CONFIG_FUTEX | 572 | #ifdef CONFIG_FUTEX |
573 | if (unlikely(tsk->robust_list)) | 573 | if (unlikely(tsk->robust_list)) { |
574 | exit_robust_list(tsk); | 574 | exit_robust_list(tsk); |
575 | tsk->robust_list = NULL; | ||
576 | } | ||
575 | #ifdef CONFIG_COMPAT | 577 | #ifdef CONFIG_COMPAT |
576 | if (unlikely(tsk->compat_robust_list)) | 578 | if (unlikely(tsk->compat_robust_list)) { |
577 | compat_exit_robust_list(tsk); | 579 | compat_exit_robust_list(tsk); |
580 | tsk->compat_robust_list = NULL; | ||
581 | } | ||
578 | #endif | 582 | #endif |
583 | if (unlikely(!list_empty(&tsk->pi_state_list))) | ||
584 | exit_pi_state_list(tsk); | ||
579 | #endif | 585 | #endif |
580 | 586 | ||
581 | /* Get rid of any cached register state */ | 587 | /* Get rid of any cached register state */ |
diff --git a/kernel/futex.c b/kernel/futex.c index b911adceb2c4..4949d336d88d 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -916,8 +916,8 @@ retry: | |||
916 | hb1 = hash_futex(&key1); | 916 | hb1 = hash_futex(&key1); |
917 | hb2 = hash_futex(&key2); | 917 | hb2 = hash_futex(&key2); |
918 | 918 | ||
919 | double_lock_hb(hb1, hb2); | ||
920 | retry_private: | 919 | retry_private: |
920 | double_lock_hb(hb1, hb2); | ||
921 | op_ret = futex_atomic_op_inuser(op, uaddr2); | 921 | op_ret = futex_atomic_op_inuser(op, uaddr2); |
922 | if (unlikely(op_ret < 0)) { | 922 | if (unlikely(op_ret < 0)) { |
923 | 923 | ||
@@ -2117,7 +2117,6 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb, | |||
2117 | * Unqueue the futex_q and determine which it was. | 2117 | * Unqueue the futex_q and determine which it was. |
2118 | */ | 2118 | */ |
2119 | plist_del(&q->list, &q->list.plist); | 2119 | plist_del(&q->list, &q->list.plist); |
2120 | drop_futex_key_refs(&q->key); | ||
2121 | 2120 | ||
2122 | if (timeout && !timeout->task) | 2121 | if (timeout && !timeout->task) |
2123 | ret = -ETIMEDOUT; | 2122 | ret = -ETIMEDOUT; |
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 6d7020490f94..3e1c36e7998f 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
@@ -726,8 +726,6 @@ static int hrtimer_switch_to_hres(void) | |||
726 | /* "Retrigger" the interrupt to get things going */ | 726 | /* "Retrigger" the interrupt to get things going */ |
727 | retrigger_next_event(NULL); | 727 | retrigger_next_event(NULL); |
728 | local_irq_restore(flags); | 728 | local_irq_restore(flags); |
729 | printk(KERN_DEBUG "Switched to high resolution mode on CPU %d\n", | ||
730 | smp_processor_id()); | ||
731 | return 1; | 729 | return 1; |
732 | } | 730 | } |
733 | 731 | ||
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index a81cf80554db..17c71bb565c6 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c | |||
@@ -11,6 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/irq.h> | 13 | #include <linux/irq.h> |
14 | #include <linux/sched.h> | ||
14 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
15 | #include <linux/module.h> | 16 | #include <linux/module.h> |
16 | #include <linux/random.h> | 17 | #include <linux/random.h> |
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 3815ac1d58b2..9af56723c096 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
@@ -142,6 +142,11 @@ static inline struct lock_class *hlock_class(struct held_lock *hlock) | |||
142 | #ifdef CONFIG_LOCK_STAT | 142 | #ifdef CONFIG_LOCK_STAT |
143 | static DEFINE_PER_CPU(struct lock_class_stats[MAX_LOCKDEP_KEYS], lock_stats); | 143 | static DEFINE_PER_CPU(struct lock_class_stats[MAX_LOCKDEP_KEYS], lock_stats); |
144 | 144 | ||
145 | static inline u64 lockstat_clock(void) | ||
146 | { | ||
147 | return cpu_clock(smp_processor_id()); | ||
148 | } | ||
149 | |||
145 | static int lock_point(unsigned long points[], unsigned long ip) | 150 | static int lock_point(unsigned long points[], unsigned long ip) |
146 | { | 151 | { |
147 | int i; | 152 | int i; |
@@ -158,7 +163,7 @@ static int lock_point(unsigned long points[], unsigned long ip) | |||
158 | return i; | 163 | return i; |
159 | } | 164 | } |
160 | 165 | ||
161 | static void lock_time_inc(struct lock_time *lt, s64 time) | 166 | static void lock_time_inc(struct lock_time *lt, u64 time) |
162 | { | 167 | { |
163 | if (time > lt->max) | 168 | if (time > lt->max) |
164 | lt->max = time; | 169 | lt->max = time; |
@@ -234,12 +239,12 @@ static void put_lock_stats(struct lock_class_stats *stats) | |||
234 | static void lock_release_holdtime(struct held_lock *hlock) | 239 | static void lock_release_holdtime(struct held_lock *hlock) |
235 | { | 240 | { |
236 | struct lock_class_stats *stats; | 241 | struct lock_class_stats *stats; |
237 | s64 holdtime; | 242 | u64 holdtime; |
238 | 243 | ||
239 | if (!lock_stat) | 244 | if (!lock_stat) |
240 | return; | 245 | return; |
241 | 246 | ||
242 | holdtime = sched_clock() - hlock->holdtime_stamp; | 247 | holdtime = lockstat_clock() - hlock->holdtime_stamp; |
243 | 248 | ||
244 | stats = get_lock_stats(hlock_class(hlock)); | 249 | stats = get_lock_stats(hlock_class(hlock)); |
245 | if (hlock->read) | 250 | if (hlock->read) |
@@ -2792,7 +2797,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, | |||
2792 | hlock->references = references; | 2797 | hlock->references = references; |
2793 | #ifdef CONFIG_LOCK_STAT | 2798 | #ifdef CONFIG_LOCK_STAT |
2794 | hlock->waittime_stamp = 0; | 2799 | hlock->waittime_stamp = 0; |
2795 | hlock->holdtime_stamp = sched_clock(); | 2800 | hlock->holdtime_stamp = lockstat_clock(); |
2796 | #endif | 2801 | #endif |
2797 | 2802 | ||
2798 | if (check == 2 && !mark_irqflags(curr, hlock)) | 2803 | if (check == 2 && !mark_irqflags(curr, hlock)) |
@@ -3322,7 +3327,7 @@ found_it: | |||
3322 | if (hlock->instance != lock) | 3327 | if (hlock->instance != lock) |
3323 | return; | 3328 | return; |
3324 | 3329 | ||
3325 | hlock->waittime_stamp = sched_clock(); | 3330 | hlock->waittime_stamp = lockstat_clock(); |
3326 | 3331 | ||
3327 | contention_point = lock_point(hlock_class(hlock)->contention_point, ip); | 3332 | contention_point = lock_point(hlock_class(hlock)->contention_point, ip); |
3328 | contending_point = lock_point(hlock_class(hlock)->contending_point, | 3333 | contending_point = lock_point(hlock_class(hlock)->contending_point, |
@@ -3345,8 +3350,7 @@ __lock_acquired(struct lockdep_map *lock, unsigned long ip) | |||
3345 | struct held_lock *hlock, *prev_hlock; | 3350 | struct held_lock *hlock, *prev_hlock; |
3346 | struct lock_class_stats *stats; | 3351 | struct lock_class_stats *stats; |
3347 | unsigned int depth; | 3352 | unsigned int depth; |
3348 | u64 now; | 3353 | u64 now, waittime = 0; |
3349 | s64 waittime = 0; | ||
3350 | int i, cpu; | 3354 | int i, cpu; |
3351 | 3355 | ||
3352 | depth = curr->lockdep_depth; | 3356 | depth = curr->lockdep_depth; |
@@ -3374,7 +3378,7 @@ found_it: | |||
3374 | 3378 | ||
3375 | cpu = smp_processor_id(); | 3379 | cpu = smp_processor_id(); |
3376 | if (hlock->waittime_stamp) { | 3380 | if (hlock->waittime_stamp) { |
3377 | now = sched_clock(); | 3381 | now = lockstat_clock(); |
3378 | waittime = now - hlock->waittime_stamp; | 3382 | waittime = now - hlock->waittime_stamp; |
3379 | hlock->holdtime_stamp = now; | 3383 | hlock->holdtime_stamp = now; |
3380 | } | 3384 | } |
diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c index 50d022e5a560..ec815a960b5d 100644 --- a/kernel/mutex-debug.c +++ b/kernel/mutex-debug.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/poison.h> | 18 | #include <linux/poison.h> |
19 | #include <linux/sched.h> | ||
19 | #include <linux/spinlock.h> | 20 | #include <linux/spinlock.h> |
20 | #include <linux/kallsyms.h> | 21 | #include <linux/kallsyms.h> |
21 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
diff --git a/kernel/panic.c b/kernel/panic.c index bcdef26e3332..96b45d0b4ba5 100644 --- a/kernel/panic.c +++ b/kernel/panic.c | |||
@@ -90,6 +90,8 @@ NORET_TYPE void panic(const char * fmt, ...) | |||
90 | 90 | ||
91 | atomic_notifier_call_chain(&panic_notifier_list, 0, buf); | 91 | atomic_notifier_call_chain(&panic_notifier_list, 0, buf); |
92 | 92 | ||
93 | bust_spinlocks(0); | ||
94 | |||
93 | if (!panic_blink) | 95 | if (!panic_blink) |
94 | panic_blink = no_blink; | 96 | panic_blink = no_blink; |
95 | 97 | ||
@@ -136,7 +138,6 @@ NORET_TYPE void panic(const char * fmt, ...) | |||
136 | mdelay(1); | 138 | mdelay(1); |
137 | i++; | 139 | i++; |
138 | } | 140 | } |
139 | bust_spinlocks(0); | ||
140 | } | 141 | } |
141 | 142 | ||
142 | EXPORT_SYMBOL(panic); | 143 | EXPORT_SYMBOL(panic); |
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 0f86feb6db0c..9d0b5c665883 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/percpu.h> | 20 | #include <linux/percpu.h> |
21 | #include <linux/ptrace.h> | 21 | #include <linux/ptrace.h> |
22 | #include <linux/vmstat.h> | 22 | #include <linux/vmstat.h> |
23 | #include <linux/vmalloc.h> | ||
23 | #include <linux/hardirq.h> | 24 | #include <linux/hardirq.h> |
24 | #include <linux/rculist.h> | 25 | #include <linux/rculist.h> |
25 | #include <linux/uaccess.h> | 26 | #include <linux/uaccess.h> |
@@ -1030,14 +1031,10 @@ void __perf_event_sched_out(struct perf_event_context *ctx, | |||
1030 | update_context_time(ctx); | 1031 | update_context_time(ctx); |
1031 | 1032 | ||
1032 | perf_disable(); | 1033 | perf_disable(); |
1033 | if (ctx->nr_active) { | 1034 | if (ctx->nr_active) |
1034 | list_for_each_entry(event, &ctx->group_list, group_entry) { | 1035 | list_for_each_entry(event, &ctx->group_list, group_entry) |
1035 | if (event != event->group_leader) | 1036 | group_sched_out(event, cpuctx, ctx); |
1036 | event_sched_out(event, cpuctx, ctx); | 1037 | |
1037 | else | ||
1038 | group_sched_out(event, cpuctx, ctx); | ||
1039 | } | ||
1040 | } | ||
1041 | perf_enable(); | 1038 | perf_enable(); |
1042 | out: | 1039 | out: |
1043 | spin_unlock(&ctx->lock); | 1040 | spin_unlock(&ctx->lock); |
@@ -1258,12 +1255,8 @@ __perf_event_sched_in(struct perf_event_context *ctx, | |||
1258 | if (event->cpu != -1 && event->cpu != cpu) | 1255 | if (event->cpu != -1 && event->cpu != cpu) |
1259 | continue; | 1256 | continue; |
1260 | 1257 | ||
1261 | if (event != event->group_leader) | 1258 | if (group_can_go_on(event, cpuctx, 1)) |
1262 | event_sched_in(event, cpuctx, ctx, cpu); | 1259 | group_sched_in(event, cpuctx, ctx, cpu); |
1263 | else { | ||
1264 | if (group_can_go_on(event, cpuctx, 1)) | ||
1265 | group_sched_in(event, cpuctx, ctx, cpu); | ||
1266 | } | ||
1267 | 1260 | ||
1268 | /* | 1261 | /* |
1269 | * If this pinned group hasn't been scheduled, | 1262 | * If this pinned group hasn't been scheduled, |
@@ -1291,15 +1284,9 @@ __perf_event_sched_in(struct perf_event_context *ctx, | |||
1291 | if (event->cpu != -1 && event->cpu != cpu) | 1284 | if (event->cpu != -1 && event->cpu != cpu) |
1292 | continue; | 1285 | continue; |
1293 | 1286 | ||
1294 | if (event != event->group_leader) { | 1287 | if (group_can_go_on(event, cpuctx, can_add_hw)) |
1295 | if (event_sched_in(event, cpuctx, ctx, cpu)) | 1288 | if (group_sched_in(event, cpuctx, ctx, cpu)) |
1296 | can_add_hw = 0; | 1289 | can_add_hw = 0; |
1297 | } else { | ||
1298 | if (group_can_go_on(event, cpuctx, can_add_hw)) { | ||
1299 | if (group_sched_in(event, cpuctx, ctx, cpu)) | ||
1300 | can_add_hw = 0; | ||
1301 | } | ||
1302 | } | ||
1303 | } | 1290 | } |
1304 | perf_enable(); | 1291 | perf_enable(); |
1305 | out: | 1292 | out: |
@@ -2105,49 +2092,31 @@ unlock: | |||
2105 | rcu_read_unlock(); | 2092 | rcu_read_unlock(); |
2106 | } | 2093 | } |
2107 | 2094 | ||
2108 | static int perf_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | 2095 | static unsigned long perf_data_size(struct perf_mmap_data *data) |
2109 | { | 2096 | { |
2110 | struct perf_event *event = vma->vm_file->private_data; | 2097 | return data->nr_pages << (PAGE_SHIFT + data->data_order); |
2111 | struct perf_mmap_data *data; | 2098 | } |
2112 | int ret = VM_FAULT_SIGBUS; | ||
2113 | |||
2114 | if (vmf->flags & FAULT_FLAG_MKWRITE) { | ||
2115 | if (vmf->pgoff == 0) | ||
2116 | ret = 0; | ||
2117 | return ret; | ||
2118 | } | ||
2119 | |||
2120 | rcu_read_lock(); | ||
2121 | data = rcu_dereference(event->data); | ||
2122 | if (!data) | ||
2123 | goto unlock; | ||
2124 | |||
2125 | if (vmf->pgoff == 0) { | ||
2126 | vmf->page = virt_to_page(data->user_page); | ||
2127 | } else { | ||
2128 | int nr = vmf->pgoff - 1; | ||
2129 | |||
2130 | if ((unsigned)nr > data->nr_pages) | ||
2131 | goto unlock; | ||
2132 | 2099 | ||
2133 | if (vmf->flags & FAULT_FLAG_WRITE) | 2100 | #ifndef CONFIG_PERF_USE_VMALLOC |
2134 | goto unlock; | ||
2135 | 2101 | ||
2136 | vmf->page = virt_to_page(data->data_pages[nr]); | 2102 | /* |
2137 | } | 2103 | * Back perf_mmap() with regular GFP_KERNEL-0 pages. |
2104 | */ | ||
2138 | 2105 | ||
2139 | get_page(vmf->page); | 2106 | static struct page * |
2140 | vmf->page->mapping = vma->vm_file->f_mapping; | 2107 | perf_mmap_to_page(struct perf_mmap_data *data, unsigned long pgoff) |
2141 | vmf->page->index = vmf->pgoff; | 2108 | { |
2109 | if (pgoff > data->nr_pages) | ||
2110 | return NULL; | ||
2142 | 2111 | ||
2143 | ret = 0; | 2112 | if (pgoff == 0) |
2144 | unlock: | 2113 | return virt_to_page(data->user_page); |
2145 | rcu_read_unlock(); | ||
2146 | 2114 | ||
2147 | return ret; | 2115 | return virt_to_page(data->data_pages[pgoff - 1]); |
2148 | } | 2116 | } |
2149 | 2117 | ||
2150 | static int perf_mmap_data_alloc(struct perf_event *event, int nr_pages) | 2118 | static struct perf_mmap_data * |
2119 | perf_mmap_data_alloc(struct perf_event *event, int nr_pages) | ||
2151 | { | 2120 | { |
2152 | struct perf_mmap_data *data; | 2121 | struct perf_mmap_data *data; |
2153 | unsigned long size; | 2122 | unsigned long size; |
@@ -2172,19 +2141,10 @@ static int perf_mmap_data_alloc(struct perf_event *event, int nr_pages) | |||
2172 | goto fail_data_pages; | 2141 | goto fail_data_pages; |
2173 | } | 2142 | } |
2174 | 2143 | ||
2144 | data->data_order = 0; | ||
2175 | data->nr_pages = nr_pages; | 2145 | data->nr_pages = nr_pages; |
2176 | atomic_set(&data->lock, -1); | ||
2177 | |||
2178 | if (event->attr.watermark) { | ||
2179 | data->watermark = min_t(long, PAGE_SIZE * nr_pages, | ||
2180 | event->attr.wakeup_watermark); | ||
2181 | } | ||
2182 | if (!data->watermark) | ||
2183 | data->watermark = max(PAGE_SIZE, PAGE_SIZE * nr_pages / 4); | ||
2184 | 2146 | ||
2185 | rcu_assign_pointer(event->data, data); | 2147 | return data; |
2186 | |||
2187 | return 0; | ||
2188 | 2148 | ||
2189 | fail_data_pages: | 2149 | fail_data_pages: |
2190 | for (i--; i >= 0; i--) | 2150 | for (i--; i >= 0; i--) |
@@ -2196,7 +2156,7 @@ fail_user_page: | |||
2196 | kfree(data); | 2156 | kfree(data); |
2197 | 2157 | ||
2198 | fail: | 2158 | fail: |
2199 | return -ENOMEM; | 2159 | return NULL; |
2200 | } | 2160 | } |
2201 | 2161 | ||
2202 | static void perf_mmap_free_page(unsigned long addr) | 2162 | static void perf_mmap_free_page(unsigned long addr) |
@@ -2207,28 +2167,169 @@ static void perf_mmap_free_page(unsigned long addr) | |||
2207 | __free_page(page); | 2167 | __free_page(page); |
2208 | } | 2168 | } |
2209 | 2169 | ||
2210 | static void __perf_mmap_data_free(struct rcu_head *rcu_head) | 2170 | static void perf_mmap_data_free(struct perf_mmap_data *data) |
2211 | { | 2171 | { |
2212 | struct perf_mmap_data *data; | ||
2213 | int i; | 2172 | int i; |
2214 | 2173 | ||
2215 | data = container_of(rcu_head, struct perf_mmap_data, rcu_head); | ||
2216 | |||
2217 | perf_mmap_free_page((unsigned long)data->user_page); | 2174 | perf_mmap_free_page((unsigned long)data->user_page); |
2218 | for (i = 0; i < data->nr_pages; i++) | 2175 | for (i = 0; i < data->nr_pages; i++) |
2219 | perf_mmap_free_page((unsigned long)data->data_pages[i]); | 2176 | perf_mmap_free_page((unsigned long)data->data_pages[i]); |
2177 | } | ||
2178 | |||
2179 | #else | ||
2180 | |||
2181 | /* | ||
2182 | * Back perf_mmap() with vmalloc memory. | ||
2183 | * | ||
2184 | * Required for architectures that have d-cache aliasing issues. | ||
2185 | */ | ||
2186 | |||
2187 | static struct page * | ||
2188 | perf_mmap_to_page(struct perf_mmap_data *data, unsigned long pgoff) | ||
2189 | { | ||
2190 | if (pgoff > (1UL << data->data_order)) | ||
2191 | return NULL; | ||
2192 | |||
2193 | return vmalloc_to_page((void *)data->user_page + pgoff * PAGE_SIZE); | ||
2194 | } | ||
2195 | |||
2196 | static void perf_mmap_unmark_page(void *addr) | ||
2197 | { | ||
2198 | struct page *page = vmalloc_to_page(addr); | ||
2199 | |||
2200 | page->mapping = NULL; | ||
2201 | } | ||
2202 | |||
2203 | static void perf_mmap_data_free_work(struct work_struct *work) | ||
2204 | { | ||
2205 | struct perf_mmap_data *data; | ||
2206 | void *base; | ||
2207 | int i, nr; | ||
2208 | |||
2209 | data = container_of(work, struct perf_mmap_data, work); | ||
2210 | nr = 1 << data->data_order; | ||
2211 | |||
2212 | base = data->user_page; | ||
2213 | for (i = 0; i < nr + 1; i++) | ||
2214 | perf_mmap_unmark_page(base + (i * PAGE_SIZE)); | ||
2215 | |||
2216 | vfree(base); | ||
2217 | } | ||
2220 | 2218 | ||
2219 | static void perf_mmap_data_free(struct perf_mmap_data *data) | ||
2220 | { | ||
2221 | schedule_work(&data->work); | ||
2222 | } | ||
2223 | |||
2224 | static struct perf_mmap_data * | ||
2225 | perf_mmap_data_alloc(struct perf_event *event, int nr_pages) | ||
2226 | { | ||
2227 | struct perf_mmap_data *data; | ||
2228 | unsigned long size; | ||
2229 | void *all_buf; | ||
2230 | |||
2231 | WARN_ON(atomic_read(&event->mmap_count)); | ||
2232 | |||
2233 | size = sizeof(struct perf_mmap_data); | ||
2234 | size += sizeof(void *); | ||
2235 | |||
2236 | data = kzalloc(size, GFP_KERNEL); | ||
2237 | if (!data) | ||
2238 | goto fail; | ||
2239 | |||
2240 | INIT_WORK(&data->work, perf_mmap_data_free_work); | ||
2241 | |||
2242 | all_buf = vmalloc_user((nr_pages + 1) * PAGE_SIZE); | ||
2243 | if (!all_buf) | ||
2244 | goto fail_all_buf; | ||
2245 | |||
2246 | data->user_page = all_buf; | ||
2247 | data->data_pages[0] = all_buf + PAGE_SIZE; | ||
2248 | data->data_order = ilog2(nr_pages); | ||
2249 | data->nr_pages = 1; | ||
2250 | |||
2251 | return data; | ||
2252 | |||
2253 | fail_all_buf: | ||
2254 | kfree(data); | ||
2255 | |||
2256 | fail: | ||
2257 | return NULL; | ||
2258 | } | ||
2259 | |||
2260 | #endif | ||
2261 | |||
2262 | static int perf_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | ||
2263 | { | ||
2264 | struct perf_event *event = vma->vm_file->private_data; | ||
2265 | struct perf_mmap_data *data; | ||
2266 | int ret = VM_FAULT_SIGBUS; | ||
2267 | |||
2268 | if (vmf->flags & FAULT_FLAG_MKWRITE) { | ||
2269 | if (vmf->pgoff == 0) | ||
2270 | ret = 0; | ||
2271 | return ret; | ||
2272 | } | ||
2273 | |||
2274 | rcu_read_lock(); | ||
2275 | data = rcu_dereference(event->data); | ||
2276 | if (!data) | ||
2277 | goto unlock; | ||
2278 | |||
2279 | if (vmf->pgoff && (vmf->flags & FAULT_FLAG_WRITE)) | ||
2280 | goto unlock; | ||
2281 | |||
2282 | vmf->page = perf_mmap_to_page(data, vmf->pgoff); | ||
2283 | if (!vmf->page) | ||
2284 | goto unlock; | ||
2285 | |||
2286 | get_page(vmf->page); | ||
2287 | vmf->page->mapping = vma->vm_file->f_mapping; | ||
2288 | vmf->page->index = vmf->pgoff; | ||
2289 | |||
2290 | ret = 0; | ||
2291 | unlock: | ||
2292 | rcu_read_unlock(); | ||
2293 | |||
2294 | return ret; | ||
2295 | } | ||
2296 | |||
2297 | static void | ||
2298 | perf_mmap_data_init(struct perf_event *event, struct perf_mmap_data *data) | ||
2299 | { | ||
2300 | long max_size = perf_data_size(data); | ||
2301 | |||
2302 | atomic_set(&data->lock, -1); | ||
2303 | |||
2304 | if (event->attr.watermark) { | ||
2305 | data->watermark = min_t(long, max_size, | ||
2306 | event->attr.wakeup_watermark); | ||
2307 | } | ||
2308 | |||
2309 | if (!data->watermark) | ||
2310 | data->watermark = max_t(long, PAGE_SIZE, max_size / 2); | ||
2311 | |||
2312 | |||
2313 | rcu_assign_pointer(event->data, data); | ||
2314 | } | ||
2315 | |||
2316 | static void perf_mmap_data_free_rcu(struct rcu_head *rcu_head) | ||
2317 | { | ||
2318 | struct perf_mmap_data *data; | ||
2319 | |||
2320 | data = container_of(rcu_head, struct perf_mmap_data, rcu_head); | ||
2321 | perf_mmap_data_free(data); | ||
2221 | kfree(data); | 2322 | kfree(data); |
2222 | } | 2323 | } |
2223 | 2324 | ||
2224 | static void perf_mmap_data_free(struct perf_event *event) | 2325 | static void perf_mmap_data_release(struct perf_event *event) |
2225 | { | 2326 | { |
2226 | struct perf_mmap_data *data = event->data; | 2327 | struct perf_mmap_data *data = event->data; |
2227 | 2328 | ||
2228 | WARN_ON(atomic_read(&event->mmap_count)); | 2329 | WARN_ON(atomic_read(&event->mmap_count)); |
2229 | 2330 | ||
2230 | rcu_assign_pointer(event->data, NULL); | 2331 | rcu_assign_pointer(event->data, NULL); |
2231 | call_rcu(&data->rcu_head, __perf_mmap_data_free); | 2332 | call_rcu(&data->rcu_head, perf_mmap_data_free_rcu); |
2232 | } | 2333 | } |
2233 | 2334 | ||
2234 | static void perf_mmap_open(struct vm_area_struct *vma) | 2335 | static void perf_mmap_open(struct vm_area_struct *vma) |
@@ -2244,11 +2345,12 @@ static void perf_mmap_close(struct vm_area_struct *vma) | |||
2244 | 2345 | ||
2245 | WARN_ON_ONCE(event->ctx->parent_ctx); | 2346 | WARN_ON_ONCE(event->ctx->parent_ctx); |
2246 | if (atomic_dec_and_mutex_lock(&event->mmap_count, &event->mmap_mutex)) { | 2347 | if (atomic_dec_and_mutex_lock(&event->mmap_count, &event->mmap_mutex)) { |
2348 | unsigned long size = perf_data_size(event->data); | ||
2247 | struct user_struct *user = current_user(); | 2349 | struct user_struct *user = current_user(); |
2248 | 2350 | ||
2249 | atomic_long_sub(event->data->nr_pages + 1, &user->locked_vm); | 2351 | atomic_long_sub((size >> PAGE_SHIFT) + 1, &user->locked_vm); |
2250 | vma->vm_mm->locked_vm -= event->data->nr_locked; | 2352 | vma->vm_mm->locked_vm -= event->data->nr_locked; |
2251 | perf_mmap_data_free(event); | 2353 | perf_mmap_data_release(event); |
2252 | mutex_unlock(&event->mmap_mutex); | 2354 | mutex_unlock(&event->mmap_mutex); |
2253 | } | 2355 | } |
2254 | } | 2356 | } |
@@ -2266,6 +2368,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma) | |||
2266 | unsigned long user_locked, user_lock_limit; | 2368 | unsigned long user_locked, user_lock_limit; |
2267 | struct user_struct *user = current_user(); | 2369 | struct user_struct *user = current_user(); |
2268 | unsigned long locked, lock_limit; | 2370 | unsigned long locked, lock_limit; |
2371 | struct perf_mmap_data *data; | ||
2269 | unsigned long vma_size; | 2372 | unsigned long vma_size; |
2270 | unsigned long nr_pages; | 2373 | unsigned long nr_pages; |
2271 | long user_extra, extra; | 2374 | long user_extra, extra; |
@@ -2328,10 +2431,15 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma) | |||
2328 | } | 2431 | } |
2329 | 2432 | ||
2330 | WARN_ON(event->data); | 2433 | WARN_ON(event->data); |
2331 | ret = perf_mmap_data_alloc(event, nr_pages); | 2434 | |
2332 | if (ret) | 2435 | data = perf_mmap_data_alloc(event, nr_pages); |
2436 | ret = -ENOMEM; | ||
2437 | if (!data) | ||
2333 | goto unlock; | 2438 | goto unlock; |
2334 | 2439 | ||
2440 | ret = 0; | ||
2441 | perf_mmap_data_init(event, data); | ||
2442 | |||
2335 | atomic_set(&event->mmap_count, 1); | 2443 | atomic_set(&event->mmap_count, 1); |
2336 | atomic_long_add(user_extra, &user->locked_vm); | 2444 | atomic_long_add(user_extra, &user->locked_vm); |
2337 | vma->vm_mm->locked_vm += extra; | 2445 | vma->vm_mm->locked_vm += extra; |
@@ -2519,7 +2627,7 @@ static bool perf_output_space(struct perf_mmap_data *data, unsigned long tail, | |||
2519 | if (!data->writable) | 2627 | if (!data->writable) |
2520 | return true; | 2628 | return true; |
2521 | 2629 | ||
2522 | mask = (data->nr_pages << PAGE_SHIFT) - 1; | 2630 | mask = perf_data_size(data) - 1; |
2523 | 2631 | ||
2524 | offset = (offset - tail) & mask; | 2632 | offset = (offset - tail) & mask; |
2525 | head = (head - tail) & mask; | 2633 | head = (head - tail) & mask; |
@@ -2624,7 +2732,7 @@ void perf_output_copy(struct perf_output_handle *handle, | |||
2624 | const void *buf, unsigned int len) | 2732 | const void *buf, unsigned int len) |
2625 | { | 2733 | { |
2626 | unsigned int pages_mask; | 2734 | unsigned int pages_mask; |
2627 | unsigned int offset; | 2735 | unsigned long offset; |
2628 | unsigned int size; | 2736 | unsigned int size; |
2629 | void **pages; | 2737 | void **pages; |
2630 | 2738 | ||
@@ -2633,12 +2741,14 @@ void perf_output_copy(struct perf_output_handle *handle, | |||
2633 | pages = handle->data->data_pages; | 2741 | pages = handle->data->data_pages; |
2634 | 2742 | ||
2635 | do { | 2743 | do { |
2636 | unsigned int page_offset; | 2744 | unsigned long page_offset; |
2745 | unsigned long page_size; | ||
2637 | int nr; | 2746 | int nr; |
2638 | 2747 | ||
2639 | nr = (offset >> PAGE_SHIFT) & pages_mask; | 2748 | nr = (offset >> PAGE_SHIFT) & pages_mask; |
2640 | page_offset = offset & (PAGE_SIZE - 1); | 2749 | page_size = 1UL << (handle->data->data_order + PAGE_SHIFT); |
2641 | size = min_t(unsigned int, PAGE_SIZE - page_offset, len); | 2750 | page_offset = offset & (page_size - 1); |
2751 | size = min_t(unsigned int, page_size - page_offset, len); | ||
2642 | 2752 | ||
2643 | memcpy(pages[nr] + page_offset, buf, size); | 2753 | memcpy(pages[nr] + page_offset, buf, size); |
2644 | 2754 | ||
@@ -4781,9 +4891,7 @@ int perf_event_init_task(struct task_struct *child) | |||
4781 | * We dont have to disable NMIs - we are only looking at | 4891 | * We dont have to disable NMIs - we are only looking at |
4782 | * the list, not manipulating it: | 4892 | * the list, not manipulating it: |
4783 | */ | 4893 | */ |
4784 | list_for_each_entry_rcu(event, &parent_ctx->event_list, event_entry) { | 4894 | list_for_each_entry(event, &parent_ctx->group_list, group_entry) { |
4785 | if (event != event->group_leader) | ||
4786 | continue; | ||
4787 | 4895 | ||
4788 | if (!event->attr.inherit) { | 4896 | if (!event->attr.inherit) { |
4789 | inherited_all = 0; | 4897 | inherited_all = 0; |
diff --git a/kernel/power/suspend_test.c b/kernel/power/suspend_test.c index 17d8bb1acf9c..25596e450ac7 100644 --- a/kernel/power/suspend_test.c +++ b/kernel/power/suspend_test.c | |||
@@ -19,7 +19,7 @@ | |||
19 | * The time it takes is system-specific though, so when we test this | 19 | * The time it takes is system-specific though, so when we test this |
20 | * during system bootup we allow a LOT of time. | 20 | * during system bootup we allow a LOT of time. |
21 | */ | 21 | */ |
22 | #define TEST_SUSPEND_SECONDS 5 | 22 | #define TEST_SUSPEND_SECONDS 10 |
23 | 23 | ||
24 | static unsigned long suspend_test_start_time; | 24 | static unsigned long suspend_test_start_time; |
25 | 25 | ||
@@ -49,7 +49,8 @@ void suspend_test_finish(const char *label) | |||
49 | * has some performance issues. The stack dump of a WARN_ON | 49 | * has some performance issues. The stack dump of a WARN_ON |
50 | * is more likely to get the right attention than a printk... | 50 | * is more likely to get the right attention than a printk... |
51 | */ | 51 | */ |
52 | WARN(msec > (TEST_SUSPEND_SECONDS * 1000), "Component: %s\n", label); | 52 | WARN(msec > (TEST_SUSPEND_SECONDS * 1000), |
53 | "Component: %s, time: %u\n", label, msec); | ||
53 | } | 54 | } |
54 | 55 | ||
55 | /* | 56 | /* |
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c index 37ac45483082..400183346ad2 100644 --- a/kernel/rcupdate.c +++ b/kernel/rcupdate.c | |||
@@ -46,22 +46,15 @@ | |||
46 | #include <linux/module.h> | 46 | #include <linux/module.h> |
47 | #include <linux/kernel_stat.h> | 47 | #include <linux/kernel_stat.h> |
48 | 48 | ||
49 | enum rcu_barrier { | 49 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
50 | RCU_BARRIER_STD, | 50 | static struct lock_class_key rcu_lock_key; |
51 | RCU_BARRIER_BH, | 51 | struct lockdep_map rcu_lock_map = |
52 | RCU_BARRIER_SCHED, | 52 | STATIC_LOCKDEP_MAP_INIT("rcu_read_lock", &rcu_lock_key); |
53 | }; | 53 | EXPORT_SYMBOL_GPL(rcu_lock_map); |
54 | #endif | ||
54 | 55 | ||
55 | static DEFINE_PER_CPU(struct rcu_head, rcu_barrier_head) = {NULL}; | ||
56 | static atomic_t rcu_barrier_cpu_count; | ||
57 | static DEFINE_MUTEX(rcu_barrier_mutex); | ||
58 | static struct completion rcu_barrier_completion; | ||
59 | int rcu_scheduler_active __read_mostly; | 56 | int rcu_scheduler_active __read_mostly; |
60 | 57 | ||
61 | static atomic_t rcu_migrate_type_count = ATOMIC_INIT(0); | ||
62 | static struct rcu_head rcu_migrate_head[3]; | ||
63 | static DECLARE_WAIT_QUEUE_HEAD(rcu_migrate_wq); | ||
64 | |||
65 | /* | 58 | /* |
66 | * Awaken the corresponding synchronize_rcu() instance now that a | 59 | * Awaken the corresponding synchronize_rcu() instance now that a |
67 | * grace period has elapsed. | 60 | * grace period has elapsed. |
@@ -164,129 +157,10 @@ void synchronize_rcu_bh(void) | |||
164 | } | 157 | } |
165 | EXPORT_SYMBOL_GPL(synchronize_rcu_bh); | 158 | EXPORT_SYMBOL_GPL(synchronize_rcu_bh); |
166 | 159 | ||
167 | static void rcu_barrier_callback(struct rcu_head *notused) | ||
168 | { | ||
169 | if (atomic_dec_and_test(&rcu_barrier_cpu_count)) | ||
170 | complete(&rcu_barrier_completion); | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | * Called with preemption disabled, and from cross-cpu IRQ context. | ||
175 | */ | ||
176 | static void rcu_barrier_func(void *type) | ||
177 | { | ||
178 | int cpu = smp_processor_id(); | ||
179 | struct rcu_head *head = &per_cpu(rcu_barrier_head, cpu); | ||
180 | |||
181 | atomic_inc(&rcu_barrier_cpu_count); | ||
182 | switch ((enum rcu_barrier)type) { | ||
183 | case RCU_BARRIER_STD: | ||
184 | call_rcu(head, rcu_barrier_callback); | ||
185 | break; | ||
186 | case RCU_BARRIER_BH: | ||
187 | call_rcu_bh(head, rcu_barrier_callback); | ||
188 | break; | ||
189 | case RCU_BARRIER_SCHED: | ||
190 | call_rcu_sched(head, rcu_barrier_callback); | ||
191 | break; | ||
192 | } | ||
193 | } | ||
194 | |||
195 | static inline void wait_migrated_callbacks(void) | ||
196 | { | ||
197 | wait_event(rcu_migrate_wq, !atomic_read(&rcu_migrate_type_count)); | ||
198 | smp_mb(); /* In case we didn't sleep. */ | ||
199 | } | ||
200 | |||
201 | /* | ||
202 | * Orchestrate the specified type of RCU barrier, waiting for all | ||
203 | * RCU callbacks of the specified type to complete. | ||
204 | */ | ||
205 | static void _rcu_barrier(enum rcu_barrier type) | ||
206 | { | ||
207 | BUG_ON(in_interrupt()); | ||
208 | /* Take cpucontrol mutex to protect against CPU hotplug */ | ||
209 | mutex_lock(&rcu_barrier_mutex); | ||
210 | init_completion(&rcu_barrier_completion); | ||
211 | /* | ||
212 | * Initialize rcu_barrier_cpu_count to 1, then invoke | ||
213 | * rcu_barrier_func() on each CPU, so that each CPU also has | ||
214 | * incremented rcu_barrier_cpu_count. Only then is it safe to | ||
215 | * decrement rcu_barrier_cpu_count -- otherwise the first CPU | ||
216 | * might complete its grace period before all of the other CPUs | ||
217 | * did their increment, causing this function to return too | ||
218 | * early. | ||
219 | */ | ||
220 | atomic_set(&rcu_barrier_cpu_count, 1); | ||
221 | on_each_cpu(rcu_barrier_func, (void *)type, 1); | ||
222 | if (atomic_dec_and_test(&rcu_barrier_cpu_count)) | ||
223 | complete(&rcu_barrier_completion); | ||
224 | wait_for_completion(&rcu_barrier_completion); | ||
225 | mutex_unlock(&rcu_barrier_mutex); | ||
226 | wait_migrated_callbacks(); | ||
227 | } | ||
228 | |||
229 | /** | ||
230 | * rcu_barrier - Wait until all in-flight call_rcu() callbacks complete. | ||
231 | */ | ||
232 | void rcu_barrier(void) | ||
233 | { | ||
234 | _rcu_barrier(RCU_BARRIER_STD); | ||
235 | } | ||
236 | EXPORT_SYMBOL_GPL(rcu_barrier); | ||
237 | |||
238 | /** | ||
239 | * rcu_barrier_bh - Wait until all in-flight call_rcu_bh() callbacks complete. | ||
240 | */ | ||
241 | void rcu_barrier_bh(void) | ||
242 | { | ||
243 | _rcu_barrier(RCU_BARRIER_BH); | ||
244 | } | ||
245 | EXPORT_SYMBOL_GPL(rcu_barrier_bh); | ||
246 | |||
247 | /** | ||
248 | * rcu_barrier_sched - Wait for in-flight call_rcu_sched() callbacks. | ||
249 | */ | ||
250 | void rcu_barrier_sched(void) | ||
251 | { | ||
252 | _rcu_barrier(RCU_BARRIER_SCHED); | ||
253 | } | ||
254 | EXPORT_SYMBOL_GPL(rcu_barrier_sched); | ||
255 | |||
256 | static void rcu_migrate_callback(struct rcu_head *notused) | ||
257 | { | ||
258 | if (atomic_dec_and_test(&rcu_migrate_type_count)) | ||
259 | wake_up(&rcu_migrate_wq); | ||
260 | } | ||
261 | |||
262 | extern int rcu_cpu_notify(struct notifier_block *self, | ||
263 | unsigned long action, void *hcpu); | ||
264 | |||
265 | static int __cpuinit rcu_barrier_cpu_hotplug(struct notifier_block *self, | 160 | static int __cpuinit rcu_barrier_cpu_hotplug(struct notifier_block *self, |
266 | unsigned long action, void *hcpu) | 161 | unsigned long action, void *hcpu) |
267 | { | 162 | { |
268 | rcu_cpu_notify(self, action, hcpu); | 163 | return rcu_cpu_notify(self, action, hcpu); |
269 | if (action == CPU_DYING) { | ||
270 | /* | ||
271 | * preempt_disable() in on_each_cpu() prevents stop_machine(), | ||
272 | * so when "on_each_cpu(rcu_barrier_func, (void *)type, 1);" | ||
273 | * returns, all online cpus have queued rcu_barrier_func(), | ||
274 | * and the dead cpu(if it exist) queues rcu_migrate_callback()s. | ||
275 | * | ||
276 | * These callbacks ensure _rcu_barrier() waits for all | ||
277 | * RCU callbacks of the specified type to complete. | ||
278 | */ | ||
279 | atomic_set(&rcu_migrate_type_count, 3); | ||
280 | call_rcu_bh(rcu_migrate_head, rcu_migrate_callback); | ||
281 | call_rcu_sched(rcu_migrate_head + 1, rcu_migrate_callback); | ||
282 | call_rcu(rcu_migrate_head + 2, rcu_migrate_callback); | ||
283 | } else if (action == CPU_DOWN_PREPARE) { | ||
284 | /* Don't need to wait until next removal operation. */ | ||
285 | /* rcu_migrate_head is protected by cpu_add_remove_lock */ | ||
286 | wait_migrated_callbacks(); | ||
287 | } | ||
288 | |||
289 | return NOTIFY_OK; | ||
290 | } | 164 | } |
291 | 165 | ||
292 | void __init rcu_init(void) | 166 | void __init rcu_init(void) |
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c index 233768f21f97..697c0a0229d4 100644 --- a/kernel/rcutorture.c +++ b/kernel/rcutorture.c | |||
@@ -606,8 +606,6 @@ static struct rcu_torture_ops sched_ops_sync = { | |||
606 | .name = "sched_sync" | 606 | .name = "sched_sync" |
607 | }; | 607 | }; |
608 | 608 | ||
609 | extern int rcu_expedited_torture_stats(char *page); | ||
610 | |||
611 | static struct rcu_torture_ops sched_expedited_ops = { | 609 | static struct rcu_torture_ops sched_expedited_ops = { |
612 | .init = rcu_sync_torture_init, | 610 | .init = rcu_sync_torture_init, |
613 | .cleanup = NULL, | 611 | .cleanup = NULL, |
@@ -650,7 +648,7 @@ rcu_torture_writer(void *arg) | |||
650 | old_rp = rcu_torture_current; | 648 | old_rp = rcu_torture_current; |
651 | rp->rtort_mbtest = 1; | 649 | rp->rtort_mbtest = 1; |
652 | rcu_assign_pointer(rcu_torture_current, rp); | 650 | rcu_assign_pointer(rcu_torture_current, rp); |
653 | smp_wmb(); | 651 | smp_wmb(); /* Mods to old_rp must follow rcu_assign_pointer() */ |
654 | if (old_rp) { | 652 | if (old_rp) { |
655 | i = old_rp->rtort_pipe_count; | 653 | i = old_rp->rtort_pipe_count; |
656 | if (i > RCU_TORTURE_PIPE_LEN) | 654 | if (i > RCU_TORTURE_PIPE_LEN) |
diff --git a/kernel/rcutree.c b/kernel/rcutree.c index 52b06f6e158c..705f02ac7433 100644 --- a/kernel/rcutree.c +++ b/kernel/rcutree.c | |||
@@ -49,13 +49,6 @@ | |||
49 | 49 | ||
50 | #include "rcutree.h" | 50 | #include "rcutree.h" |
51 | 51 | ||
52 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
53 | static struct lock_class_key rcu_lock_key; | ||
54 | struct lockdep_map rcu_lock_map = | ||
55 | STATIC_LOCKDEP_MAP_INIT("rcu_read_lock", &rcu_lock_key); | ||
56 | EXPORT_SYMBOL_GPL(rcu_lock_map); | ||
57 | #endif | ||
58 | |||
59 | /* Data structures. */ | 52 | /* Data structures. */ |
60 | 53 | ||
61 | #define RCU_STATE_INITIALIZER(name) { \ | 54 | #define RCU_STATE_INITIALIZER(name) { \ |
@@ -70,6 +63,9 @@ EXPORT_SYMBOL_GPL(rcu_lock_map); | |||
70 | .gpnum = -300, \ | 63 | .gpnum = -300, \ |
71 | .completed = -300, \ | 64 | .completed = -300, \ |
72 | .onofflock = __SPIN_LOCK_UNLOCKED(&name.onofflock), \ | 65 | .onofflock = __SPIN_LOCK_UNLOCKED(&name.onofflock), \ |
66 | .orphan_cbs_list = NULL, \ | ||
67 | .orphan_cbs_tail = &name.orphan_cbs_list, \ | ||
68 | .orphan_qlen = 0, \ | ||
73 | .fqslock = __SPIN_LOCK_UNLOCKED(&name.fqslock), \ | 69 | .fqslock = __SPIN_LOCK_UNLOCKED(&name.fqslock), \ |
74 | .n_force_qs = 0, \ | 70 | .n_force_qs = 0, \ |
75 | .n_force_qs_ngp = 0, \ | 71 | .n_force_qs_ngp = 0, \ |
@@ -81,24 +77,16 @@ DEFINE_PER_CPU(struct rcu_data, rcu_sched_data); | |||
81 | struct rcu_state rcu_bh_state = RCU_STATE_INITIALIZER(rcu_bh_state); | 77 | struct rcu_state rcu_bh_state = RCU_STATE_INITIALIZER(rcu_bh_state); |
82 | DEFINE_PER_CPU(struct rcu_data, rcu_bh_data); | 78 | DEFINE_PER_CPU(struct rcu_data, rcu_bh_data); |
83 | 79 | ||
84 | extern long rcu_batches_completed_sched(void); | ||
85 | static struct rcu_node *rcu_get_root(struct rcu_state *rsp); | ||
86 | static void cpu_quiet_msk(unsigned long mask, struct rcu_state *rsp, | ||
87 | struct rcu_node *rnp, unsigned long flags); | ||
88 | static void cpu_quiet_msk_finish(struct rcu_state *rsp, unsigned long flags); | ||
89 | #ifdef CONFIG_HOTPLUG_CPU | ||
90 | static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp); | ||
91 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | ||
92 | static void __rcu_process_callbacks(struct rcu_state *rsp, | ||
93 | struct rcu_data *rdp); | ||
94 | static void __call_rcu(struct rcu_head *head, | ||
95 | void (*func)(struct rcu_head *rcu), | ||
96 | struct rcu_state *rsp); | ||
97 | static int __rcu_pending(struct rcu_state *rsp, struct rcu_data *rdp); | ||
98 | static void __cpuinit rcu_init_percpu_data(int cpu, struct rcu_state *rsp, | ||
99 | int preemptable); | ||
100 | 80 | ||
101 | #include "rcutree_plugin.h" | 81 | /* |
82 | * Return true if an RCU grace period is in progress. The ACCESS_ONCE()s | ||
83 | * permit this function to be invoked without holding the root rcu_node | ||
84 | * structure's ->lock, but of course results can be subject to change. | ||
85 | */ | ||
86 | static int rcu_gp_in_progress(struct rcu_state *rsp) | ||
87 | { | ||
88 | return ACCESS_ONCE(rsp->completed) != ACCESS_ONCE(rsp->gpnum); | ||
89 | } | ||
102 | 90 | ||
103 | /* | 91 | /* |
104 | * Note a quiescent state. Because we do not need to know | 92 | * Note a quiescent state. Because we do not need to know |
@@ -137,6 +125,10 @@ static int blimit = 10; /* Maximum callbacks per softirq. */ | |||
137 | static int qhimark = 10000; /* If this many pending, ignore blimit. */ | 125 | static int qhimark = 10000; /* If this many pending, ignore blimit. */ |
138 | static int qlowmark = 100; /* Once only this many pending, use blimit. */ | 126 | static int qlowmark = 100; /* Once only this many pending, use blimit. */ |
139 | 127 | ||
128 | module_param(blimit, int, 0); | ||
129 | module_param(qhimark, int, 0); | ||
130 | module_param(qlowmark, int, 0); | ||
131 | |||
140 | static void force_quiescent_state(struct rcu_state *rsp, int relaxed); | 132 | static void force_quiescent_state(struct rcu_state *rsp, int relaxed); |
141 | static int rcu_pending(int cpu); | 133 | static int rcu_pending(int cpu); |
142 | 134 | ||
@@ -173,9 +165,7 @@ cpu_has_callbacks_ready_to_invoke(struct rcu_data *rdp) | |||
173 | static int | 165 | static int |
174 | cpu_needs_another_gp(struct rcu_state *rsp, struct rcu_data *rdp) | 166 | cpu_needs_another_gp(struct rcu_state *rsp, struct rcu_data *rdp) |
175 | { | 167 | { |
176 | /* ACCESS_ONCE() because we are accessing outside of lock. */ | 168 | return *rdp->nxttail[RCU_DONE_TAIL] && !rcu_gp_in_progress(rsp); |
177 | return *rdp->nxttail[RCU_DONE_TAIL] && | ||
178 | ACCESS_ONCE(rsp->completed) == ACCESS_ONCE(rsp->gpnum); | ||
179 | } | 169 | } |
180 | 170 | ||
181 | /* | 171 | /* |
@@ -369,7 +359,7 @@ static long dyntick_recall_completed(struct rcu_state *rsp) | |||
369 | /* | 359 | /* |
370 | * Snapshot the specified CPU's dynticks counter so that we can later | 360 | * Snapshot the specified CPU's dynticks counter so that we can later |
371 | * credit them with an implicit quiescent state. Return 1 if this CPU | 361 | * credit them with an implicit quiescent state. Return 1 if this CPU |
372 | * is already in a quiescent state courtesy of dynticks idle mode. | 362 | * is in dynticks idle mode, which is an extended quiescent state. |
373 | */ | 363 | */ |
374 | static int dyntick_save_progress_counter(struct rcu_data *rdp) | 364 | static int dyntick_save_progress_counter(struct rcu_data *rdp) |
375 | { | 365 | { |
@@ -475,30 +465,34 @@ static void print_other_cpu_stall(struct rcu_state *rsp) | |||
475 | long delta; | 465 | long delta; |
476 | unsigned long flags; | 466 | unsigned long flags; |
477 | struct rcu_node *rnp = rcu_get_root(rsp); | 467 | struct rcu_node *rnp = rcu_get_root(rsp); |
478 | struct rcu_node *rnp_cur = rsp->level[NUM_RCU_LVLS - 1]; | ||
479 | struct rcu_node *rnp_end = &rsp->node[NUM_RCU_NODES]; | ||
480 | 468 | ||
481 | /* Only let one CPU complain about others per time interval. */ | 469 | /* Only let one CPU complain about others per time interval. */ |
482 | 470 | ||
483 | spin_lock_irqsave(&rnp->lock, flags); | 471 | spin_lock_irqsave(&rnp->lock, flags); |
484 | delta = jiffies - rsp->jiffies_stall; | 472 | delta = jiffies - rsp->jiffies_stall; |
485 | if (delta < RCU_STALL_RAT_DELAY || rsp->gpnum == rsp->completed) { | 473 | if (delta < RCU_STALL_RAT_DELAY || !rcu_gp_in_progress(rsp)) { |
486 | spin_unlock_irqrestore(&rnp->lock, flags); | 474 | spin_unlock_irqrestore(&rnp->lock, flags); |
487 | return; | 475 | return; |
488 | } | 476 | } |
489 | rsp->jiffies_stall = jiffies + RCU_SECONDS_TILL_STALL_RECHECK; | 477 | rsp->jiffies_stall = jiffies + RCU_SECONDS_TILL_STALL_RECHECK; |
478 | |||
479 | /* | ||
480 | * Now rat on any tasks that got kicked up to the root rcu_node | ||
481 | * due to CPU offlining. | ||
482 | */ | ||
483 | rcu_print_task_stall(rnp); | ||
490 | spin_unlock_irqrestore(&rnp->lock, flags); | 484 | spin_unlock_irqrestore(&rnp->lock, flags); |
491 | 485 | ||
492 | /* OK, time to rat on our buddy... */ | 486 | /* OK, time to rat on our buddy... */ |
493 | 487 | ||
494 | printk(KERN_ERR "INFO: RCU detected CPU stalls:"); | 488 | printk(KERN_ERR "INFO: RCU detected CPU stalls:"); |
495 | for (; rnp_cur < rnp_end; rnp_cur++) { | 489 | rcu_for_each_leaf_node(rsp, rnp) { |
496 | rcu_print_task_stall(rnp); | 490 | rcu_print_task_stall(rnp); |
497 | if (rnp_cur->qsmask == 0) | 491 | if (rnp->qsmask == 0) |
498 | continue; | 492 | continue; |
499 | for (cpu = 0; cpu <= rnp_cur->grphi - rnp_cur->grplo; cpu++) | 493 | for (cpu = 0; cpu <= rnp->grphi - rnp->grplo; cpu++) |
500 | if (rnp_cur->qsmask & (1UL << cpu)) | 494 | if (rnp->qsmask & (1UL << cpu)) |
501 | printk(" %d", rnp_cur->grplo + cpu); | 495 | printk(" %d", rnp->grplo + cpu); |
502 | } | 496 | } |
503 | printk(" (detected by %d, t=%ld jiffies)\n", | 497 | printk(" (detected by %d, t=%ld jiffies)\n", |
504 | smp_processor_id(), (long)(jiffies - rsp->gp_start)); | 498 | smp_processor_id(), (long)(jiffies - rsp->gp_start)); |
@@ -537,8 +531,7 @@ static void check_cpu_stall(struct rcu_state *rsp, struct rcu_data *rdp) | |||
537 | /* We haven't checked in, so go dump stack. */ | 531 | /* We haven't checked in, so go dump stack. */ |
538 | print_cpu_stall(rsp); | 532 | print_cpu_stall(rsp); |
539 | 533 | ||
540 | } else if (rsp->gpnum != rsp->completed && | 534 | } else if (rcu_gp_in_progress(rsp) && delta >= RCU_STALL_RAT_DELAY) { |
541 | delta >= RCU_STALL_RAT_DELAY) { | ||
542 | 535 | ||
543 | /* They had two time units to dump stack, so complain. */ | 536 | /* They had two time units to dump stack, so complain. */ |
544 | print_other_cpu_stall(rsp); | 537 | print_other_cpu_stall(rsp); |
@@ -617,9 +610,15 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags) | |||
617 | note_new_gpnum(rsp, rdp); | 610 | note_new_gpnum(rsp, rdp); |
618 | 611 | ||
619 | /* | 612 | /* |
620 | * Because we are first, we know that all our callbacks will | 613 | * Because this CPU just now started the new grace period, we know |
621 | * be covered by this upcoming grace period, even the ones | 614 | * that all of its callbacks will be covered by this upcoming grace |
622 | * that were registered arbitrarily recently. | 615 | * period, even the ones that were registered arbitrarily recently. |
616 | * Therefore, advance all outstanding callbacks to RCU_WAIT_TAIL. | ||
617 | * | ||
618 | * Other CPUs cannot be sure exactly when the grace period started. | ||
619 | * Therefore, their recently registered callbacks must pass through | ||
620 | * an additional RCU_NEXT_READY stage, so that they will be handled | ||
621 | * by the next RCU grace period. | ||
623 | */ | 622 | */ |
624 | rdp->nxttail[RCU_NEXT_READY_TAIL] = rdp->nxttail[RCU_NEXT_TAIL]; | 623 | rdp->nxttail[RCU_NEXT_READY_TAIL] = rdp->nxttail[RCU_NEXT_TAIL]; |
625 | rdp->nxttail[RCU_WAIT_TAIL] = rdp->nxttail[RCU_NEXT_TAIL]; | 624 | rdp->nxttail[RCU_WAIT_TAIL] = rdp->nxttail[RCU_NEXT_TAIL]; |
@@ -657,7 +656,7 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags) | |||
657 | * one corresponding to this CPU, due to the fact that we have | 656 | * one corresponding to this CPU, due to the fact that we have |
658 | * irqs disabled. | 657 | * irqs disabled. |
659 | */ | 658 | */ |
660 | for (rnp = &rsp->node[0]; rnp < &rsp->node[NUM_RCU_NODES]; rnp++) { | 659 | rcu_for_each_node_breadth_first(rsp, rnp) { |
661 | spin_lock(&rnp->lock); /* irqs already disabled. */ | 660 | spin_lock(&rnp->lock); /* irqs already disabled. */ |
662 | rcu_preempt_check_blocked_tasks(rnp); | 661 | rcu_preempt_check_blocked_tasks(rnp); |
663 | rnp->qsmask = rnp->qsmaskinit; | 662 | rnp->qsmask = rnp->qsmaskinit; |
@@ -703,9 +702,9 @@ rcu_process_gp_end(struct rcu_state *rsp, struct rcu_data *rdp) | |||
703 | * hold rnp->lock, as required by rcu_start_gp(), which will release it. | 702 | * hold rnp->lock, as required by rcu_start_gp(), which will release it. |
704 | */ | 703 | */ |
705 | static void cpu_quiet_msk_finish(struct rcu_state *rsp, unsigned long flags) | 704 | static void cpu_quiet_msk_finish(struct rcu_state *rsp, unsigned long flags) |
706 | __releases(rnp->lock) | 705 | __releases(rcu_get_root(rsp)->lock) |
707 | { | 706 | { |
708 | WARN_ON_ONCE(rsp->completed == rsp->gpnum); | 707 | WARN_ON_ONCE(!rcu_gp_in_progress(rsp)); |
709 | rsp->completed = rsp->gpnum; | 708 | rsp->completed = rsp->gpnum; |
710 | rcu_process_gp_end(rsp, rsp->rda[smp_processor_id()]); | 709 | rcu_process_gp_end(rsp, rsp->rda[smp_processor_id()]); |
711 | rcu_start_gp(rsp, flags); /* releases root node's rnp->lock. */ | 710 | rcu_start_gp(rsp, flags); /* releases root node's rnp->lock. */ |
@@ -842,17 +841,63 @@ rcu_check_quiescent_state(struct rcu_state *rsp, struct rcu_data *rdp) | |||
842 | #ifdef CONFIG_HOTPLUG_CPU | 841 | #ifdef CONFIG_HOTPLUG_CPU |
843 | 842 | ||
844 | /* | 843 | /* |
844 | * Move a dying CPU's RCU callbacks to the ->orphan_cbs_list for the | ||
845 | * specified flavor of RCU. The callbacks will be adopted by the next | ||
846 | * _rcu_barrier() invocation or by the CPU_DEAD notifier, whichever | ||
847 | * comes first. Because this is invoked from the CPU_DYING notifier, | ||
848 | * irqs are already disabled. | ||
849 | */ | ||
850 | static void rcu_send_cbs_to_orphanage(struct rcu_state *rsp) | ||
851 | { | ||
852 | int i; | ||
853 | struct rcu_data *rdp = rsp->rda[smp_processor_id()]; | ||
854 | |||
855 | if (rdp->nxtlist == NULL) | ||
856 | return; /* irqs disabled, so comparison is stable. */ | ||
857 | spin_lock(&rsp->onofflock); /* irqs already disabled. */ | ||
858 | *rsp->orphan_cbs_tail = rdp->nxtlist; | ||
859 | rsp->orphan_cbs_tail = rdp->nxttail[RCU_NEXT_TAIL]; | ||
860 | rdp->nxtlist = NULL; | ||
861 | for (i = 0; i < RCU_NEXT_SIZE; i++) | ||
862 | rdp->nxttail[i] = &rdp->nxtlist; | ||
863 | rsp->orphan_qlen += rdp->qlen; | ||
864 | rdp->qlen = 0; | ||
865 | spin_unlock(&rsp->onofflock); /* irqs remain disabled. */ | ||
866 | } | ||
867 | |||
868 | /* | ||
869 | * Adopt previously orphaned RCU callbacks. | ||
870 | */ | ||
871 | static void rcu_adopt_orphan_cbs(struct rcu_state *rsp) | ||
872 | { | ||
873 | unsigned long flags; | ||
874 | struct rcu_data *rdp; | ||
875 | |||
876 | spin_lock_irqsave(&rsp->onofflock, flags); | ||
877 | rdp = rsp->rda[smp_processor_id()]; | ||
878 | if (rsp->orphan_cbs_list == NULL) { | ||
879 | spin_unlock_irqrestore(&rsp->onofflock, flags); | ||
880 | return; | ||
881 | } | ||
882 | *rdp->nxttail[RCU_NEXT_TAIL] = rsp->orphan_cbs_list; | ||
883 | rdp->nxttail[RCU_NEXT_TAIL] = rsp->orphan_cbs_tail; | ||
884 | rdp->qlen += rsp->orphan_qlen; | ||
885 | rsp->orphan_cbs_list = NULL; | ||
886 | rsp->orphan_cbs_tail = &rsp->orphan_cbs_list; | ||
887 | rsp->orphan_qlen = 0; | ||
888 | spin_unlock_irqrestore(&rsp->onofflock, flags); | ||
889 | } | ||
890 | |||
891 | /* | ||
845 | * Remove the outgoing CPU from the bitmasks in the rcu_node hierarchy | 892 | * Remove the outgoing CPU from the bitmasks in the rcu_node hierarchy |
846 | * and move all callbacks from the outgoing CPU to the current one. | 893 | * and move all callbacks from the outgoing CPU to the current one. |
847 | */ | 894 | */ |
848 | static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp) | 895 | static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp) |
849 | { | 896 | { |
850 | int i; | ||
851 | unsigned long flags; | 897 | unsigned long flags; |
852 | long lastcomp; | 898 | long lastcomp; |
853 | unsigned long mask; | 899 | unsigned long mask; |
854 | struct rcu_data *rdp = rsp->rda[cpu]; | 900 | struct rcu_data *rdp = rsp->rda[cpu]; |
855 | struct rcu_data *rdp_me; | ||
856 | struct rcu_node *rnp; | 901 | struct rcu_node *rnp; |
857 | 902 | ||
858 | /* Exclude any attempts to start a new grace period. */ | 903 | /* Exclude any attempts to start a new grace period. */ |
@@ -875,32 +920,9 @@ static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp) | |||
875 | } while (rnp != NULL); | 920 | } while (rnp != NULL); |
876 | lastcomp = rsp->completed; | 921 | lastcomp = rsp->completed; |
877 | 922 | ||
878 | spin_unlock(&rsp->onofflock); /* irqs remain disabled. */ | 923 | spin_unlock_irqrestore(&rsp->onofflock, flags); |
879 | 924 | ||
880 | /* | 925 | rcu_adopt_orphan_cbs(rsp); |
881 | * Move callbacks from the outgoing CPU to the running CPU. | ||
882 | * Note that the outgoing CPU is now quiscent, so it is now | ||
883 | * (uncharacteristically) safe to access its rcu_data structure. | ||
884 | * Note also that we must carefully retain the order of the | ||
885 | * outgoing CPU's callbacks in order for rcu_barrier() to work | ||
886 | * correctly. Finally, note that we start all the callbacks | ||
887 | * afresh, even those that have passed through a grace period | ||
888 | * and are therefore ready to invoke. The theory is that hotplug | ||
889 | * events are rare, and that if they are frequent enough to | ||
890 | * indefinitely delay callbacks, you have far worse things to | ||
891 | * be worrying about. | ||
892 | */ | ||
893 | rdp_me = rsp->rda[smp_processor_id()]; | ||
894 | if (rdp->nxtlist != NULL) { | ||
895 | *rdp_me->nxttail[RCU_NEXT_TAIL] = rdp->nxtlist; | ||
896 | rdp_me->nxttail[RCU_NEXT_TAIL] = rdp->nxttail[RCU_NEXT_TAIL]; | ||
897 | rdp->nxtlist = NULL; | ||
898 | for (i = 0; i < RCU_NEXT_SIZE; i++) | ||
899 | rdp->nxttail[i] = &rdp->nxtlist; | ||
900 | rdp_me->qlen += rdp->qlen; | ||
901 | rdp->qlen = 0; | ||
902 | } | ||
903 | local_irq_restore(flags); | ||
904 | } | 926 | } |
905 | 927 | ||
906 | /* | 928 | /* |
@@ -918,6 +940,14 @@ static void rcu_offline_cpu(int cpu) | |||
918 | 940 | ||
919 | #else /* #ifdef CONFIG_HOTPLUG_CPU */ | 941 | #else /* #ifdef CONFIG_HOTPLUG_CPU */ |
920 | 942 | ||
943 | static void rcu_send_cbs_to_orphanage(struct rcu_state *rsp) | ||
944 | { | ||
945 | } | ||
946 | |||
947 | static void rcu_adopt_orphan_cbs(struct rcu_state *rsp) | ||
948 | { | ||
949 | } | ||
950 | |||
921 | static void rcu_offline_cpu(int cpu) | 951 | static void rcu_offline_cpu(int cpu) |
922 | { | 952 | { |
923 | } | 953 | } |
@@ -1050,33 +1080,32 @@ static int rcu_process_dyntick(struct rcu_state *rsp, long lastcomp, | |||
1050 | int cpu; | 1080 | int cpu; |
1051 | unsigned long flags; | 1081 | unsigned long flags; |
1052 | unsigned long mask; | 1082 | unsigned long mask; |
1053 | struct rcu_node *rnp_cur = rsp->level[NUM_RCU_LVLS - 1]; | 1083 | struct rcu_node *rnp; |
1054 | struct rcu_node *rnp_end = &rsp->node[NUM_RCU_NODES]; | ||
1055 | 1084 | ||
1056 | for (; rnp_cur < rnp_end; rnp_cur++) { | 1085 | rcu_for_each_leaf_node(rsp, rnp) { |
1057 | mask = 0; | 1086 | mask = 0; |
1058 | spin_lock_irqsave(&rnp_cur->lock, flags); | 1087 | spin_lock_irqsave(&rnp->lock, flags); |
1059 | if (rsp->completed != lastcomp) { | 1088 | if (rsp->completed != lastcomp) { |
1060 | spin_unlock_irqrestore(&rnp_cur->lock, flags); | 1089 | spin_unlock_irqrestore(&rnp->lock, flags); |
1061 | return 1; | 1090 | return 1; |
1062 | } | 1091 | } |
1063 | if (rnp_cur->qsmask == 0) { | 1092 | if (rnp->qsmask == 0) { |
1064 | spin_unlock_irqrestore(&rnp_cur->lock, flags); | 1093 | spin_unlock_irqrestore(&rnp->lock, flags); |
1065 | continue; | 1094 | continue; |
1066 | } | 1095 | } |
1067 | cpu = rnp_cur->grplo; | 1096 | cpu = rnp->grplo; |
1068 | bit = 1; | 1097 | bit = 1; |
1069 | for (; cpu <= rnp_cur->grphi; cpu++, bit <<= 1) { | 1098 | for (; cpu <= rnp->grphi; cpu++, bit <<= 1) { |
1070 | if ((rnp_cur->qsmask & bit) != 0 && f(rsp->rda[cpu])) | 1099 | if ((rnp->qsmask & bit) != 0 && f(rsp->rda[cpu])) |
1071 | mask |= bit; | 1100 | mask |= bit; |
1072 | } | 1101 | } |
1073 | if (mask != 0 && rsp->completed == lastcomp) { | 1102 | if (mask != 0 && rsp->completed == lastcomp) { |
1074 | 1103 | ||
1075 | /* cpu_quiet_msk() releases rnp_cur->lock. */ | 1104 | /* cpu_quiet_msk() releases rnp->lock. */ |
1076 | cpu_quiet_msk(mask, rsp, rnp_cur, flags); | 1105 | cpu_quiet_msk(mask, rsp, rnp, flags); |
1077 | continue; | 1106 | continue; |
1078 | } | 1107 | } |
1079 | spin_unlock_irqrestore(&rnp_cur->lock, flags); | 1108 | spin_unlock_irqrestore(&rnp->lock, flags); |
1080 | } | 1109 | } |
1081 | return 0; | 1110 | return 0; |
1082 | } | 1111 | } |
@@ -1092,7 +1121,7 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed) | |||
1092 | struct rcu_node *rnp = rcu_get_root(rsp); | 1121 | struct rcu_node *rnp = rcu_get_root(rsp); |
1093 | u8 signaled; | 1122 | u8 signaled; |
1094 | 1123 | ||
1095 | if (ACCESS_ONCE(rsp->completed) == ACCESS_ONCE(rsp->gpnum)) | 1124 | if (!rcu_gp_in_progress(rsp)) |
1096 | return; /* No grace period in progress, nothing to force. */ | 1125 | return; /* No grace period in progress, nothing to force. */ |
1097 | if (!spin_trylock_irqsave(&rsp->fqslock, flags)) { | 1126 | if (!spin_trylock_irqsave(&rsp->fqslock, flags)) { |
1098 | rsp->n_force_qs_lh++; /* Inexact, can lose counts. Tough! */ | 1127 | rsp->n_force_qs_lh++; /* Inexact, can lose counts. Tough! */ |
@@ -1251,7 +1280,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu), | |||
1251 | rdp->nxttail[RCU_NEXT_TAIL] = &head->next; | 1280 | rdp->nxttail[RCU_NEXT_TAIL] = &head->next; |
1252 | 1281 | ||
1253 | /* Start a new grace period if one not already started. */ | 1282 | /* Start a new grace period if one not already started. */ |
1254 | if (ACCESS_ONCE(rsp->completed) == ACCESS_ONCE(rsp->gpnum)) { | 1283 | if (!rcu_gp_in_progress(rsp)) { |
1255 | unsigned long nestflag; | 1284 | unsigned long nestflag; |
1256 | struct rcu_node *rnp_root = rcu_get_root(rsp); | 1285 | struct rcu_node *rnp_root = rcu_get_root(rsp); |
1257 | 1286 | ||
@@ -1331,7 +1360,7 @@ static int __rcu_pending(struct rcu_state *rsp, struct rcu_data *rdp) | |||
1331 | } | 1360 | } |
1332 | 1361 | ||
1333 | /* Has an RCU GP gone long enough to send resched IPIs &c? */ | 1362 | /* Has an RCU GP gone long enough to send resched IPIs &c? */ |
1334 | if (ACCESS_ONCE(rsp->completed) != ACCESS_ONCE(rsp->gpnum) && | 1363 | if (rcu_gp_in_progress(rsp) && |
1335 | ((long)(ACCESS_ONCE(rsp->jiffies_force_qs) - jiffies) < 0)) { | 1364 | ((long)(ACCESS_ONCE(rsp->jiffies_force_qs) - jiffies) < 0)) { |
1336 | rdp->n_rp_need_fqs++; | 1365 | rdp->n_rp_need_fqs++; |
1337 | return 1; | 1366 | return 1; |
@@ -1368,6 +1397,82 @@ int rcu_needs_cpu(int cpu) | |||
1368 | rcu_preempt_needs_cpu(cpu); | 1397 | rcu_preempt_needs_cpu(cpu); |
1369 | } | 1398 | } |
1370 | 1399 | ||
1400 | static DEFINE_PER_CPU(struct rcu_head, rcu_barrier_head) = {NULL}; | ||
1401 | static atomic_t rcu_barrier_cpu_count; | ||
1402 | static DEFINE_MUTEX(rcu_barrier_mutex); | ||
1403 | static struct completion rcu_barrier_completion; | ||
1404 | |||
1405 | static void rcu_barrier_callback(struct rcu_head *notused) | ||
1406 | { | ||
1407 | if (atomic_dec_and_test(&rcu_barrier_cpu_count)) | ||
1408 | complete(&rcu_barrier_completion); | ||
1409 | } | ||
1410 | |||
1411 | /* | ||
1412 | * Called with preemption disabled, and from cross-cpu IRQ context. | ||
1413 | */ | ||
1414 | static void rcu_barrier_func(void *type) | ||
1415 | { | ||
1416 | int cpu = smp_processor_id(); | ||
1417 | struct rcu_head *head = &per_cpu(rcu_barrier_head, cpu); | ||
1418 | void (*call_rcu_func)(struct rcu_head *head, | ||
1419 | void (*func)(struct rcu_head *head)); | ||
1420 | |||
1421 | atomic_inc(&rcu_barrier_cpu_count); | ||
1422 | call_rcu_func = type; | ||
1423 | call_rcu_func(head, rcu_barrier_callback); | ||
1424 | } | ||
1425 | |||
1426 | /* | ||
1427 | * Orchestrate the specified type of RCU barrier, waiting for all | ||
1428 | * RCU callbacks of the specified type to complete. | ||
1429 | */ | ||
1430 | static void _rcu_barrier(struct rcu_state *rsp, | ||
1431 | void (*call_rcu_func)(struct rcu_head *head, | ||
1432 | void (*func)(struct rcu_head *head))) | ||
1433 | { | ||
1434 | BUG_ON(in_interrupt()); | ||
1435 | /* Take mutex to serialize concurrent rcu_barrier() requests. */ | ||
1436 | mutex_lock(&rcu_barrier_mutex); | ||
1437 | init_completion(&rcu_barrier_completion); | ||
1438 | /* | ||
1439 | * Initialize rcu_barrier_cpu_count to 1, then invoke | ||
1440 | * rcu_barrier_func() on each CPU, so that each CPU also has | ||
1441 | * incremented rcu_barrier_cpu_count. Only then is it safe to | ||
1442 | * decrement rcu_barrier_cpu_count -- otherwise the first CPU | ||
1443 | * might complete its grace period before all of the other CPUs | ||
1444 | * did their increment, causing this function to return too | ||
1445 | * early. | ||
1446 | */ | ||
1447 | atomic_set(&rcu_barrier_cpu_count, 1); | ||
1448 | preempt_disable(); /* stop CPU_DYING from filling orphan_cbs_list */ | ||
1449 | rcu_adopt_orphan_cbs(rsp); | ||
1450 | on_each_cpu(rcu_barrier_func, (void *)call_rcu_func, 1); | ||
1451 | preempt_enable(); /* CPU_DYING can again fill orphan_cbs_list */ | ||
1452 | if (atomic_dec_and_test(&rcu_barrier_cpu_count)) | ||
1453 | complete(&rcu_barrier_completion); | ||
1454 | wait_for_completion(&rcu_barrier_completion); | ||
1455 | mutex_unlock(&rcu_barrier_mutex); | ||
1456 | } | ||
1457 | |||
1458 | /** | ||
1459 | * rcu_barrier_bh - Wait until all in-flight call_rcu_bh() callbacks complete. | ||
1460 | */ | ||
1461 | void rcu_barrier_bh(void) | ||
1462 | { | ||
1463 | _rcu_barrier(&rcu_bh_state, call_rcu_bh); | ||
1464 | } | ||
1465 | EXPORT_SYMBOL_GPL(rcu_barrier_bh); | ||
1466 | |||
1467 | /** | ||
1468 | * rcu_barrier_sched - Wait for in-flight call_rcu_sched() callbacks. | ||
1469 | */ | ||
1470 | void rcu_barrier_sched(void) | ||
1471 | { | ||
1472 | _rcu_barrier(&rcu_sched_state, call_rcu_sched); | ||
1473 | } | ||
1474 | EXPORT_SYMBOL_GPL(rcu_barrier_sched); | ||
1475 | |||
1371 | /* | 1476 | /* |
1372 | * Do boot-time initialization of a CPU's per-CPU RCU data. | 1477 | * Do boot-time initialization of a CPU's per-CPU RCU data. |
1373 | */ | 1478 | */ |
@@ -1464,6 +1569,22 @@ int __cpuinit rcu_cpu_notify(struct notifier_block *self, | |||
1464 | case CPU_UP_PREPARE_FROZEN: | 1569 | case CPU_UP_PREPARE_FROZEN: |
1465 | rcu_online_cpu(cpu); | 1570 | rcu_online_cpu(cpu); |
1466 | break; | 1571 | break; |
1572 | case CPU_DYING: | ||
1573 | case CPU_DYING_FROZEN: | ||
1574 | /* | ||
1575 | * preempt_disable() in _rcu_barrier() prevents stop_machine(), | ||
1576 | * so when "on_each_cpu(rcu_barrier_func, (void *)type, 1);" | ||
1577 | * returns, all online cpus have queued rcu_barrier_func(). | ||
1578 | * The dying CPU clears its cpu_online_mask bit and | ||
1579 | * moves all of its RCU callbacks to ->orphan_cbs_list | ||
1580 | * in the context of stop_machine(), so subsequent calls | ||
1581 | * to _rcu_barrier() will adopt these callbacks and only | ||
1582 | * then queue rcu_barrier_func() on all remaining CPUs. | ||
1583 | */ | ||
1584 | rcu_send_cbs_to_orphanage(&rcu_bh_state); | ||
1585 | rcu_send_cbs_to_orphanage(&rcu_sched_state); | ||
1586 | rcu_preempt_send_cbs_to_orphanage(); | ||
1587 | break; | ||
1467 | case CPU_DEAD: | 1588 | case CPU_DEAD: |
1468 | case CPU_DEAD_FROZEN: | 1589 | case CPU_DEAD_FROZEN: |
1469 | case CPU_UP_CANCELED: | 1590 | case CPU_UP_CANCELED: |
@@ -1526,7 +1647,8 @@ static void __init rcu_init_one(struct rcu_state *rsp) | |||
1526 | cpustride *= rsp->levelspread[i]; | 1647 | cpustride *= rsp->levelspread[i]; |
1527 | rnp = rsp->level[i]; | 1648 | rnp = rsp->level[i]; |
1528 | for (j = 0; j < rsp->levelcnt[i]; j++, rnp++) { | 1649 | for (j = 0; j < rsp->levelcnt[i]; j++, rnp++) { |
1529 | spin_lock_init(&rnp->lock); | 1650 | if (rnp != rcu_get_root(rsp)) |
1651 | spin_lock_init(&rnp->lock); | ||
1530 | rnp->gpnum = 0; | 1652 | rnp->gpnum = 0; |
1531 | rnp->qsmask = 0; | 1653 | rnp->qsmask = 0; |
1532 | rnp->qsmaskinit = 0; | 1654 | rnp->qsmaskinit = 0; |
@@ -1549,6 +1671,7 @@ static void __init rcu_init_one(struct rcu_state *rsp) | |||
1549 | INIT_LIST_HEAD(&rnp->blocked_tasks[1]); | 1671 | INIT_LIST_HEAD(&rnp->blocked_tasks[1]); |
1550 | } | 1672 | } |
1551 | } | 1673 | } |
1674 | spin_lock_init(&rcu_get_root(rsp)->lock); | ||
1552 | } | 1675 | } |
1553 | 1676 | ||
1554 | /* | 1677 | /* |
@@ -1558,6 +1681,10 @@ static void __init rcu_init_one(struct rcu_state *rsp) | |||
1558 | */ | 1681 | */ |
1559 | #define RCU_INIT_FLAVOR(rsp, rcu_data) \ | 1682 | #define RCU_INIT_FLAVOR(rsp, rcu_data) \ |
1560 | do { \ | 1683 | do { \ |
1684 | int i; \ | ||
1685 | int j; \ | ||
1686 | struct rcu_node *rnp; \ | ||
1687 | \ | ||
1561 | rcu_init_one(rsp); \ | 1688 | rcu_init_one(rsp); \ |
1562 | rnp = (rsp)->level[NUM_RCU_LVLS - 1]; \ | 1689 | rnp = (rsp)->level[NUM_RCU_LVLS - 1]; \ |
1563 | j = 0; \ | 1690 | j = 0; \ |
@@ -1570,31 +1697,8 @@ do { \ | |||
1570 | } \ | 1697 | } \ |
1571 | } while (0) | 1698 | } while (0) |
1572 | 1699 | ||
1573 | #ifdef CONFIG_TREE_PREEMPT_RCU | ||
1574 | |||
1575 | void __init __rcu_init_preempt(void) | ||
1576 | { | ||
1577 | int i; /* All used by RCU_INIT_FLAVOR(). */ | ||
1578 | int j; | ||
1579 | struct rcu_node *rnp; | ||
1580 | |||
1581 | RCU_INIT_FLAVOR(&rcu_preempt_state, rcu_preempt_data); | ||
1582 | } | ||
1583 | |||
1584 | #else /* #ifdef CONFIG_TREE_PREEMPT_RCU */ | ||
1585 | |||
1586 | void __init __rcu_init_preempt(void) | ||
1587 | { | ||
1588 | } | ||
1589 | |||
1590 | #endif /* #else #ifdef CONFIG_TREE_PREEMPT_RCU */ | ||
1591 | |||
1592 | void __init __rcu_init(void) | 1700 | void __init __rcu_init(void) |
1593 | { | 1701 | { |
1594 | int i; /* All used by RCU_INIT_FLAVOR(). */ | ||
1595 | int j; | ||
1596 | struct rcu_node *rnp; | ||
1597 | |||
1598 | rcu_bootup_announce(); | 1702 | rcu_bootup_announce(); |
1599 | #ifdef CONFIG_RCU_CPU_STALL_DETECTOR | 1703 | #ifdef CONFIG_RCU_CPU_STALL_DETECTOR |
1600 | printk(KERN_INFO "RCU-based detection of stalled CPUs is enabled.\n"); | 1704 | printk(KERN_INFO "RCU-based detection of stalled CPUs is enabled.\n"); |
@@ -1605,6 +1709,4 @@ void __init __rcu_init(void) | |||
1605 | open_softirq(RCU_SOFTIRQ, rcu_process_callbacks); | 1709 | open_softirq(RCU_SOFTIRQ, rcu_process_callbacks); |
1606 | } | 1710 | } |
1607 | 1711 | ||
1608 | module_param(blimit, int, 0); | 1712 | #include "rcutree_plugin.h" |
1609 | module_param(qhimark, int, 0); | ||
1610 | module_param(qlowmark, int, 0); | ||
diff --git a/kernel/rcutree.h b/kernel/rcutree.h index 8e8287a983c2..b40ac5706040 100644 --- a/kernel/rcutree.h +++ b/kernel/rcutree.h | |||
@@ -48,14 +48,14 @@ | |||
48 | #elif NR_CPUS <= RCU_FANOUT_SQ | 48 | #elif NR_CPUS <= RCU_FANOUT_SQ |
49 | # define NUM_RCU_LVLS 2 | 49 | # define NUM_RCU_LVLS 2 |
50 | # define NUM_RCU_LVL_0 1 | 50 | # define NUM_RCU_LVL_0 1 |
51 | # define NUM_RCU_LVL_1 (((NR_CPUS) + RCU_FANOUT - 1) / RCU_FANOUT) | 51 | # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT) |
52 | # define NUM_RCU_LVL_2 (NR_CPUS) | 52 | # define NUM_RCU_LVL_2 (NR_CPUS) |
53 | # define NUM_RCU_LVL_3 0 | 53 | # define NUM_RCU_LVL_3 0 |
54 | #elif NR_CPUS <= RCU_FANOUT_CUBE | 54 | #elif NR_CPUS <= RCU_FANOUT_CUBE |
55 | # define NUM_RCU_LVLS 3 | 55 | # define NUM_RCU_LVLS 3 |
56 | # define NUM_RCU_LVL_0 1 | 56 | # define NUM_RCU_LVL_0 1 |
57 | # define NUM_RCU_LVL_1 (((NR_CPUS) + RCU_FANOUT_SQ - 1) / RCU_FANOUT_SQ) | 57 | # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_SQ) |
58 | # define NUM_RCU_LVL_2 (((NR_CPUS) + (RCU_FANOUT) - 1) / (RCU_FANOUT)) | 58 | # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT) |
59 | # define NUM_RCU_LVL_3 NR_CPUS | 59 | # define NUM_RCU_LVL_3 NR_CPUS |
60 | #else | 60 | #else |
61 | # error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" | 61 | # error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" |
@@ -79,15 +79,21 @@ struct rcu_dynticks { | |||
79 | * Definition for node within the RCU grace-period-detection hierarchy. | 79 | * Definition for node within the RCU grace-period-detection hierarchy. |
80 | */ | 80 | */ |
81 | struct rcu_node { | 81 | struct rcu_node { |
82 | spinlock_t lock; | 82 | spinlock_t lock; /* Root rcu_node's lock protects some */ |
83 | /* rcu_state fields as well as following. */ | ||
83 | long gpnum; /* Current grace period for this node. */ | 84 | long gpnum; /* Current grace period for this node. */ |
84 | /* This will either be equal to or one */ | 85 | /* This will either be equal to or one */ |
85 | /* behind the root rcu_node's gpnum. */ | 86 | /* behind the root rcu_node's gpnum. */ |
86 | unsigned long qsmask; /* CPUs or groups that need to switch in */ | 87 | unsigned long qsmask; /* CPUs or groups that need to switch in */ |
87 | /* order for current grace period to proceed.*/ | 88 | /* order for current grace period to proceed.*/ |
89 | /* In leaf rcu_node, each bit corresponds to */ | ||
90 | /* an rcu_data structure, otherwise, each */ | ||
91 | /* bit corresponds to a child rcu_node */ | ||
92 | /* structure. */ | ||
88 | unsigned long qsmaskinit; | 93 | unsigned long qsmaskinit; |
89 | /* Per-GP initialization for qsmask. */ | 94 | /* Per-GP initialization for qsmask. */ |
90 | unsigned long grpmask; /* Mask to apply to parent qsmask. */ | 95 | unsigned long grpmask; /* Mask to apply to parent qsmask. */ |
96 | /* Only one bit will be set in this mask. */ | ||
91 | int grplo; /* lowest-numbered CPU or group here. */ | 97 | int grplo; /* lowest-numbered CPU or group here. */ |
92 | int grphi; /* highest-numbered CPU or group here. */ | 98 | int grphi; /* highest-numbered CPU or group here. */ |
93 | u8 grpnum; /* CPU/group number for next level up. */ | 99 | u8 grpnum; /* CPU/group number for next level up. */ |
@@ -95,8 +101,23 @@ struct rcu_node { | |||
95 | struct rcu_node *parent; | 101 | struct rcu_node *parent; |
96 | struct list_head blocked_tasks[2]; | 102 | struct list_head blocked_tasks[2]; |
97 | /* Tasks blocked in RCU read-side critsect. */ | 103 | /* Tasks blocked in RCU read-side critsect. */ |
104 | /* Grace period number (->gpnum) x blocked */ | ||
105 | /* by tasks on the (x & 0x1) element of the */ | ||
106 | /* blocked_tasks[] array. */ | ||
98 | } ____cacheline_internodealigned_in_smp; | 107 | } ____cacheline_internodealigned_in_smp; |
99 | 108 | ||
109 | /* | ||
110 | * Do a full breadth-first scan of the rcu_node structures for the | ||
111 | * specified rcu_state structure. | ||
112 | */ | ||
113 | #define rcu_for_each_node_breadth_first(rsp, rnp) \ | ||
114 | for ((rnp) = &(rsp)->node[0]; \ | ||
115 | (rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++) | ||
116 | |||
117 | #define rcu_for_each_leaf_node(rsp, rnp) \ | ||
118 | for ((rnp) = (rsp)->level[NUM_RCU_LVLS - 1]; \ | ||
119 | (rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++) | ||
120 | |||
100 | /* Index values for nxttail array in struct rcu_data. */ | 121 | /* Index values for nxttail array in struct rcu_data. */ |
101 | #define RCU_DONE_TAIL 0 /* Also RCU_WAIT head. */ | 122 | #define RCU_DONE_TAIL 0 /* Also RCU_WAIT head. */ |
102 | #define RCU_WAIT_TAIL 1 /* Also RCU_NEXT_READY head. */ | 123 | #define RCU_WAIT_TAIL 1 /* Also RCU_NEXT_READY head. */ |
@@ -126,19 +147,22 @@ struct rcu_data { | |||
126 | * Any of the partitions might be empty, in which case the | 147 | * Any of the partitions might be empty, in which case the |
127 | * pointer to that partition will be equal to the pointer for | 148 | * pointer to that partition will be equal to the pointer for |
128 | * the following partition. When the list is empty, all of | 149 | * the following partition. When the list is empty, all of |
129 | * the nxttail elements point to nxtlist, which is NULL. | 150 | * the nxttail elements point to the ->nxtlist pointer itself, |
151 | * which in that case is NULL. | ||
130 | * | 152 | * |
131 | * [*nxttail[RCU_NEXT_READY_TAIL], NULL = *nxttail[RCU_NEXT_TAIL]): | ||
132 | * Entries that might have arrived after current GP ended | ||
133 | * [*nxttail[RCU_WAIT_TAIL], *nxttail[RCU_NEXT_READY_TAIL]): | ||
134 | * Entries known to have arrived before current GP ended | ||
135 | * [*nxttail[RCU_DONE_TAIL], *nxttail[RCU_WAIT_TAIL]): | ||
136 | * Entries that batch # <= ->completed - 1: waiting for current GP | ||
137 | * [nxtlist, *nxttail[RCU_DONE_TAIL]): | 153 | * [nxtlist, *nxttail[RCU_DONE_TAIL]): |
138 | * Entries that batch # <= ->completed | 154 | * Entries that batch # <= ->completed |
139 | * The grace period for these entries has completed, and | 155 | * The grace period for these entries has completed, and |
140 | * the other grace-period-completed entries may be moved | 156 | * the other grace-period-completed entries may be moved |
141 | * here temporarily in rcu_process_callbacks(). | 157 | * here temporarily in rcu_process_callbacks(). |
158 | * [*nxttail[RCU_DONE_TAIL], *nxttail[RCU_WAIT_TAIL]): | ||
159 | * Entries that batch # <= ->completed - 1: waiting for current GP | ||
160 | * [*nxttail[RCU_WAIT_TAIL], *nxttail[RCU_NEXT_READY_TAIL]): | ||
161 | * Entries known to have arrived before current GP ended | ||
162 | * [*nxttail[RCU_NEXT_READY_TAIL], *nxttail[RCU_NEXT_TAIL]): | ||
163 | * Entries that might have arrived after current GP ended | ||
164 | * Note that the value of *nxttail[RCU_NEXT_TAIL] will | ||
165 | * always be NULL, as this is the end of the list. | ||
142 | */ | 166 | */ |
143 | struct rcu_head *nxtlist; | 167 | struct rcu_head *nxtlist; |
144 | struct rcu_head **nxttail[RCU_NEXT_SIZE]; | 168 | struct rcu_head **nxttail[RCU_NEXT_SIZE]; |
@@ -216,8 +240,19 @@ struct rcu_state { | |||
216 | /* Force QS state. */ | 240 | /* Force QS state. */ |
217 | long gpnum; /* Current gp number. */ | 241 | long gpnum; /* Current gp number. */ |
218 | long completed; /* # of last completed gp. */ | 242 | long completed; /* # of last completed gp. */ |
243 | |||
244 | /* End of fields guarded by root rcu_node's lock. */ | ||
245 | |||
219 | spinlock_t onofflock; /* exclude on/offline and */ | 246 | spinlock_t onofflock; /* exclude on/offline and */ |
220 | /* starting new GP. */ | 247 | /* starting new GP. Also */ |
248 | /* protects the following */ | ||
249 | /* orphan_cbs fields. */ | ||
250 | struct rcu_head *orphan_cbs_list; /* list of rcu_head structs */ | ||
251 | /* orphaned by all CPUs in */ | ||
252 | /* a given leaf rcu_node */ | ||
253 | /* going offline. */ | ||
254 | struct rcu_head **orphan_cbs_tail; /* And tail pointer. */ | ||
255 | long orphan_qlen; /* Number of orphaned cbs. */ | ||
221 | spinlock_t fqslock; /* Only one task forcing */ | 256 | spinlock_t fqslock; /* Only one task forcing */ |
222 | /* quiescent states. */ | 257 | /* quiescent states. */ |
223 | unsigned long jiffies_force_qs; /* Time at which to invoke */ | 258 | unsigned long jiffies_force_qs; /* Time at which to invoke */ |
@@ -255,5 +290,30 @@ extern struct rcu_state rcu_preempt_state; | |||
255 | DECLARE_PER_CPU(struct rcu_data, rcu_preempt_data); | 290 | DECLARE_PER_CPU(struct rcu_data, rcu_preempt_data); |
256 | #endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */ | 291 | #endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */ |
257 | 292 | ||
258 | #endif /* #ifdef RCU_TREE_NONCORE */ | 293 | #else /* #ifdef RCU_TREE_NONCORE */ |
294 | |||
295 | /* Forward declarations for rcutree_plugin.h */ | ||
296 | static inline void rcu_bootup_announce(void); | ||
297 | long rcu_batches_completed(void); | ||
298 | static void rcu_preempt_note_context_switch(int cpu); | ||
299 | static int rcu_preempted_readers(struct rcu_node *rnp); | ||
300 | #ifdef CONFIG_RCU_CPU_STALL_DETECTOR | ||
301 | static void rcu_print_task_stall(struct rcu_node *rnp); | ||
302 | #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ | ||
303 | static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp); | ||
304 | #ifdef CONFIG_HOTPLUG_CPU | ||
305 | static void rcu_preempt_offline_tasks(struct rcu_state *rsp, | ||
306 | struct rcu_node *rnp, | ||
307 | struct rcu_data *rdp); | ||
308 | static void rcu_preempt_offline_cpu(int cpu); | ||
309 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | ||
310 | static void rcu_preempt_check_callbacks(int cpu); | ||
311 | static void rcu_preempt_process_callbacks(void); | ||
312 | void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu)); | ||
313 | static int rcu_preempt_pending(int cpu); | ||
314 | static int rcu_preempt_needs_cpu(int cpu); | ||
315 | static void __cpuinit rcu_preempt_init_percpu_data(int cpu); | ||
316 | static void rcu_preempt_send_cbs_to_orphanage(void); | ||
317 | static void __init __rcu_init_preempt(void); | ||
259 | 318 | ||
319 | #endif /* #else #ifdef RCU_TREE_NONCORE */ | ||
diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h index 1cee04f627eb..c0cb783aa16a 100644 --- a/kernel/rcutree_plugin.h +++ b/kernel/rcutree_plugin.h | |||
@@ -150,6 +150,16 @@ void __rcu_read_lock(void) | |||
150 | } | 150 | } |
151 | EXPORT_SYMBOL_GPL(__rcu_read_lock); | 151 | EXPORT_SYMBOL_GPL(__rcu_read_lock); |
152 | 152 | ||
153 | /* | ||
154 | * Check for preempted RCU readers blocking the current grace period | ||
155 | * for the specified rcu_node structure. If the caller needs a reliable | ||
156 | * answer, it must hold the rcu_node's ->lock. | ||
157 | */ | ||
158 | static int rcu_preempted_readers(struct rcu_node *rnp) | ||
159 | { | ||
160 | return !list_empty(&rnp->blocked_tasks[rnp->gpnum & 0x1]); | ||
161 | } | ||
162 | |||
153 | static void rcu_read_unlock_special(struct task_struct *t) | 163 | static void rcu_read_unlock_special(struct task_struct *t) |
154 | { | 164 | { |
155 | int empty; | 165 | int empty; |
@@ -196,7 +206,7 @@ static void rcu_read_unlock_special(struct task_struct *t) | |||
196 | break; | 206 | break; |
197 | spin_unlock(&rnp->lock); /* irqs remain disabled. */ | 207 | spin_unlock(&rnp->lock); /* irqs remain disabled. */ |
198 | } | 208 | } |
199 | empty = list_empty(&rnp->blocked_tasks[rnp->gpnum & 0x1]); | 209 | empty = !rcu_preempted_readers(rnp); |
200 | list_del_init(&t->rcu_node_entry); | 210 | list_del_init(&t->rcu_node_entry); |
201 | t->rcu_blocked_node = NULL; | 211 | t->rcu_blocked_node = NULL; |
202 | 212 | ||
@@ -207,7 +217,7 @@ static void rcu_read_unlock_special(struct task_struct *t) | |||
207 | * drop rnp->lock and restore irq. | 217 | * drop rnp->lock and restore irq. |
208 | */ | 218 | */ |
209 | if (!empty && rnp->qsmask == 0 && | 219 | if (!empty && rnp->qsmask == 0 && |
210 | list_empty(&rnp->blocked_tasks[rnp->gpnum & 0x1])) { | 220 | !rcu_preempted_readers(rnp)) { |
211 | struct rcu_node *rnp_p; | 221 | struct rcu_node *rnp_p; |
212 | 222 | ||
213 | if (rnp->parent == NULL) { | 223 | if (rnp->parent == NULL) { |
@@ -257,12 +267,12 @@ static void rcu_print_task_stall(struct rcu_node *rnp) | |||
257 | { | 267 | { |
258 | unsigned long flags; | 268 | unsigned long flags; |
259 | struct list_head *lp; | 269 | struct list_head *lp; |
260 | int phase = rnp->gpnum & 0x1; | 270 | int phase; |
261 | struct task_struct *t; | 271 | struct task_struct *t; |
262 | 272 | ||
263 | if (!list_empty(&rnp->blocked_tasks[phase])) { | 273 | if (rcu_preempted_readers(rnp)) { |
264 | spin_lock_irqsave(&rnp->lock, flags); | 274 | spin_lock_irqsave(&rnp->lock, flags); |
265 | phase = rnp->gpnum & 0x1; /* re-read under lock. */ | 275 | phase = rnp->gpnum & 0x1; |
266 | lp = &rnp->blocked_tasks[phase]; | 276 | lp = &rnp->blocked_tasks[phase]; |
267 | list_for_each_entry(t, lp, rcu_node_entry) | 277 | list_for_each_entry(t, lp, rcu_node_entry) |
268 | printk(" P%d", t->pid); | 278 | printk(" P%d", t->pid); |
@@ -281,20 +291,10 @@ static void rcu_print_task_stall(struct rcu_node *rnp) | |||
281 | */ | 291 | */ |
282 | static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) | 292 | static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) |
283 | { | 293 | { |
284 | WARN_ON_ONCE(!list_empty(&rnp->blocked_tasks[rnp->gpnum & 0x1])); | 294 | WARN_ON_ONCE(rcu_preempted_readers(rnp)); |
285 | WARN_ON_ONCE(rnp->qsmask); | 295 | WARN_ON_ONCE(rnp->qsmask); |
286 | } | 296 | } |
287 | 297 | ||
288 | /* | ||
289 | * Check for preempted RCU readers for the specified rcu_node structure. | ||
290 | * If the caller needs a reliable answer, it must hold the rcu_node's | ||
291 | * >lock. | ||
292 | */ | ||
293 | static int rcu_preempted_readers(struct rcu_node *rnp) | ||
294 | { | ||
295 | return !list_empty(&rnp->blocked_tasks[rnp->gpnum & 0x1]); | ||
296 | } | ||
297 | |||
298 | #ifdef CONFIG_HOTPLUG_CPU | 298 | #ifdef CONFIG_HOTPLUG_CPU |
299 | 299 | ||
300 | /* | 300 | /* |
@@ -410,6 +410,15 @@ static int rcu_preempt_needs_cpu(int cpu) | |||
410 | return !!per_cpu(rcu_preempt_data, cpu).nxtlist; | 410 | return !!per_cpu(rcu_preempt_data, cpu).nxtlist; |
411 | } | 411 | } |
412 | 412 | ||
413 | /** | ||
414 | * rcu_barrier - Wait until all in-flight call_rcu() callbacks complete. | ||
415 | */ | ||
416 | void rcu_barrier(void) | ||
417 | { | ||
418 | _rcu_barrier(&rcu_preempt_state, call_rcu); | ||
419 | } | ||
420 | EXPORT_SYMBOL_GPL(rcu_barrier); | ||
421 | |||
413 | /* | 422 | /* |
414 | * Initialize preemptable RCU's per-CPU data. | 423 | * Initialize preemptable RCU's per-CPU data. |
415 | */ | 424 | */ |
@@ -419,6 +428,22 @@ static void __cpuinit rcu_preempt_init_percpu_data(int cpu) | |||
419 | } | 428 | } |
420 | 429 | ||
421 | /* | 430 | /* |
431 | * Move preemptable RCU's callbacks to ->orphan_cbs_list. | ||
432 | */ | ||
433 | static void rcu_preempt_send_cbs_to_orphanage(void) | ||
434 | { | ||
435 | rcu_send_cbs_to_orphanage(&rcu_preempt_state); | ||
436 | } | ||
437 | |||
438 | /* | ||
439 | * Initialize preemptable RCU's state structures. | ||
440 | */ | ||
441 | static void __init __rcu_init_preempt(void) | ||
442 | { | ||
443 | RCU_INIT_FLAVOR(&rcu_preempt_state, rcu_preempt_data); | ||
444 | } | ||
445 | |||
446 | /* | ||
422 | * Check for a task exiting while in a preemptable-RCU read-side | 447 | * Check for a task exiting while in a preemptable-RCU read-side |
423 | * critical section, clean up if so. No need to issue warnings, | 448 | * critical section, clean up if so. No need to issue warnings, |
424 | * as debug_check_no_locks_held() already does this if lockdep | 449 | * as debug_check_no_locks_held() already does this if lockdep |
@@ -461,6 +486,15 @@ static void rcu_preempt_note_context_switch(int cpu) | |||
461 | { | 486 | { |
462 | } | 487 | } |
463 | 488 | ||
489 | /* | ||
490 | * Because preemptable RCU does not exist, there are never any preempted | ||
491 | * RCU readers. | ||
492 | */ | ||
493 | static int rcu_preempted_readers(struct rcu_node *rnp) | ||
494 | { | ||
495 | return 0; | ||
496 | } | ||
497 | |||
464 | #ifdef CONFIG_RCU_CPU_STALL_DETECTOR | 498 | #ifdef CONFIG_RCU_CPU_STALL_DETECTOR |
465 | 499 | ||
466 | /* | 500 | /* |
@@ -483,15 +517,6 @@ static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) | |||
483 | WARN_ON_ONCE(rnp->qsmask); | 517 | WARN_ON_ONCE(rnp->qsmask); |
484 | } | 518 | } |
485 | 519 | ||
486 | /* | ||
487 | * Because preemptable RCU does not exist, there are never any preempted | ||
488 | * RCU readers. | ||
489 | */ | ||
490 | static int rcu_preempted_readers(struct rcu_node *rnp) | ||
491 | { | ||
492 | return 0; | ||
493 | } | ||
494 | |||
495 | #ifdef CONFIG_HOTPLUG_CPU | 520 | #ifdef CONFIG_HOTPLUG_CPU |
496 | 521 | ||
497 | /* | 522 | /* |
@@ -518,7 +543,7 @@ static void rcu_preempt_offline_cpu(int cpu) | |||
518 | * Because preemptable RCU does not exist, it never has any callbacks | 543 | * Because preemptable RCU does not exist, it never has any callbacks |
519 | * to check. | 544 | * to check. |
520 | */ | 545 | */ |
521 | void rcu_preempt_check_callbacks(int cpu) | 546 | static void rcu_preempt_check_callbacks(int cpu) |
522 | { | 547 | { |
523 | } | 548 | } |
524 | 549 | ||
@@ -526,7 +551,7 @@ void rcu_preempt_check_callbacks(int cpu) | |||
526 | * Because preemptable RCU does not exist, it never has any callbacks | 551 | * Because preemptable RCU does not exist, it never has any callbacks |
527 | * to process. | 552 | * to process. |
528 | */ | 553 | */ |
529 | void rcu_preempt_process_callbacks(void) | 554 | static void rcu_preempt_process_callbacks(void) |
530 | { | 555 | { |
531 | } | 556 | } |
532 | 557 | ||
@@ -556,6 +581,16 @@ static int rcu_preempt_needs_cpu(int cpu) | |||
556 | } | 581 | } |
557 | 582 | ||
558 | /* | 583 | /* |
584 | * Because preemptable RCU does not exist, rcu_barrier() is just | ||
585 | * another name for rcu_barrier_sched(). | ||
586 | */ | ||
587 | void rcu_barrier(void) | ||
588 | { | ||
589 | rcu_barrier_sched(); | ||
590 | } | ||
591 | EXPORT_SYMBOL_GPL(rcu_barrier); | ||
592 | |||
593 | /* | ||
559 | * Because preemptable RCU does not exist, there is no per-CPU | 594 | * Because preemptable RCU does not exist, there is no per-CPU |
560 | * data to initialize. | 595 | * data to initialize. |
561 | */ | 596 | */ |
@@ -563,4 +598,18 @@ static void __cpuinit rcu_preempt_init_percpu_data(int cpu) | |||
563 | { | 598 | { |
564 | } | 599 | } |
565 | 600 | ||
601 | /* | ||
602 | * Because there is no preemptable RCU, there are no callbacks to move. | ||
603 | */ | ||
604 | static void rcu_preempt_send_cbs_to_orphanage(void) | ||
605 | { | ||
606 | } | ||
607 | |||
608 | /* | ||
609 | * Because preemptable RCU does not exist, it need not be initialized. | ||
610 | */ | ||
611 | static void __init __rcu_init_preempt(void) | ||
612 | { | ||
613 | } | ||
614 | |||
566 | #endif /* #else #ifdef CONFIG_TREE_PREEMPT_RCU */ | 615 | #endif /* #else #ifdef CONFIG_TREE_PREEMPT_RCU */ |
diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c index 179e6ad80dc0..4b31c779e62e 100644 --- a/kernel/rcutree_trace.c +++ b/kernel/rcutree_trace.c | |||
@@ -159,13 +159,13 @@ static void print_one_rcu_state(struct seq_file *m, struct rcu_state *rsp) | |||
159 | struct rcu_node *rnp; | 159 | struct rcu_node *rnp; |
160 | 160 | ||
161 | seq_printf(m, "c=%ld g=%ld s=%d jfq=%ld j=%x " | 161 | seq_printf(m, "c=%ld g=%ld s=%d jfq=%ld j=%x " |
162 | "nfqs=%lu/nfqsng=%lu(%lu) fqlh=%lu\n", | 162 | "nfqs=%lu/nfqsng=%lu(%lu) fqlh=%lu oqlen=%ld\n", |
163 | rsp->completed, rsp->gpnum, rsp->signaled, | 163 | rsp->completed, rsp->gpnum, rsp->signaled, |
164 | (long)(rsp->jiffies_force_qs - jiffies), | 164 | (long)(rsp->jiffies_force_qs - jiffies), |
165 | (int)(jiffies & 0xffff), | 165 | (int)(jiffies & 0xffff), |
166 | rsp->n_force_qs, rsp->n_force_qs_ngp, | 166 | rsp->n_force_qs, rsp->n_force_qs_ngp, |
167 | rsp->n_force_qs - rsp->n_force_qs_ngp, | 167 | rsp->n_force_qs - rsp->n_force_qs_ngp, |
168 | rsp->n_force_qs_lh); | 168 | rsp->n_force_qs_lh, rsp->orphan_qlen); |
169 | for (rnp = &rsp->node[0]; rnp - &rsp->node[0] < NUM_RCU_NODES; rnp++) { | 169 | for (rnp = &rsp->node[0]; rnp - &rsp->node[0] < NUM_RCU_NODES; rnp++) { |
170 | if (rnp->level != level) { | 170 | if (rnp->level != level) { |
171 | seq_puts(m, "\n"); | 171 | seq_puts(m, "\n"); |
diff --git a/kernel/sched.c b/kernel/sched.c index 1535f3884b88..e88689522e66 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -676,6 +676,7 @@ inline void update_rq_clock(struct rq *rq) | |||
676 | 676 | ||
677 | /** | 677 | /** |
678 | * runqueue_is_locked | 678 | * runqueue_is_locked |
679 | * @cpu: the processor in question. | ||
679 | * | 680 | * |
680 | * Returns true if the current cpu runqueue is locked. | 681 | * Returns true if the current cpu runqueue is locked. |
681 | * This interface allows printk to be called with the runqueue lock | 682 | * This interface allows printk to be called with the runqueue lock |
@@ -2311,7 +2312,7 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, | |||
2311 | { | 2312 | { |
2312 | int cpu, orig_cpu, this_cpu, success = 0; | 2313 | int cpu, orig_cpu, this_cpu, success = 0; |
2313 | unsigned long flags; | 2314 | unsigned long flags; |
2314 | struct rq *rq; | 2315 | struct rq *rq, *orig_rq; |
2315 | 2316 | ||
2316 | if (!sched_feat(SYNC_WAKEUPS)) | 2317 | if (!sched_feat(SYNC_WAKEUPS)) |
2317 | wake_flags &= ~WF_SYNC; | 2318 | wake_flags &= ~WF_SYNC; |
@@ -2319,7 +2320,7 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, | |||
2319 | this_cpu = get_cpu(); | 2320 | this_cpu = get_cpu(); |
2320 | 2321 | ||
2321 | smp_wmb(); | 2322 | smp_wmb(); |
2322 | rq = task_rq_lock(p, &flags); | 2323 | rq = orig_rq = task_rq_lock(p, &flags); |
2323 | update_rq_clock(rq); | 2324 | update_rq_clock(rq); |
2324 | if (!(p->state & state)) | 2325 | if (!(p->state & state)) |
2325 | goto out; | 2326 | goto out; |
@@ -2350,6 +2351,10 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, | |||
2350 | set_task_cpu(p, cpu); | 2351 | set_task_cpu(p, cpu); |
2351 | 2352 | ||
2352 | rq = task_rq_lock(p, &flags); | 2353 | rq = task_rq_lock(p, &flags); |
2354 | |||
2355 | if (rq != orig_rq) | ||
2356 | update_rq_clock(rq); | ||
2357 | |||
2353 | WARN_ON(p->state != TASK_WAKING); | 2358 | WARN_ON(p->state != TASK_WAKING); |
2354 | cpu = task_cpu(p); | 2359 | cpu = task_cpu(p); |
2355 | 2360 | ||
@@ -2515,22 +2520,17 @@ void sched_fork(struct task_struct *p, int clone_flags) | |||
2515 | __sched_fork(p); | 2520 | __sched_fork(p); |
2516 | 2521 | ||
2517 | /* | 2522 | /* |
2518 | * Make sure we do not leak PI boosting priority to the child. | ||
2519 | */ | ||
2520 | p->prio = current->normal_prio; | ||
2521 | |||
2522 | /* | ||
2523 | * Revert to default priority/policy on fork if requested. | 2523 | * Revert to default priority/policy on fork if requested. |
2524 | */ | 2524 | */ |
2525 | if (unlikely(p->sched_reset_on_fork)) { | 2525 | if (unlikely(p->sched_reset_on_fork)) { |
2526 | if (p->policy == SCHED_FIFO || p->policy == SCHED_RR) | 2526 | if (p->policy == SCHED_FIFO || p->policy == SCHED_RR) { |
2527 | p->policy = SCHED_NORMAL; | 2527 | p->policy = SCHED_NORMAL; |
2528 | 2528 | p->normal_prio = p->static_prio; | |
2529 | if (p->normal_prio < DEFAULT_PRIO) | 2529 | } |
2530 | p->prio = DEFAULT_PRIO; | ||
2531 | 2530 | ||
2532 | if (PRIO_TO_NICE(p->static_prio) < 0) { | 2531 | if (PRIO_TO_NICE(p->static_prio) < 0) { |
2533 | p->static_prio = NICE_TO_PRIO(0); | 2532 | p->static_prio = NICE_TO_PRIO(0); |
2533 | p->normal_prio = p->static_prio; | ||
2534 | set_load_weight(p); | 2534 | set_load_weight(p); |
2535 | } | 2535 | } |
2536 | 2536 | ||
@@ -2541,6 +2541,11 @@ void sched_fork(struct task_struct *p, int clone_flags) | |||
2541 | p->sched_reset_on_fork = 0; | 2541 | p->sched_reset_on_fork = 0; |
2542 | } | 2542 | } |
2543 | 2543 | ||
2544 | /* | ||
2545 | * Make sure we do not leak PI boosting priority to the child. | ||
2546 | */ | ||
2547 | p->prio = current->normal_prio; | ||
2548 | |||
2544 | if (!rt_prio(p->prio)) | 2549 | if (!rt_prio(p->prio)) |
2545 | p->sched_class = &fair_sched_class; | 2550 | p->sched_class = &fair_sched_class; |
2546 | 2551 | ||
@@ -2581,8 +2586,6 @@ void wake_up_new_task(struct task_struct *p, unsigned long clone_flags) | |||
2581 | BUG_ON(p->state != TASK_RUNNING); | 2586 | BUG_ON(p->state != TASK_RUNNING); |
2582 | update_rq_clock(rq); | 2587 | update_rq_clock(rq); |
2583 | 2588 | ||
2584 | p->prio = effective_prio(p); | ||
2585 | |||
2586 | if (!p->sched_class->task_new || !current->se.on_rq) { | 2589 | if (!p->sched_class->task_new || !current->se.on_rq) { |
2587 | activate_task(rq, p, 0); | 2590 | activate_task(rq, p, 0); |
2588 | } else { | 2591 | } else { |
@@ -3658,6 +3661,7 @@ static void update_group_power(struct sched_domain *sd, int cpu) | |||
3658 | 3661 | ||
3659 | /** | 3662 | /** |
3660 | * update_sg_lb_stats - Update sched_group's statistics for load balancing. | 3663 | * update_sg_lb_stats - Update sched_group's statistics for load balancing. |
3664 | * @sd: The sched_domain whose statistics are to be updated. | ||
3661 | * @group: sched_group whose statistics are to be updated. | 3665 | * @group: sched_group whose statistics are to be updated. |
3662 | * @this_cpu: Cpu for which load balance is currently performed. | 3666 | * @this_cpu: Cpu for which load balance is currently performed. |
3663 | * @idle: Idle status of this_cpu | 3667 | * @idle: Idle status of this_cpu |
@@ -6720,9 +6724,6 @@ EXPORT_SYMBOL(yield); | |||
6720 | /* | 6724 | /* |
6721 | * This task is about to go to sleep on IO. Increment rq->nr_iowait so | 6725 | * This task is about to go to sleep on IO. Increment rq->nr_iowait so |
6722 | * that process accounting knows that this is a task in IO wait state. | 6726 | * that process accounting knows that this is a task in IO wait state. |
6723 | * | ||
6724 | * But don't do that if it is a deliberate, throttling IO wait (this task | ||
6725 | * has set its backing_dev_info: the queue against which it should throttle) | ||
6726 | */ | 6727 | */ |
6727 | void __sched io_schedule(void) | 6728 | void __sched io_schedule(void) |
6728 | { | 6729 | { |
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index e0f59a21c061..89aed5933ed4 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c | |||
@@ -231,6 +231,13 @@ void tick_nohz_stop_sched_tick(int inidle) | |||
231 | if (!inidle && !ts->inidle) | 231 | if (!inidle && !ts->inidle) |
232 | goto end; | 232 | goto end; |
233 | 233 | ||
234 | /* | ||
235 | * Set ts->inidle unconditionally. Even if the system did not | ||
236 | * switch to NOHZ mode the cpu frequency governers rely on the | ||
237 | * update of the idle time accounting in tick_nohz_start_idle(). | ||
238 | */ | ||
239 | ts->inidle = 1; | ||
240 | |||
234 | now = tick_nohz_start_idle(ts); | 241 | now = tick_nohz_start_idle(ts); |
235 | 242 | ||
236 | /* | 243 | /* |
@@ -248,8 +255,6 @@ void tick_nohz_stop_sched_tick(int inidle) | |||
248 | if (unlikely(ts->nohz_mode == NOHZ_MODE_INACTIVE)) | 255 | if (unlikely(ts->nohz_mode == NOHZ_MODE_INACTIVE)) |
249 | goto end; | 256 | goto end; |
250 | 257 | ||
251 | ts->inidle = 1; | ||
252 | |||
253 | if (need_resched()) | 258 | if (need_resched()) |
254 | goto end; | 259 | goto end; |
255 | 260 | ||
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index fb0f46fa1ecd..c3a4e2907eaa 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/percpu.h> | 13 | #include <linux/percpu.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
16 | #include <linux/sched.h> | ||
16 | #include <linux/sysdev.h> | 17 | #include <linux/sysdev.h> |
17 | #include <linux/clocksource.h> | 18 | #include <linux/clocksource.h> |
18 | #include <linux/jiffies.h> | 19 | #include <linux/jiffies.h> |
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 3eb159c277c8..d9d6206e0b14 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
@@ -856,6 +856,37 @@ static void blk_add_trace_remap(struct request_queue *q, struct bio *bio, | |||
856 | } | 856 | } |
857 | 857 | ||
858 | /** | 858 | /** |
859 | * blk_add_trace_rq_remap - Add a trace for a request-remap operation | ||
860 | * @q: queue the io is for | ||
861 | * @rq: the source request | ||
862 | * @dev: target device | ||
863 | * @from: source sector | ||
864 | * | ||
865 | * Description: | ||
866 | * Device mapper remaps request to other devices. | ||
867 | * Add a trace for that action. | ||
868 | * | ||
869 | **/ | ||
870 | static void blk_add_trace_rq_remap(struct request_queue *q, | ||
871 | struct request *rq, dev_t dev, | ||
872 | sector_t from) | ||
873 | { | ||
874 | struct blk_trace *bt = q->blk_trace; | ||
875 | struct blk_io_trace_remap r; | ||
876 | |||
877 | if (likely(!bt)) | ||
878 | return; | ||
879 | |||
880 | r.device_from = cpu_to_be32(dev); | ||
881 | r.device_to = cpu_to_be32(disk_devt(rq->rq_disk)); | ||
882 | r.sector_from = cpu_to_be64(from); | ||
883 | |||
884 | __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_bytes(rq), | ||
885 | rq_data_dir(rq), BLK_TA_REMAP, !!rq->errors, | ||
886 | sizeof(r), &r); | ||
887 | } | ||
888 | |||
889 | /** | ||
859 | * blk_add_driver_data - Add binary message with driver-specific data | 890 | * blk_add_driver_data - Add binary message with driver-specific data |
860 | * @q: queue the io is for | 891 | * @q: queue the io is for |
861 | * @rq: io request | 892 | * @rq: io request |
@@ -922,10 +953,13 @@ static void blk_register_tracepoints(void) | |||
922 | WARN_ON(ret); | 953 | WARN_ON(ret); |
923 | ret = register_trace_block_remap(blk_add_trace_remap); | 954 | ret = register_trace_block_remap(blk_add_trace_remap); |
924 | WARN_ON(ret); | 955 | WARN_ON(ret); |
956 | ret = register_trace_block_rq_remap(blk_add_trace_rq_remap); | ||
957 | WARN_ON(ret); | ||
925 | } | 958 | } |
926 | 959 | ||
927 | static void blk_unregister_tracepoints(void) | 960 | static void blk_unregister_tracepoints(void) |
928 | { | 961 | { |
962 | unregister_trace_block_rq_remap(blk_add_trace_rq_remap); | ||
929 | unregister_trace_block_remap(blk_add_trace_remap); | 963 | unregister_trace_block_remap(blk_add_trace_remap); |
930 | unregister_trace_block_split(blk_add_trace_split); | 964 | unregister_trace_block_split(blk_add_trace_split); |
931 | unregister_trace_block_unplug_io(blk_add_trace_unplug_io); | 965 | unregister_trace_block_unplug_io(blk_add_trace_unplug_io); |
@@ -1657,6 +1691,11 @@ int blk_trace_init_sysfs(struct device *dev) | |||
1657 | return sysfs_create_group(&dev->kobj, &blk_trace_attr_group); | 1691 | return sysfs_create_group(&dev->kobj, &blk_trace_attr_group); |
1658 | } | 1692 | } |
1659 | 1693 | ||
1694 | void blk_trace_remove_sysfs(struct device *dev) | ||
1695 | { | ||
1696 | sysfs_remove_group(&dev->kobj, &blk_trace_attr_group); | ||
1697 | } | ||
1698 | |||
1660 | #endif /* CONFIG_BLK_DEV_IO_TRACE */ | 1699 | #endif /* CONFIG_BLK_DEV_IO_TRACE */ |
1661 | 1700 | ||
1662 | #ifdef CONFIG_EVENT_TRACING | 1701 | #ifdef CONFIG_EVENT_TRACING |
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index b10c0d90a6ff..1ed514fe3a30 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -751,7 +751,7 @@ ftrace_profile_write(struct file *filp, const char __user *ubuf, | |||
751 | out: | 751 | out: |
752 | mutex_unlock(&ftrace_profile_lock); | 752 | mutex_unlock(&ftrace_profile_lock); |
753 | 753 | ||
754 | filp->f_pos += cnt; | 754 | *ppos += cnt; |
755 | 755 | ||
756 | return cnt; | 756 | return cnt; |
757 | } | 757 | } |
diff --git a/kernel/trace/kmemtrace.c b/kernel/trace/kmemtrace.c index 81b1645c8549..a91da69f153a 100644 --- a/kernel/trace/kmemtrace.c +++ b/kernel/trace/kmemtrace.c | |||
@@ -501,7 +501,7 @@ static int __init init_kmem_tracer(void) | |||
501 | return 1; | 501 | return 1; |
502 | } | 502 | } |
503 | 503 | ||
504 | if (!register_tracer(&kmem_tracer)) { | 504 | if (register_tracer(&kmem_tracer) != 0) { |
505 | pr_warning("Warning: could not register the kmem tracer\n"); | 505 | pr_warning("Warning: could not register the kmem tracer\n"); |
506 | return 1; | 506 | return 1; |
507 | } | 507 | } |
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index d4ff01970547..3ffa502fb243 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
@@ -483,7 +483,7 @@ struct ring_buffer_iter { | |||
483 | /* Up this if you want to test the TIME_EXTENTS and normalization */ | 483 | /* Up this if you want to test the TIME_EXTENTS and normalization */ |
484 | #define DEBUG_SHIFT 0 | 484 | #define DEBUG_SHIFT 0 |
485 | 485 | ||
486 | static inline u64 rb_time_stamp(struct ring_buffer *buffer, int cpu) | 486 | static inline u64 rb_time_stamp(struct ring_buffer *buffer) |
487 | { | 487 | { |
488 | /* shift to debug/test normalization and TIME_EXTENTS */ | 488 | /* shift to debug/test normalization and TIME_EXTENTS */ |
489 | return buffer->clock() << DEBUG_SHIFT; | 489 | return buffer->clock() << DEBUG_SHIFT; |
@@ -494,7 +494,7 @@ u64 ring_buffer_time_stamp(struct ring_buffer *buffer, int cpu) | |||
494 | u64 time; | 494 | u64 time; |
495 | 495 | ||
496 | preempt_disable_notrace(); | 496 | preempt_disable_notrace(); |
497 | time = rb_time_stamp(buffer, cpu); | 497 | time = rb_time_stamp(buffer); |
498 | preempt_enable_no_resched_notrace(); | 498 | preempt_enable_no_resched_notrace(); |
499 | 499 | ||
500 | return time; | 500 | return time; |
@@ -599,7 +599,7 @@ static struct list_head *rb_list_head(struct list_head *list) | |||
599 | } | 599 | } |
600 | 600 | ||
601 | /* | 601 | /* |
602 | * rb_is_head_page - test if the give page is the head page | 602 | * rb_is_head_page - test if the given page is the head page |
603 | * | 603 | * |
604 | * Because the reader may move the head_page pointer, we can | 604 | * Because the reader may move the head_page pointer, we can |
605 | * not trust what the head page is (it may be pointing to | 605 | * not trust what the head page is (it may be pointing to |
@@ -1868,7 +1868,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer, | |||
1868 | * Nested commits always have zero deltas, so | 1868 | * Nested commits always have zero deltas, so |
1869 | * just reread the time stamp | 1869 | * just reread the time stamp |
1870 | */ | 1870 | */ |
1871 | *ts = rb_time_stamp(buffer, cpu_buffer->cpu); | 1871 | *ts = rb_time_stamp(buffer); |
1872 | next_page->page->time_stamp = *ts; | 1872 | next_page->page->time_stamp = *ts; |
1873 | } | 1873 | } |
1874 | 1874 | ||
@@ -2111,7 +2111,7 @@ rb_reserve_next_event(struct ring_buffer *buffer, | |||
2111 | if (RB_WARN_ON(cpu_buffer, ++nr_loops > 1000)) | 2111 | if (RB_WARN_ON(cpu_buffer, ++nr_loops > 1000)) |
2112 | goto out_fail; | 2112 | goto out_fail; |
2113 | 2113 | ||
2114 | ts = rb_time_stamp(cpu_buffer->buffer, cpu_buffer->cpu); | 2114 | ts = rb_time_stamp(cpu_buffer->buffer); |
2115 | 2115 | ||
2116 | /* | 2116 | /* |
2117 | * Only the first commit can update the timestamp. | 2117 | * Only the first commit can update the timestamp. |
@@ -2681,7 +2681,7 @@ unsigned long ring_buffer_entries(struct ring_buffer *buffer) | |||
2681 | EXPORT_SYMBOL_GPL(ring_buffer_entries); | 2681 | EXPORT_SYMBOL_GPL(ring_buffer_entries); |
2682 | 2682 | ||
2683 | /** | 2683 | /** |
2684 | * ring_buffer_overrun_cpu - get the number of overruns in buffer | 2684 | * ring_buffer_overruns - get the number of overruns in buffer |
2685 | * @buffer: The ring buffer | 2685 | * @buffer: The ring buffer |
2686 | * | 2686 | * |
2687 | * Returns the total number of overruns in the ring buffer | 2687 | * Returns the total number of overruns in the ring buffer |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 026e715a0c7a..9d3067a62d43 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -2440,7 +2440,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf, | |||
2440 | return ret; | 2440 | return ret; |
2441 | } | 2441 | } |
2442 | 2442 | ||
2443 | filp->f_pos += cnt; | 2443 | *ppos += cnt; |
2444 | 2444 | ||
2445 | return cnt; | 2445 | return cnt; |
2446 | } | 2446 | } |
@@ -2582,7 +2582,7 @@ tracing_ctrl_write(struct file *filp, const char __user *ubuf, | |||
2582 | } | 2582 | } |
2583 | mutex_unlock(&trace_types_lock); | 2583 | mutex_unlock(&trace_types_lock); |
2584 | 2584 | ||
2585 | filp->f_pos += cnt; | 2585 | *ppos += cnt; |
2586 | 2586 | ||
2587 | return cnt; | 2587 | return cnt; |
2588 | } | 2588 | } |
@@ -2764,7 +2764,7 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, | |||
2764 | if (err) | 2764 | if (err) |
2765 | return err; | 2765 | return err; |
2766 | 2766 | ||
2767 | filp->f_pos += ret; | 2767 | *ppos += ret; |
2768 | 2768 | ||
2769 | return ret; | 2769 | return ret; |
2770 | } | 2770 | } |
@@ -3299,7 +3299,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, | |||
3299 | } | 3299 | } |
3300 | } | 3300 | } |
3301 | 3301 | ||
3302 | filp->f_pos += cnt; | 3302 | *ppos += cnt; |
3303 | 3303 | ||
3304 | /* If check pages failed, return ENOMEM */ | 3304 | /* If check pages failed, return ENOMEM */ |
3305 | if (tracing_disabled) | 3305 | if (tracing_disabled) |
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index ed17565826b0..b6c12c6a1bcd 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c | |||
@@ -69,6 +69,9 @@ enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter) | |||
69 | * @s: trace sequence descriptor | 69 | * @s: trace sequence descriptor |
70 | * @fmt: printf format string | 70 | * @fmt: printf format string |
71 | * | 71 | * |
72 | * It returns 0 if the trace oversizes the buffer's free | ||
73 | * space, 1 otherwise. | ||
74 | * | ||
72 | * The tracer may use either sequence operations or its own | 75 | * The tracer may use either sequence operations or its own |
73 | * copy to user routines. To simplify formating of a trace | 76 | * copy to user routines. To simplify formating of a trace |
74 | * trace_seq_printf is used to store strings into a special | 77 | * trace_seq_printf is used to store strings into a special |
@@ -95,7 +98,7 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | |||
95 | 98 | ||
96 | s->len += ret; | 99 | s->len += ret; |
97 | 100 | ||
98 | return len; | 101 | return 1; |
99 | } | 102 | } |
100 | EXPORT_SYMBOL_GPL(trace_seq_printf); | 103 | EXPORT_SYMBOL_GPL(trace_seq_printf); |
101 | 104 | ||
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index 8bda4bff2286..ddee9c593732 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c | |||
@@ -229,7 +229,7 @@ int syscall_exit_format(struct ftrace_event_call *call, struct trace_seq *s) | |||
229 | "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" | 229 | "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" |
230 | "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n", | 230 | "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n", |
231 | SYSCALL_FIELD(int, nr), | 231 | SYSCALL_FIELD(int, nr), |
232 | SYSCALL_FIELD(unsigned long, ret)); | 232 | SYSCALL_FIELD(long, ret)); |
233 | if (!ret) | 233 | if (!ret) |
234 | return 0; | 234 | return 0; |
235 | 235 | ||
@@ -275,7 +275,7 @@ int syscall_exit_define_fields(struct ftrace_event_call *call) | |||
275 | if (ret) | 275 | if (ret) |
276 | return ret; | 276 | return ret; |
277 | 277 | ||
278 | ret = trace_define_field(call, SYSCALL_FIELD(unsigned long, ret), 0, | 278 | ret = trace_define_field(call, SYSCALL_FIELD(long, ret), 0, |
279 | FILTER_OTHER); | 279 | FILTER_OTHER); |
280 | 280 | ||
281 | return ret; | 281 | return ret; |
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index addfe2df93b1..47cdd7e76f2b 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -640,6 +640,24 @@ int schedule_delayed_work(struct delayed_work *dwork, | |||
640 | EXPORT_SYMBOL(schedule_delayed_work); | 640 | EXPORT_SYMBOL(schedule_delayed_work); |
641 | 641 | ||
642 | /** | 642 | /** |
643 | * flush_delayed_work - block until a dwork_struct's callback has terminated | ||
644 | * @dwork: the delayed work which is to be flushed | ||
645 | * | ||
646 | * Any timeout is cancelled, and any pending work is run immediately. | ||
647 | */ | ||
648 | void flush_delayed_work(struct delayed_work *dwork) | ||
649 | { | ||
650 | if (del_timer_sync(&dwork->timer)) { | ||
651 | struct cpu_workqueue_struct *cwq; | ||
652 | cwq = wq_per_cpu(keventd_wq, get_cpu()); | ||
653 | __queue_work(cwq, &dwork->work); | ||
654 | put_cpu(); | ||
655 | } | ||
656 | flush_work(&dwork->work); | ||
657 | } | ||
658 | EXPORT_SYMBOL(flush_delayed_work); | ||
659 | |||
660 | /** | ||
643 | * schedule_delayed_work_on - queue work in global workqueue on CPU after delay | 661 | * schedule_delayed_work_on - queue work in global workqueue on CPU after delay |
644 | * @cpu: cpu to use | 662 | * @cpu: cpu to use |
645 | * @dwork: job to be done | 663 | * @dwork: job to be done |