diff options
-rw-r--r-- | Documentation/DocBook/kernel-hacking.tmpl | 2 | ||||
-rw-r--r-- | Documentation/SubmitChecklist | 2 | ||||
-rw-r--r-- | Documentation/development-process/4.Coding | 2 | ||||
-rw-r--r-- | Documentation/ja_JP/SubmitChecklist | 2 | ||||
-rw-r--r-- | Documentation/zh_CN/SubmitChecklist | 2 | ||||
-rw-r--r-- | arch/h8300/Kconfig.cpu | 4 | ||||
-rw-r--r-- | arch/m32r/Kconfig | 12 | ||||
-rw-r--r-- | arch/xtensa/Kconfig | 13 | ||||
-rw-r--r-- | include/linux/bit_spinlock.h | 2 | ||||
-rw-r--r-- | include/linux/hardirq.h | 4 | ||||
-rw-r--r-- | include/linux/kernel.h | 2 | ||||
-rw-r--r-- | include/linux/pagemap.h | 4 | ||||
-rw-r--r-- | include/linux/preempt.h | 26 | ||||
-rw-r--r-- | include/linux/rcupdate.h | 12 | ||||
-rw-r--r-- | include/linux/sched.h | 2 | ||||
-rw-r--r-- | kernel/Kconfig.preempt | 3 | ||||
-rw-r--r-- | kernel/sched.c | 117 | ||||
-rw-r--r-- | kernel/sched_autogroup.h | 1 | ||||
-rw-r--r-- | kernel/sched_fair.c | 72 | ||||
-rw-r--r-- | kernel/sched_rt.c | 26 | ||||
-rw-r--r-- | lib/Kconfig.debug | 9 |
21 files changed, 145 insertions, 174 deletions
diff --git a/Documentation/DocBook/kernel-hacking.tmpl b/Documentation/DocBook/kernel-hacking.tmpl index 7b3f49363413..07a9c48de5a2 100644 --- a/Documentation/DocBook/kernel-hacking.tmpl +++ b/Documentation/DocBook/kernel-hacking.tmpl | |||
@@ -409,7 +409,7 @@ cond_resched(); /* Will sleep */ | |||
409 | 409 | ||
410 | <para> | 410 | <para> |
411 | You should always compile your kernel | 411 | You should always compile your kernel |
412 | <symbol>CONFIG_DEBUG_SPINLOCK_SLEEP</symbol> on, and it will warn | 412 | <symbol>CONFIG_DEBUG_ATOMIC_SLEEP</symbol> on, and it will warn |
413 | you if you break these rules. If you <emphasis>do</emphasis> break | 413 | you if you break these rules. If you <emphasis>do</emphasis> break |
414 | the rules, you will eventually lock up your box. | 414 | the rules, you will eventually lock up your box. |
415 | </para> | 415 | </para> |
diff --git a/Documentation/SubmitChecklist b/Documentation/SubmitChecklist index da0382daa395..7b13be41c085 100644 --- a/Documentation/SubmitChecklist +++ b/Documentation/SubmitChecklist | |||
@@ -53,7 +53,7 @@ kernel patches. | |||
53 | 53 | ||
54 | 12: Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, | 54 | 12: Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, |
55 | CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, | 55 | CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, |
56 | CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_SPINLOCK_SLEEP all simultaneously | 56 | CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_ATOMIC_SLEEP all simultaneously |
57 | enabled. | 57 | enabled. |
58 | 58 | ||
59 | 13: Has been build- and runtime tested with and without CONFIG_SMP and | 59 | 13: Has been build- and runtime tested with and without CONFIG_SMP and |
diff --git a/Documentation/development-process/4.Coding b/Documentation/development-process/4.Coding index f3f1a469443c..83f5f5b365a3 100644 --- a/Documentation/development-process/4.Coding +++ b/Documentation/development-process/4.Coding | |||
@@ -244,7 +244,7 @@ testing purposes. In particular, you should turn on: | |||
244 | - DEBUG_SLAB can find a variety of memory allocation and use errors; it | 244 | - DEBUG_SLAB can find a variety of memory allocation and use errors; it |
245 | should be used on most development kernels. | 245 | should be used on most development kernels. |
246 | 246 | ||
247 | - DEBUG_SPINLOCK, DEBUG_SPINLOCK_SLEEP, and DEBUG_MUTEXES will find a | 247 | - DEBUG_SPINLOCK, DEBUG_ATOMIC_SLEEP, and DEBUG_MUTEXES will find a |
248 | number of common locking errors. | 248 | number of common locking errors. |
249 | 249 | ||
250 | There are quite a few other debugging options, some of which will be | 250 | There are quite a few other debugging options, some of which will be |
diff --git a/Documentation/ja_JP/SubmitChecklist b/Documentation/ja_JP/SubmitChecklist index 2df4576f1173..cb5507b1ac81 100644 --- a/Documentation/ja_JP/SubmitChecklist +++ b/Documentation/ja_JP/SubmitChecklist | |||
@@ -68,7 +68,7 @@ Linux カーネルパッチ投稿者向けチェックリスト | |||
68 | 68 | ||
69 | 12: CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, CONFIG_DEBUG_SLAB, | 69 | 12: CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, CONFIG_DEBUG_SLAB, |
70 | CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SPINLOCK, | 70 | CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SPINLOCK, |
71 | CONFIG_DEBUG_SPINLOCK_SLEEP これら全てを同時に有効にして動作確認を | 71 | CONFIG_DEBUG_ATOMIC_SLEEP これら全てを同時に有効にして動作確認を |
72 | 行ってください。 | 72 | 行ってください。 |
73 | 73 | ||
74 | 13: CONFIG_SMP, CONFIG_PREEMPT を有効にした場合と無効にした場合の両方で | 74 | 13: CONFIG_SMP, CONFIG_PREEMPT を有効にした場合と無効にした場合の両方で |
diff --git a/Documentation/zh_CN/SubmitChecklist b/Documentation/zh_CN/SubmitChecklist index 951415bbab0c..4c741d6bc048 100644 --- a/Documentation/zh_CN/SubmitChecklist +++ b/Documentation/zh_CN/SubmitChecklist | |||
@@ -67,7 +67,7 @@ Linuxںύ嵥 | |||
67 | 67 | ||
68 | 12ѾͨCONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, | 68 | 12ѾͨCONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, |
69 | CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, | 69 | CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, |
70 | CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_SPINLOCK_SLEEPԣͬʱ | 70 | CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_ATOMIC_SLEEPԣͬʱ |
71 | ʹܡ | 71 | ʹܡ |
72 | 72 | ||
73 | 13Ѿʹû߲ʹ CONFIG_SMP CONFIG_PREEMPTִʱ䡣 | 73 | 13Ѿʹû߲ʹ CONFIG_SMP CONFIG_PREEMPTִʱ䡣 |
diff --git a/arch/h8300/Kconfig.cpu b/arch/h8300/Kconfig.cpu index d236ab4232ca..15c22286ae79 100644 --- a/arch/h8300/Kconfig.cpu +++ b/arch/h8300/Kconfig.cpu | |||
@@ -162,9 +162,7 @@ config H8300_TPU_CH | |||
162 | int "TPU channel" | 162 | int "TPU channel" |
163 | depends on H8300_TPU | 163 | depends on H8300_TPU |
164 | 164 | ||
165 | config PREEMPT | 165 | source "kernel/Kconfig.preempt" |
166 | bool "Preemptible Kernel" | ||
167 | default n | ||
168 | 166 | ||
169 | source "mm/Kconfig" | 167 | source "mm/Kconfig" |
170 | 168 | ||
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index 85b44e858225..b92b9445255d 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig | |||
@@ -268,17 +268,7 @@ config SCHED_OMIT_FRAME_POINTER | |||
268 | bool | 268 | bool |
269 | default y | 269 | default y |
270 | 270 | ||
271 | config PREEMPT | 271 | source "kernel/Kconfig.preempt" |
272 | bool "Preemptible Kernel" | ||
273 | help | ||
274 | This option reduces the latency of the kernel when reacting to | ||
275 | real-time or interactive events by allowing a low priority process to | ||
276 | be preempted even if it is in kernel mode executing a system call. | ||
277 | This allows applications to run more reliably even when the system is | ||
278 | under load. | ||
279 | |||
280 | Say Y here if you are building a kernel for a desktop, embedded | ||
281 | or real-time system. Say N if you are unsure. | ||
282 | 272 | ||
283 | config SMP | 273 | config SMP |
284 | bool "Symmetric multi-processing support" | 274 | bool "Symmetric multi-processing support" |
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 5d43c1f8ada8..c346ccdce0df 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig | |||
@@ -80,18 +80,7 @@ config XTENSA_UNALIGNED_USER | |||
80 | 80 | ||
81 | Say Y here to enable unaligned memory access in user space. | 81 | Say Y here to enable unaligned memory access in user space. |
82 | 82 | ||
83 | config PREEMPT | 83 | source "kernel/Kconfig.preempt" |
84 | bool "Preemptible Kernel" | ||
85 | help | ||
86 | This option reduces the latency of the kernel when reacting to | ||
87 | real-time or interactive events by allowing a low priority process to | ||
88 | be preempted even if it is in kernel mode executing a system call. | ||
89 | Unfortunately the kernel code has some race conditions if both | ||
90 | CONFIG_SMP and CONFIG_PREEMPT are enabled, so this option is | ||
91 | currently disabled if you are building an SMP kernel. | ||
92 | |||
93 | Say Y here if you are building a kernel for a desktop, embedded | ||
94 | or real-time system. Say N if you are unsure. | ||
95 | 84 | ||
96 | config MATH_EMULATION | 85 | config MATH_EMULATION |
97 | bool "Math emulation" | 86 | bool "Math emulation" |
diff --git a/include/linux/bit_spinlock.h b/include/linux/bit_spinlock.h index b4326bfa684f..564d997e2168 100644 --- a/include/linux/bit_spinlock.h +++ b/include/linux/bit_spinlock.h | |||
@@ -88,7 +88,7 @@ static inline int bit_spin_is_locked(int bitnum, unsigned long *addr) | |||
88 | { | 88 | { |
89 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | 89 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) |
90 | return test_bit(bitnum, addr); | 90 | return test_bit(bitnum, addr); |
91 | #elif defined CONFIG_PREEMPT | 91 | #elif defined CONFIG_PREEMPT_COUNT |
92 | return preempt_count(); | 92 | return preempt_count(); |
93 | #else | 93 | #else |
94 | return 1; | 94 | return 1; |
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h index ba362171e8ae..f743883f769e 100644 --- a/include/linux/hardirq.h +++ b/include/linux/hardirq.h | |||
@@ -93,7 +93,7 @@ | |||
93 | */ | 93 | */ |
94 | #define in_nmi() (preempt_count() & NMI_MASK) | 94 | #define in_nmi() (preempt_count() & NMI_MASK) |
95 | 95 | ||
96 | #if defined(CONFIG_PREEMPT) | 96 | #if defined(CONFIG_PREEMPT_COUNT) |
97 | # define PREEMPT_CHECK_OFFSET 1 | 97 | # define PREEMPT_CHECK_OFFSET 1 |
98 | #else | 98 | #else |
99 | # define PREEMPT_CHECK_OFFSET 0 | 99 | # define PREEMPT_CHECK_OFFSET 0 |
@@ -115,7 +115,7 @@ | |||
115 | #define in_atomic_preempt_off() \ | 115 | #define in_atomic_preempt_off() \ |
116 | ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_CHECK_OFFSET) | 116 | ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_CHECK_OFFSET) |
117 | 117 | ||
118 | #ifdef CONFIG_PREEMPT | 118 | #ifdef CONFIG_PREEMPT_COUNT |
119 | # define preemptible() (preempt_count() == 0 && !irqs_disabled()) | 119 | # define preemptible() (preempt_count() == 0 && !irqs_disabled()) |
120 | # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1) | 120 | # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1) |
121 | #else | 121 | #else |
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 953352a88336..567a6f7bbeed 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -121,7 +121,7 @@ extern int _cond_resched(void); | |||
121 | # define might_resched() do { } while (0) | 121 | # define might_resched() do { } while (0) |
122 | #endif | 122 | #endif |
123 | 123 | ||
124 | #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP | 124 | #ifdef CONFIG_DEBUG_ATOMIC_SLEEP |
125 | void __might_sleep(const char *file, int line, int preempt_offset); | 125 | void __might_sleep(const char *file, int line, int preempt_offset); |
126 | /** | 126 | /** |
127 | * might_sleep - annotation for functions that can sleep | 127 | * might_sleep - annotation for functions that can sleep |
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 716875e53520..8e38d4c140ff 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h | |||
@@ -134,7 +134,7 @@ static inline int page_cache_get_speculative(struct page *page) | |||
134 | VM_BUG_ON(in_interrupt()); | 134 | VM_BUG_ON(in_interrupt()); |
135 | 135 | ||
136 | #if !defined(CONFIG_SMP) && defined(CONFIG_TREE_RCU) | 136 | #if !defined(CONFIG_SMP) && defined(CONFIG_TREE_RCU) |
137 | # ifdef CONFIG_PREEMPT | 137 | # ifdef CONFIG_PREEMPT_COUNT |
138 | VM_BUG_ON(!in_atomic()); | 138 | VM_BUG_ON(!in_atomic()); |
139 | # endif | 139 | # endif |
140 | /* | 140 | /* |
@@ -172,7 +172,7 @@ static inline int page_cache_add_speculative(struct page *page, int count) | |||
172 | VM_BUG_ON(in_interrupt()); | 172 | VM_BUG_ON(in_interrupt()); |
173 | 173 | ||
174 | #if !defined(CONFIG_SMP) && defined(CONFIG_TREE_RCU) | 174 | #if !defined(CONFIG_SMP) && defined(CONFIG_TREE_RCU) |
175 | # ifdef CONFIG_PREEMPT | 175 | # ifdef CONFIG_PREEMPT_COUNT |
176 | VM_BUG_ON(!in_atomic()); | 176 | VM_BUG_ON(!in_atomic()); |
177 | # endif | 177 | # endif |
178 | VM_BUG_ON(page_count(page) == 0); | 178 | VM_BUG_ON(page_count(page) == 0); |
diff --git a/include/linux/preempt.h b/include/linux/preempt.h index 2e681d9555bd..58969b2a8a82 100644 --- a/include/linux/preempt.h +++ b/include/linux/preempt.h | |||
@@ -27,6 +27,21 @@ | |||
27 | 27 | ||
28 | asmlinkage void preempt_schedule(void); | 28 | asmlinkage void preempt_schedule(void); |
29 | 29 | ||
30 | #define preempt_check_resched() \ | ||
31 | do { \ | ||
32 | if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \ | ||
33 | preempt_schedule(); \ | ||
34 | } while (0) | ||
35 | |||
36 | #else /* !CONFIG_PREEMPT */ | ||
37 | |||
38 | #define preempt_check_resched() do { } while (0) | ||
39 | |||
40 | #endif /* CONFIG_PREEMPT */ | ||
41 | |||
42 | |||
43 | #ifdef CONFIG_PREEMPT_COUNT | ||
44 | |||
30 | #define preempt_disable() \ | 45 | #define preempt_disable() \ |
31 | do { \ | 46 | do { \ |
32 | inc_preempt_count(); \ | 47 | inc_preempt_count(); \ |
@@ -39,12 +54,6 @@ do { \ | |||
39 | dec_preempt_count(); \ | 54 | dec_preempt_count(); \ |
40 | } while (0) | 55 | } while (0) |
41 | 56 | ||
42 | #define preempt_check_resched() \ | ||
43 | do { \ | ||
44 | if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \ | ||
45 | preempt_schedule(); \ | ||
46 | } while (0) | ||
47 | |||
48 | #define preempt_enable() \ | 57 | #define preempt_enable() \ |
49 | do { \ | 58 | do { \ |
50 | preempt_enable_no_resched(); \ | 59 | preempt_enable_no_resched(); \ |
@@ -80,18 +89,17 @@ do { \ | |||
80 | preempt_check_resched(); \ | 89 | preempt_check_resched(); \ |
81 | } while (0) | 90 | } while (0) |
82 | 91 | ||
83 | #else | 92 | #else /* !CONFIG_PREEMPT_COUNT */ |
84 | 93 | ||
85 | #define preempt_disable() do { } while (0) | 94 | #define preempt_disable() do { } while (0) |
86 | #define preempt_enable_no_resched() do { } while (0) | 95 | #define preempt_enable_no_resched() do { } while (0) |
87 | #define preempt_enable() do { } while (0) | 96 | #define preempt_enable() do { } while (0) |
88 | #define preempt_check_resched() do { } while (0) | ||
89 | 97 | ||
90 | #define preempt_disable_notrace() do { } while (0) | 98 | #define preempt_disable_notrace() do { } while (0) |
91 | #define preempt_enable_no_resched_notrace() do { } while (0) | 99 | #define preempt_enable_no_resched_notrace() do { } while (0) |
92 | #define preempt_enable_notrace() do { } while (0) | 100 | #define preempt_enable_notrace() do { } while (0) |
93 | 101 | ||
94 | #endif | 102 | #endif /* CONFIG_PREEMPT_COUNT */ |
95 | 103 | ||
96 | #ifdef CONFIG_PREEMPT_NOTIFIERS | 104 | #ifdef CONFIG_PREEMPT_NOTIFIERS |
97 | 105 | ||
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 99f9aa7c2804..8f4f881a0ad8 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h | |||
@@ -239,7 +239,7 @@ extern int rcu_read_lock_bh_held(void); | |||
239 | * Check debug_lockdep_rcu_enabled() to prevent false positives during boot | 239 | * Check debug_lockdep_rcu_enabled() to prevent false positives during boot |
240 | * and while lockdep is disabled. | 240 | * and while lockdep is disabled. |
241 | */ | 241 | */ |
242 | #ifdef CONFIG_PREEMPT | 242 | #ifdef CONFIG_PREEMPT_COUNT |
243 | static inline int rcu_read_lock_sched_held(void) | 243 | static inline int rcu_read_lock_sched_held(void) |
244 | { | 244 | { |
245 | int lockdep_opinion = 0; | 245 | int lockdep_opinion = 0; |
@@ -250,12 +250,12 @@ static inline int rcu_read_lock_sched_held(void) | |||
250 | lockdep_opinion = lock_is_held(&rcu_sched_lock_map); | 250 | lockdep_opinion = lock_is_held(&rcu_sched_lock_map); |
251 | return lockdep_opinion || preempt_count() != 0 || irqs_disabled(); | 251 | return lockdep_opinion || preempt_count() != 0 || irqs_disabled(); |
252 | } | 252 | } |
253 | #else /* #ifdef CONFIG_PREEMPT */ | 253 | #else /* #ifdef CONFIG_PREEMPT_COUNT */ |
254 | static inline int rcu_read_lock_sched_held(void) | 254 | static inline int rcu_read_lock_sched_held(void) |
255 | { | 255 | { |
256 | return 1; | 256 | return 1; |
257 | } | 257 | } |
258 | #endif /* #else #ifdef CONFIG_PREEMPT */ | 258 | #endif /* #else #ifdef CONFIG_PREEMPT_COUNT */ |
259 | 259 | ||
260 | #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */ | 260 | #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */ |
261 | 261 | ||
@@ -276,17 +276,17 @@ static inline int rcu_read_lock_bh_held(void) | |||
276 | return 1; | 276 | return 1; |
277 | } | 277 | } |
278 | 278 | ||
279 | #ifdef CONFIG_PREEMPT | 279 | #ifdef CONFIG_PREEMPT_COUNT |
280 | static inline int rcu_read_lock_sched_held(void) | 280 | static inline int rcu_read_lock_sched_held(void) |
281 | { | 281 | { |
282 | return preempt_count() != 0 || irqs_disabled(); | 282 | return preempt_count() != 0 || irqs_disabled(); |
283 | } | 283 | } |
284 | #else /* #ifdef CONFIG_PREEMPT */ | 284 | #else /* #ifdef CONFIG_PREEMPT_COUNT */ |
285 | static inline int rcu_read_lock_sched_held(void) | 285 | static inline int rcu_read_lock_sched_held(void) |
286 | { | 286 | { |
287 | return 1; | 287 | return 1; |
288 | } | 288 | } |
289 | #endif /* #else #ifdef CONFIG_PREEMPT */ | 289 | #endif /* #else #ifdef CONFIG_PREEMPT_COUNT */ |
290 | 290 | ||
291 | #endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */ | 291 | #endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */ |
292 | 292 | ||
diff --git a/include/linux/sched.h b/include/linux/sched.h index f6ef727ee4fc..ed766add9b23 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -2526,7 +2526,7 @@ extern int _cond_resched(void); | |||
2526 | 2526 | ||
2527 | extern int __cond_resched_lock(spinlock_t *lock); | 2527 | extern int __cond_resched_lock(spinlock_t *lock); |
2528 | 2528 | ||
2529 | #ifdef CONFIG_PREEMPT | 2529 | #ifdef CONFIG_PREEMPT_COUNT |
2530 | #define PREEMPT_LOCK_OFFSET PREEMPT_OFFSET | 2530 | #define PREEMPT_LOCK_OFFSET PREEMPT_OFFSET |
2531 | #else | 2531 | #else |
2532 | #define PREEMPT_LOCK_OFFSET 0 | 2532 | #define PREEMPT_LOCK_OFFSET 0 |
diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt index bf987b95b356..24e7cb0ba26a 100644 --- a/kernel/Kconfig.preempt +++ b/kernel/Kconfig.preempt | |||
@@ -35,6 +35,7 @@ config PREEMPT_VOLUNTARY | |||
35 | 35 | ||
36 | config PREEMPT | 36 | config PREEMPT |
37 | bool "Preemptible Kernel (Low-Latency Desktop)" | 37 | bool "Preemptible Kernel (Low-Latency Desktop)" |
38 | select PREEMPT_COUNT | ||
38 | help | 39 | help |
39 | This option reduces the latency of the kernel by making | 40 | This option reduces the latency of the kernel by making |
40 | all kernel code (that is not executing in a critical section) | 41 | all kernel code (that is not executing in a critical section) |
@@ -52,3 +53,5 @@ config PREEMPT | |||
52 | 53 | ||
53 | endchoice | 54 | endchoice |
54 | 55 | ||
56 | config PREEMPT_COUNT | ||
57 | bool \ No newline at end of file | ||
diff --git a/kernel/sched.c b/kernel/sched.c index 84b9e076812e..9aaf567c5da5 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -124,7 +124,7 @@ | |||
124 | 124 | ||
125 | static inline int rt_policy(int policy) | 125 | static inline int rt_policy(int policy) |
126 | { | 126 | { |
127 | if (unlikely(policy == SCHED_FIFO || policy == SCHED_RR)) | 127 | if (policy == SCHED_FIFO || policy == SCHED_RR) |
128 | return 1; | 128 | return 1; |
129 | return 0; | 129 | return 0; |
130 | } | 130 | } |
@@ -422,6 +422,7 @@ struct rt_rq { | |||
422 | */ | 422 | */ |
423 | struct root_domain { | 423 | struct root_domain { |
424 | atomic_t refcount; | 424 | atomic_t refcount; |
425 | atomic_t rto_count; | ||
425 | struct rcu_head rcu; | 426 | struct rcu_head rcu; |
426 | cpumask_var_t span; | 427 | cpumask_var_t span; |
427 | cpumask_var_t online; | 428 | cpumask_var_t online; |
@@ -431,7 +432,6 @@ struct root_domain { | |||
431 | * one runnable RT task. | 432 | * one runnable RT task. |
432 | */ | 433 | */ |
433 | cpumask_var_t rto_mask; | 434 | cpumask_var_t rto_mask; |
434 | atomic_t rto_count; | ||
435 | struct cpupri cpupri; | 435 | struct cpupri cpupri; |
436 | }; | 436 | }; |
437 | 437 | ||
@@ -1568,38 +1568,6 @@ static unsigned long cpu_avg_load_per_task(int cpu) | |||
1568 | return rq->avg_load_per_task; | 1568 | return rq->avg_load_per_task; |
1569 | } | 1569 | } |
1570 | 1570 | ||
1571 | #ifdef CONFIG_FAIR_GROUP_SCHED | ||
1572 | |||
1573 | /* | ||
1574 | * Compute the cpu's hierarchical load factor for each task group. | ||
1575 | * This needs to be done in a top-down fashion because the load of a child | ||
1576 | * group is a fraction of its parents load. | ||
1577 | */ | ||
1578 | static int tg_load_down(struct task_group *tg, void *data) | ||
1579 | { | ||
1580 | unsigned long load; | ||
1581 | long cpu = (long)data; | ||
1582 | |||
1583 | if (!tg->parent) { | ||
1584 | load = cpu_rq(cpu)->load.weight; | ||
1585 | } else { | ||
1586 | load = tg->parent->cfs_rq[cpu]->h_load; | ||
1587 | load *= tg->se[cpu]->load.weight; | ||
1588 | load /= tg->parent->cfs_rq[cpu]->load.weight + 1; | ||
1589 | } | ||
1590 | |||
1591 | tg->cfs_rq[cpu]->h_load = load; | ||
1592 | |||
1593 | return 0; | ||
1594 | } | ||
1595 | |||
1596 | static void update_h_load(long cpu) | ||
1597 | { | ||
1598 | walk_tg_tree(tg_load_down, tg_nop, (void *)cpu); | ||
1599 | } | ||
1600 | |||
1601 | #endif | ||
1602 | |||
1603 | #ifdef CONFIG_PREEMPT | 1571 | #ifdef CONFIG_PREEMPT |
1604 | 1572 | ||
1605 | static void double_rq_lock(struct rq *rq1, struct rq *rq2); | 1573 | static void double_rq_lock(struct rq *rq1, struct rq *rq2); |
@@ -2497,7 +2465,7 @@ ttwu_do_wakeup(struct rq *rq, struct task_struct *p, int wake_flags) | |||
2497 | if (p->sched_class->task_woken) | 2465 | if (p->sched_class->task_woken) |
2498 | p->sched_class->task_woken(rq, p); | 2466 | p->sched_class->task_woken(rq, p); |
2499 | 2467 | ||
2500 | if (unlikely(rq->idle_stamp)) { | 2468 | if (rq->idle_stamp) { |
2501 | u64 delta = rq->clock - rq->idle_stamp; | 2469 | u64 delta = rq->clock - rq->idle_stamp; |
2502 | u64 max = 2*sysctl_sched_migration_cost; | 2470 | u64 max = 2*sysctl_sched_migration_cost; |
2503 | 2471 | ||
@@ -2886,7 +2854,7 @@ void sched_fork(struct task_struct *p) | |||
2886 | #if defined(CONFIG_SMP) | 2854 | #if defined(CONFIG_SMP) |
2887 | p->on_cpu = 0; | 2855 | p->on_cpu = 0; |
2888 | #endif | 2856 | #endif |
2889 | #ifdef CONFIG_PREEMPT | 2857 | #ifdef CONFIG_PREEMPT_COUNT |
2890 | /* Want to start with kernel preemption disabled. */ | 2858 | /* Want to start with kernel preemption disabled. */ |
2891 | task_thread_info(p)->preempt_count = 1; | 2859 | task_thread_info(p)->preempt_count = 1; |
2892 | #endif | 2860 | #endif |
@@ -4338,11 +4306,8 @@ EXPORT_SYMBOL(schedule); | |||
4338 | 4306 | ||
4339 | static inline bool owner_running(struct mutex *lock, struct task_struct *owner) | 4307 | static inline bool owner_running(struct mutex *lock, struct task_struct *owner) |
4340 | { | 4308 | { |
4341 | bool ret = false; | ||
4342 | |||
4343 | rcu_read_lock(); | ||
4344 | if (lock->owner != owner) | 4309 | if (lock->owner != owner) |
4345 | goto fail; | 4310 | return false; |
4346 | 4311 | ||
4347 | /* | 4312 | /* |
4348 | * Ensure we emit the owner->on_cpu, dereference _after_ checking | 4313 | * Ensure we emit the owner->on_cpu, dereference _after_ checking |
@@ -4352,11 +4317,7 @@ static inline bool owner_running(struct mutex *lock, struct task_struct *owner) | |||
4352 | */ | 4317 | */ |
4353 | barrier(); | 4318 | barrier(); |
4354 | 4319 | ||
4355 | ret = owner->on_cpu; | 4320 | return owner->on_cpu; |
4356 | fail: | ||
4357 | rcu_read_unlock(); | ||
4358 | |||
4359 | return ret; | ||
4360 | } | 4321 | } |
4361 | 4322 | ||
4362 | /* | 4323 | /* |
@@ -4368,21 +4329,21 @@ int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner) | |||
4368 | if (!sched_feat(OWNER_SPIN)) | 4329 | if (!sched_feat(OWNER_SPIN)) |
4369 | return 0; | 4330 | return 0; |
4370 | 4331 | ||
4332 | rcu_read_lock(); | ||
4371 | while (owner_running(lock, owner)) { | 4333 | while (owner_running(lock, owner)) { |
4372 | if (need_resched()) | 4334 | if (need_resched()) |
4373 | return 0; | 4335 | break; |
4374 | 4336 | ||
4375 | arch_mutex_cpu_relax(); | 4337 | arch_mutex_cpu_relax(); |
4376 | } | 4338 | } |
4339 | rcu_read_unlock(); | ||
4377 | 4340 | ||
4378 | /* | 4341 | /* |
4379 | * If the owner changed to another task there is likely | 4342 | * We break out the loop above on need_resched() and when the |
4380 | * heavy contention, stop spinning. | 4343 | * owner changed, which is a sign for heavy contention. Return |
4344 | * success only when lock->owner is NULL. | ||
4381 | */ | 4345 | */ |
4382 | if (lock->owner) | 4346 | return lock->owner == NULL; |
4383 | return 0; | ||
4384 | |||
4385 | return 1; | ||
4386 | } | 4347 | } |
4387 | #endif | 4348 | #endif |
4388 | 4349 | ||
@@ -7898,17 +7859,10 @@ int in_sched_functions(unsigned long addr) | |||
7898 | && addr < (unsigned long)__sched_text_end); | 7859 | && addr < (unsigned long)__sched_text_end); |
7899 | } | 7860 | } |
7900 | 7861 | ||
7901 | static void init_cfs_rq(struct cfs_rq *cfs_rq, struct rq *rq) | 7862 | static void init_cfs_rq(struct cfs_rq *cfs_rq) |
7902 | { | 7863 | { |
7903 | cfs_rq->tasks_timeline = RB_ROOT; | 7864 | cfs_rq->tasks_timeline = RB_ROOT; |
7904 | INIT_LIST_HEAD(&cfs_rq->tasks); | 7865 | INIT_LIST_HEAD(&cfs_rq->tasks); |
7905 | #ifdef CONFIG_FAIR_GROUP_SCHED | ||
7906 | cfs_rq->rq = rq; | ||
7907 | /* allow initial update_cfs_load() to truncate */ | ||
7908 | #ifdef CONFIG_SMP | ||
7909 | cfs_rq->load_stamp = 1; | ||
7910 | #endif | ||
7911 | #endif | ||
7912 | cfs_rq->min_vruntime = (u64)(-(1LL << 20)); | 7866 | cfs_rq->min_vruntime = (u64)(-(1LL << 20)); |
7913 | #ifndef CONFIG_64BIT | 7867 | #ifndef CONFIG_64BIT |
7914 | cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime; | 7868 | cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime; |
@@ -7928,13 +7882,9 @@ static void init_rt_rq(struct rt_rq *rt_rq, struct rq *rq) | |||
7928 | /* delimiter for bitsearch: */ | 7882 | /* delimiter for bitsearch: */ |
7929 | __set_bit(MAX_RT_PRIO, array->bitmap); | 7883 | __set_bit(MAX_RT_PRIO, array->bitmap); |
7930 | 7884 | ||
7931 | #if defined CONFIG_SMP || defined CONFIG_RT_GROUP_SCHED | 7885 | #if defined CONFIG_SMP |
7932 | rt_rq->highest_prio.curr = MAX_RT_PRIO; | 7886 | rt_rq->highest_prio.curr = MAX_RT_PRIO; |
7933 | #ifdef CONFIG_SMP | ||
7934 | rt_rq->highest_prio.next = MAX_RT_PRIO; | 7887 | rt_rq->highest_prio.next = MAX_RT_PRIO; |
7935 | #endif | ||
7936 | #endif | ||
7937 | #ifdef CONFIG_SMP | ||
7938 | rt_rq->rt_nr_migratory = 0; | 7888 | rt_rq->rt_nr_migratory = 0; |
7939 | rt_rq->overloaded = 0; | 7889 | rt_rq->overloaded = 0; |
7940 | plist_head_init(&rt_rq->pushable_tasks); | 7890 | plist_head_init(&rt_rq->pushable_tasks); |
@@ -7944,11 +7894,6 @@ static void init_rt_rq(struct rt_rq *rt_rq, struct rq *rq) | |||
7944 | rt_rq->rt_throttled = 0; | 7894 | rt_rq->rt_throttled = 0; |
7945 | rt_rq->rt_runtime = 0; | 7895 | rt_rq->rt_runtime = 0; |
7946 | raw_spin_lock_init(&rt_rq->rt_runtime_lock); | 7896 | raw_spin_lock_init(&rt_rq->rt_runtime_lock); |
7947 | |||
7948 | #ifdef CONFIG_RT_GROUP_SCHED | ||
7949 | rt_rq->rt_nr_boosted = 0; | ||
7950 | rt_rq->rq = rq; | ||
7951 | #endif | ||
7952 | } | 7897 | } |
7953 | 7898 | ||
7954 | #ifdef CONFIG_FAIR_GROUP_SCHED | 7899 | #ifdef CONFIG_FAIR_GROUP_SCHED |
@@ -7957,11 +7902,17 @@ static void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq, | |||
7957 | struct sched_entity *parent) | 7902 | struct sched_entity *parent) |
7958 | { | 7903 | { |
7959 | struct rq *rq = cpu_rq(cpu); | 7904 | struct rq *rq = cpu_rq(cpu); |
7960 | tg->cfs_rq[cpu] = cfs_rq; | 7905 | |
7961 | init_cfs_rq(cfs_rq, rq); | ||
7962 | cfs_rq->tg = tg; | 7906 | cfs_rq->tg = tg; |
7907 | cfs_rq->rq = rq; | ||
7908 | #ifdef CONFIG_SMP | ||
7909 | /* allow initial update_cfs_load() to truncate */ | ||
7910 | cfs_rq->load_stamp = 1; | ||
7911 | #endif | ||
7963 | 7912 | ||
7913 | tg->cfs_rq[cpu] = cfs_rq; | ||
7964 | tg->se[cpu] = se; | 7914 | tg->se[cpu] = se; |
7915 | |||
7965 | /* se could be NULL for root_task_group */ | 7916 | /* se could be NULL for root_task_group */ |
7966 | if (!se) | 7917 | if (!se) |
7967 | return; | 7918 | return; |
@@ -7984,12 +7935,14 @@ static void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq, | |||
7984 | { | 7935 | { |
7985 | struct rq *rq = cpu_rq(cpu); | 7936 | struct rq *rq = cpu_rq(cpu); |
7986 | 7937 | ||
7987 | tg->rt_rq[cpu] = rt_rq; | 7938 | rt_rq->highest_prio.curr = MAX_RT_PRIO; |
7988 | init_rt_rq(rt_rq, rq); | 7939 | rt_rq->rt_nr_boosted = 0; |
7940 | rt_rq->rq = rq; | ||
7989 | rt_rq->tg = tg; | 7941 | rt_rq->tg = tg; |
7990 | rt_rq->rt_runtime = tg->rt_bandwidth.rt_runtime; | ||
7991 | 7942 | ||
7943 | tg->rt_rq[cpu] = rt_rq; | ||
7992 | tg->rt_se[cpu] = rt_se; | 7944 | tg->rt_se[cpu] = rt_se; |
7945 | |||
7993 | if (!rt_se) | 7946 | if (!rt_se) |
7994 | return; | 7947 | return; |
7995 | 7948 | ||
@@ -8071,7 +8024,7 @@ void __init sched_init(void) | |||
8071 | rq->nr_running = 0; | 8024 | rq->nr_running = 0; |
8072 | rq->calc_load_active = 0; | 8025 | rq->calc_load_active = 0; |
8073 | rq->calc_load_update = jiffies + LOAD_FREQ; | 8026 | rq->calc_load_update = jiffies + LOAD_FREQ; |
8074 | init_cfs_rq(&rq->cfs, rq); | 8027 | init_cfs_rq(&rq->cfs); |
8075 | init_rt_rq(&rq->rt, rq); | 8028 | init_rt_rq(&rq->rt, rq); |
8076 | #ifdef CONFIG_FAIR_GROUP_SCHED | 8029 | #ifdef CONFIG_FAIR_GROUP_SCHED |
8077 | root_task_group.shares = root_task_group_load; | 8030 | root_task_group.shares = root_task_group_load; |
@@ -8185,7 +8138,7 @@ void __init sched_init(void) | |||
8185 | scheduler_running = 1; | 8138 | scheduler_running = 1; |
8186 | } | 8139 | } |
8187 | 8140 | ||
8188 | #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP | 8141 | #ifdef CONFIG_DEBUG_ATOMIC_SLEEP |
8189 | static inline int preempt_count_equals(int preempt_offset) | 8142 | static inline int preempt_count_equals(int preempt_offset) |
8190 | { | 8143 | { |
8191 | int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth(); | 8144 | int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth(); |
@@ -8195,7 +8148,6 @@ static inline int preempt_count_equals(int preempt_offset) | |||
8195 | 8148 | ||
8196 | void __might_sleep(const char *file, int line, int preempt_offset) | 8149 | void __might_sleep(const char *file, int line, int preempt_offset) |
8197 | { | 8150 | { |
8198 | #ifdef in_atomic | ||
8199 | static unsigned long prev_jiffy; /* ratelimiting */ | 8151 | static unsigned long prev_jiffy; /* ratelimiting */ |
8200 | 8152 | ||
8201 | if ((preempt_count_equals(preempt_offset) && !irqs_disabled()) || | 8153 | if ((preempt_count_equals(preempt_offset) && !irqs_disabled()) || |
@@ -8217,7 +8169,6 @@ void __might_sleep(const char *file, int line, int preempt_offset) | |||
8217 | if (irqs_disabled()) | 8169 | if (irqs_disabled()) |
8218 | print_irqtrace_events(current); | 8170 | print_irqtrace_events(current); |
8219 | dump_stack(); | 8171 | dump_stack(); |
8220 | #endif | ||
8221 | } | 8172 | } |
8222 | EXPORT_SYMBOL(__might_sleep); | 8173 | EXPORT_SYMBOL(__might_sleep); |
8223 | #endif | 8174 | #endif |
@@ -8376,6 +8327,7 @@ int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent) | |||
8376 | if (!se) | 8327 | if (!se) |
8377 | goto err_free_rq; | 8328 | goto err_free_rq; |
8378 | 8329 | ||
8330 | init_cfs_rq(cfs_rq); | ||
8379 | init_tg_cfs_entry(tg, cfs_rq, se, i, parent->se[i]); | 8331 | init_tg_cfs_entry(tg, cfs_rq, se, i, parent->se[i]); |
8380 | } | 8332 | } |
8381 | 8333 | ||
@@ -8403,7 +8355,7 @@ static inline void unregister_fair_sched_group(struct task_group *tg, int cpu) | |||
8403 | list_del_leaf_cfs_rq(tg->cfs_rq[cpu]); | 8355 | list_del_leaf_cfs_rq(tg->cfs_rq[cpu]); |
8404 | raw_spin_unlock_irqrestore(&rq->lock, flags); | 8356 | raw_spin_unlock_irqrestore(&rq->lock, flags); |
8405 | } | 8357 | } |
8406 | #else /* !CONFG_FAIR_GROUP_SCHED */ | 8358 | #else /* !CONFIG_FAIR_GROUP_SCHED */ |
8407 | static inline void free_fair_sched_group(struct task_group *tg) | 8359 | static inline void free_fair_sched_group(struct task_group *tg) |
8408 | { | 8360 | { |
8409 | } | 8361 | } |
@@ -8424,7 +8376,8 @@ static void free_rt_sched_group(struct task_group *tg) | |||
8424 | { | 8376 | { |
8425 | int i; | 8377 | int i; |
8426 | 8378 | ||
8427 | destroy_rt_bandwidth(&tg->rt_bandwidth); | 8379 | if (tg->rt_se) |
8380 | destroy_rt_bandwidth(&tg->rt_bandwidth); | ||
8428 | 8381 | ||
8429 | for_each_possible_cpu(i) { | 8382 | for_each_possible_cpu(i) { |
8430 | if (tg->rt_rq) | 8383 | if (tg->rt_rq) |
@@ -8465,6 +8418,8 @@ int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent) | |||
8465 | if (!rt_se) | 8418 | if (!rt_se) |
8466 | goto err_free_rq; | 8419 | goto err_free_rq; |
8467 | 8420 | ||
8421 | init_rt_rq(rt_rq, cpu_rq(i)); | ||
8422 | rt_rq->rt_runtime = tg->rt_bandwidth.rt_runtime; | ||
8468 | init_tg_rt_entry(tg, rt_rq, rt_se, i, parent->rt_se[i]); | 8423 | init_tg_rt_entry(tg, rt_rq, rt_se, i, parent->rt_se[i]); |
8469 | } | 8424 | } |
8470 | 8425 | ||
diff --git a/kernel/sched_autogroup.h b/kernel/sched_autogroup.h index 05577055cfca..c2f0e7248dca 100644 --- a/kernel/sched_autogroup.h +++ b/kernel/sched_autogroup.h | |||
@@ -13,6 +13,7 @@ struct autogroup { | |||
13 | int nice; | 13 | int nice; |
14 | }; | 14 | }; |
15 | 15 | ||
16 | static inline bool task_group_is_autogroup(struct task_group *tg); | ||
16 | static inline struct task_group * | 17 | static inline struct task_group * |
17 | autogroup_task_group(struct task_struct *p, struct task_group *tg); | 18 | autogroup_task_group(struct task_struct *p, struct task_group *tg); |
18 | 19 | ||
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index c768588e180b..bc8ee9993814 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c | |||
@@ -135,14 +135,6 @@ static inline struct cfs_rq *group_cfs_rq(struct sched_entity *grp) | |||
135 | return grp->my_q; | 135 | return grp->my_q; |
136 | } | 136 | } |
137 | 137 | ||
138 | /* Given a group's cfs_rq on one cpu, return its corresponding cfs_rq on | ||
139 | * another cpu ('this_cpu') | ||
140 | */ | ||
141 | static inline struct cfs_rq *cpu_cfs_rq(struct cfs_rq *cfs_rq, int this_cpu) | ||
142 | { | ||
143 | return cfs_rq->tg->cfs_rq[this_cpu]; | ||
144 | } | ||
145 | |||
146 | static inline void list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq) | 138 | static inline void list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq) |
147 | { | 139 | { |
148 | if (!cfs_rq->on_list) { | 140 | if (!cfs_rq->on_list) { |
@@ -271,11 +263,6 @@ static inline struct cfs_rq *group_cfs_rq(struct sched_entity *grp) | |||
271 | return NULL; | 263 | return NULL; |
272 | } | 264 | } |
273 | 265 | ||
274 | static inline struct cfs_rq *cpu_cfs_rq(struct cfs_rq *cfs_rq, int this_cpu) | ||
275 | { | ||
276 | return &cpu_rq(this_cpu)->cfs; | ||
277 | } | ||
278 | |||
279 | static inline void list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq) | 266 | static inline void list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq) |
280 | { | 267 | { |
281 | } | 268 | } |
@@ -334,11 +321,6 @@ static inline int entity_before(struct sched_entity *a, | |||
334 | return (s64)(a->vruntime - b->vruntime) < 0; | 321 | return (s64)(a->vruntime - b->vruntime) < 0; |
335 | } | 322 | } |
336 | 323 | ||
337 | static inline s64 entity_key(struct cfs_rq *cfs_rq, struct sched_entity *se) | ||
338 | { | ||
339 | return se->vruntime - cfs_rq->min_vruntime; | ||
340 | } | ||
341 | |||
342 | static void update_min_vruntime(struct cfs_rq *cfs_rq) | 324 | static void update_min_vruntime(struct cfs_rq *cfs_rq) |
343 | { | 325 | { |
344 | u64 vruntime = cfs_rq->min_vruntime; | 326 | u64 vruntime = cfs_rq->min_vruntime; |
@@ -372,7 +354,6 @@ static void __enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) | |||
372 | struct rb_node **link = &cfs_rq->tasks_timeline.rb_node; | 354 | struct rb_node **link = &cfs_rq->tasks_timeline.rb_node; |
373 | struct rb_node *parent = NULL; | 355 | struct rb_node *parent = NULL; |
374 | struct sched_entity *entry; | 356 | struct sched_entity *entry; |
375 | s64 key = entity_key(cfs_rq, se); | ||
376 | int leftmost = 1; | 357 | int leftmost = 1; |
377 | 358 | ||
378 | /* | 359 | /* |
@@ -385,7 +366,7 @@ static void __enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) | |||
385 | * We dont care about collisions. Nodes with | 366 | * We dont care about collisions. Nodes with |
386 | * the same key stay together. | 367 | * the same key stay together. |
387 | */ | 368 | */ |
388 | if (key < entity_key(cfs_rq, entry)) { | 369 | if (entity_before(se, entry)) { |
389 | link = &parent->rb_left; | 370 | link = &parent->rb_left; |
390 | } else { | 371 | } else { |
391 | link = &parent->rb_right; | 372 | link = &parent->rb_right; |
@@ -1336,7 +1317,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) | |||
1336 | } | 1317 | } |
1337 | 1318 | ||
1338 | for_each_sched_entity(se) { | 1319 | for_each_sched_entity(se) { |
1339 | struct cfs_rq *cfs_rq = cfs_rq_of(se); | 1320 | cfs_rq = cfs_rq_of(se); |
1340 | 1321 | ||
1341 | update_cfs_load(cfs_rq, 0); | 1322 | update_cfs_load(cfs_rq, 0); |
1342 | update_cfs_shares(cfs_rq); | 1323 | update_cfs_shares(cfs_rq); |
@@ -1370,13 +1351,16 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) | |||
1370 | */ | 1351 | */ |
1371 | if (task_sleep && parent_entity(se)) | 1352 | if (task_sleep && parent_entity(se)) |
1372 | set_next_buddy(parent_entity(se)); | 1353 | set_next_buddy(parent_entity(se)); |
1354 | |||
1355 | /* avoid re-evaluating load for this entity */ | ||
1356 | se = parent_entity(se); | ||
1373 | break; | 1357 | break; |
1374 | } | 1358 | } |
1375 | flags |= DEQUEUE_SLEEP; | 1359 | flags |= DEQUEUE_SLEEP; |
1376 | } | 1360 | } |
1377 | 1361 | ||
1378 | for_each_sched_entity(se) { | 1362 | for_each_sched_entity(se) { |
1379 | struct cfs_rq *cfs_rq = cfs_rq_of(se); | 1363 | cfs_rq = cfs_rq_of(se); |
1380 | 1364 | ||
1381 | update_cfs_load(cfs_rq, 0); | 1365 | update_cfs_load(cfs_rq, 0); |
1382 | update_cfs_shares(cfs_rq); | 1366 | update_cfs_shares(cfs_rq); |
@@ -1481,7 +1465,6 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync) | |||
1481 | * effect of the currently running task from the load | 1465 | * effect of the currently running task from the load |
1482 | * of the current CPU: | 1466 | * of the current CPU: |
1483 | */ | 1467 | */ |
1484 | rcu_read_lock(); | ||
1485 | if (sync) { | 1468 | if (sync) { |
1486 | tg = task_group(current); | 1469 | tg = task_group(current); |
1487 | weight = current->se.load.weight; | 1470 | weight = current->se.load.weight; |
@@ -1517,7 +1500,6 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync) | |||
1517 | balanced = this_eff_load <= prev_eff_load; | 1500 | balanced = this_eff_load <= prev_eff_load; |
1518 | } else | 1501 | } else |
1519 | balanced = true; | 1502 | balanced = true; |
1520 | rcu_read_unlock(); | ||
1521 | 1503 | ||
1522 | /* | 1504 | /* |
1523 | * If the currently running task will sleep within | 1505 | * If the currently running task will sleep within |
@@ -1921,8 +1903,8 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_ | |||
1921 | if (!sched_feat(WAKEUP_PREEMPT)) | 1903 | if (!sched_feat(WAKEUP_PREEMPT)) |
1922 | return; | 1904 | return; |
1923 | 1905 | ||
1924 | update_curr(cfs_rq); | ||
1925 | find_matching_se(&se, &pse); | 1906 | find_matching_se(&se, &pse); |
1907 | update_curr(cfs_rq_of(se)); | ||
1926 | BUG_ON(!pse); | 1908 | BUG_ON(!pse); |
1927 | if (wakeup_preempt_entity(se, pse) == 1) { | 1909 | if (wakeup_preempt_entity(se, pse) == 1) { |
1928 | /* | 1910 | /* |
@@ -2231,11 +2213,43 @@ static void update_shares(int cpu) | |||
2231 | struct rq *rq = cpu_rq(cpu); | 2213 | struct rq *rq = cpu_rq(cpu); |
2232 | 2214 | ||
2233 | rcu_read_lock(); | 2215 | rcu_read_lock(); |
2216 | /* | ||
2217 | * Iterates the task_group tree in a bottom up fashion, see | ||
2218 | * list_add_leaf_cfs_rq() for details. | ||
2219 | */ | ||
2234 | for_each_leaf_cfs_rq(rq, cfs_rq) | 2220 | for_each_leaf_cfs_rq(rq, cfs_rq) |
2235 | update_shares_cpu(cfs_rq->tg, cpu); | 2221 | update_shares_cpu(cfs_rq->tg, cpu); |
2236 | rcu_read_unlock(); | 2222 | rcu_read_unlock(); |
2237 | } | 2223 | } |
2238 | 2224 | ||
2225 | /* | ||
2226 | * Compute the cpu's hierarchical load factor for each task group. | ||
2227 | * This needs to be done in a top-down fashion because the load of a child | ||
2228 | * group is a fraction of its parents load. | ||
2229 | */ | ||
2230 | static int tg_load_down(struct task_group *tg, void *data) | ||
2231 | { | ||
2232 | unsigned long load; | ||
2233 | long cpu = (long)data; | ||
2234 | |||
2235 | if (!tg->parent) { | ||
2236 | load = cpu_rq(cpu)->load.weight; | ||
2237 | } else { | ||
2238 | load = tg->parent->cfs_rq[cpu]->h_load; | ||
2239 | load *= tg->se[cpu]->load.weight; | ||
2240 | load /= tg->parent->cfs_rq[cpu]->load.weight + 1; | ||
2241 | } | ||
2242 | |||
2243 | tg->cfs_rq[cpu]->h_load = load; | ||
2244 | |||
2245 | return 0; | ||
2246 | } | ||
2247 | |||
2248 | static void update_h_load(long cpu) | ||
2249 | { | ||
2250 | walk_tg_tree(tg_load_down, tg_nop, (void *)cpu); | ||
2251 | } | ||
2252 | |||
2239 | static unsigned long | 2253 | static unsigned long |
2240 | load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest, | 2254 | load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest, |
2241 | unsigned long max_load_move, | 2255 | unsigned long max_load_move, |
@@ -2243,14 +2257,12 @@ load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest, | |||
2243 | int *all_pinned) | 2257 | int *all_pinned) |
2244 | { | 2258 | { |
2245 | long rem_load_move = max_load_move; | 2259 | long rem_load_move = max_load_move; |
2246 | int busiest_cpu = cpu_of(busiest); | 2260 | struct cfs_rq *busiest_cfs_rq; |
2247 | struct task_group *tg; | ||
2248 | 2261 | ||
2249 | rcu_read_lock(); | 2262 | rcu_read_lock(); |
2250 | update_h_load(busiest_cpu); | 2263 | update_h_load(cpu_of(busiest)); |
2251 | 2264 | ||
2252 | list_for_each_entry_rcu(tg, &task_groups, list) { | 2265 | for_each_leaf_cfs_rq(busiest, busiest_cfs_rq) { |
2253 | struct cfs_rq *busiest_cfs_rq = tg->cfs_rq[busiest_cpu]; | ||
2254 | unsigned long busiest_h_load = busiest_cfs_rq->h_load; | 2266 | unsigned long busiest_h_load = busiest_cfs_rq->h_load; |
2255 | unsigned long busiest_weight = busiest_cfs_rq->load.weight; | 2267 | unsigned long busiest_weight = busiest_cfs_rq->load.weight; |
2256 | u64 rem_load, moved_load; | 2268 | u64 rem_load, moved_load; |
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c index 10d018212bab..97540f0c9e47 100644 --- a/kernel/sched_rt.c +++ b/kernel/sched_rt.c | |||
@@ -185,11 +185,23 @@ static inline u64 sched_rt_period(struct rt_rq *rt_rq) | |||
185 | 185 | ||
186 | typedef struct task_group *rt_rq_iter_t; | 186 | typedef struct task_group *rt_rq_iter_t; |
187 | 187 | ||
188 | #define for_each_rt_rq(rt_rq, iter, rq) \ | 188 | static inline struct task_group *next_task_group(struct task_group *tg) |
189 | for (iter = list_entry_rcu(task_groups.next, typeof(*iter), list); \ | 189 | { |
190 | (&iter->list != &task_groups) && \ | 190 | do { |
191 | (rt_rq = iter->rt_rq[cpu_of(rq)]); \ | 191 | tg = list_entry_rcu(tg->list.next, |
192 | iter = list_entry_rcu(iter->list.next, typeof(*iter), list)) | 192 | typeof(struct task_group), list); |
193 | } while (&tg->list != &task_groups && task_group_is_autogroup(tg)); | ||
194 | |||
195 | if (&tg->list == &task_groups) | ||
196 | tg = NULL; | ||
197 | |||
198 | return tg; | ||
199 | } | ||
200 | |||
201 | #define for_each_rt_rq(rt_rq, iter, rq) \ | ||
202 | for (iter = container_of(&task_groups, typeof(*iter), list); \ | ||
203 | (iter = next_task_group(iter)) && \ | ||
204 | (rt_rq = iter->rt_rq[cpu_of(rq)]);) | ||
193 | 205 | ||
194 | static inline void list_add_leaf_rt_rq(struct rt_rq *rt_rq) | 206 | static inline void list_add_leaf_rt_rq(struct rt_rq *rt_rq) |
195 | { | 207 | { |
@@ -1126,7 +1138,7 @@ static struct task_struct *_pick_next_task_rt(struct rq *rq) | |||
1126 | 1138 | ||
1127 | rt_rq = &rq->rt; | 1139 | rt_rq = &rq->rt; |
1128 | 1140 | ||
1129 | if (unlikely(!rt_rq->rt_nr_running)) | 1141 | if (!rt_rq->rt_nr_running) |
1130 | return NULL; | 1142 | return NULL; |
1131 | 1143 | ||
1132 | if (rt_rq_throttled(rt_rq)) | 1144 | if (rt_rq_throttled(rt_rq)) |
@@ -1548,7 +1560,7 @@ skip: | |||
1548 | static void pre_schedule_rt(struct rq *rq, struct task_struct *prev) | 1560 | static void pre_schedule_rt(struct rq *rq, struct task_struct *prev) |
1549 | { | 1561 | { |
1550 | /* Try to pull RT tasks here if we lower this rq's prio */ | 1562 | /* Try to pull RT tasks here if we lower this rq's prio */ |
1551 | if (unlikely(rt_task(prev)) && rq->rt.highest_prio.curr > prev->prio) | 1563 | if (rq->rt.highest_prio.curr > prev->prio) |
1552 | pull_rt_task(rq); | 1564 | pull_rt_task(rq); |
1553 | } | 1565 | } |
1554 | 1566 | ||
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 9c28fa4202f8..c0cb9c4bc46d 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -648,12 +648,15 @@ config TRACE_IRQFLAGS | |||
648 | Enables hooks to interrupt enabling and disabling for | 648 | Enables hooks to interrupt enabling and disabling for |
649 | either tracing or lock debugging. | 649 | either tracing or lock debugging. |
650 | 650 | ||
651 | config DEBUG_SPINLOCK_SLEEP | 651 | config DEBUG_ATOMIC_SLEEP |
652 | bool "Spinlock debugging: sleep-inside-spinlock checking" | 652 | bool "Sleep inside atomic section checking" |
653 | select PREEMPT_COUNT | ||
653 | depends on DEBUG_KERNEL | 654 | depends on DEBUG_KERNEL |
654 | help | 655 | help |
655 | If you say Y here, various routines which may sleep will become very | 656 | If you say Y here, various routines which may sleep will become very |
656 | noisy if they are called with a spinlock held. | 657 | noisy if they are called inside atomic sections: when a spinlock is |
658 | held, inside an rcu read side critical section, inside preempt disabled | ||
659 | sections, inside an interrupt, etc... | ||
657 | 660 | ||
658 | config DEBUG_LOCKING_API_SELFTESTS | 661 | config DEBUG_LOCKING_API_SELFTESTS |
659 | bool "Locking API boot-time self-tests" | 662 | bool "Locking API boot-time self-tests" |