diff options
author | Oleg Nesterov <oleg@redhat.com> | 2016-09-06 10:00:55 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-09-30 04:54:03 -0400 |
commit | 0176beaffbe9ed627b6a4dfa61d640f1a848086f (patch) | |
tree | 88d38997e19ca0fc353f6b48021efbf84c427612 | |
parent | eaf9ef52241b545fe63621266bfc6fd8b06559ff (diff) |
sched/wait: Introduce init_wait_entry()
The partial initialization of wait_queue_t in prepare_to_wait_event() looks
ugly. This was done to shrink .text, but we can simply add the new helper
which does the full initialization and shrink the compiled code a bit more.
And. This way prepare_to_wait_event() can have more users. In particular we
are ready to remove the signal_pending_state() checks from wait_bit_action_f
helpers and change __wait_on_bit_lock() to use prepare_to_wait_event().
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Neil Brown <neilb@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20160906140055.GA6167@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | include/linux/wait.h | 9 | ||||
-rw-r--r-- | kernel/sched/wait.c | 12 |
2 files changed, 12 insertions, 9 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h index 19c75f9545ce..2408e8d5c05c 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h | |||
@@ -248,6 +248,8 @@ wait_queue_head_t *bit_waitqueue(void *, int); | |||
248 | (!__builtin_constant_p(state) || \ | 248 | (!__builtin_constant_p(state) || \ |
249 | state == TASK_INTERRUPTIBLE || state == TASK_KILLABLE) \ | 249 | state == TASK_INTERRUPTIBLE || state == TASK_KILLABLE) \ |
250 | 250 | ||
251 | extern void init_wait_entry(wait_queue_t *__wait, int flags); | ||
252 | |||
251 | /* | 253 | /* |
252 | * The below macro ___wait_event() has an explicit shadow of the __ret | 254 | * The below macro ___wait_event() has an explicit shadow of the __ret |
253 | * variable when used from the wait_event_*() macros. | 255 | * variable when used from the wait_event_*() macros. |
@@ -266,12 +268,7 @@ wait_queue_head_t *bit_waitqueue(void *, int); | |||
266 | wait_queue_t __wait; \ | 268 | wait_queue_t __wait; \ |
267 | long __ret = ret; /* explicit shadow */ \ | 269 | long __ret = ret; /* explicit shadow */ \ |
268 | \ | 270 | \ |
269 | INIT_LIST_HEAD(&__wait.task_list); \ | 271 | init_wait_entry(&__wait, exclusive ? WQ_FLAG_EXCLUSIVE : 0); \ |
270 | if (exclusive) \ | ||
271 | __wait.flags = WQ_FLAG_EXCLUSIVE; \ | ||
272 | else \ | ||
273 | __wait.flags = 0; \ | ||
274 | \ | ||
275 | for (;;) { \ | 272 | for (;;) { \ |
276 | long __int = prepare_to_wait_event(&wq, &__wait, state);\ | 273 | long __int = prepare_to_wait_event(&wq, &__wait, state);\ |
277 | \ | 274 | \ |
diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c index 0cb615d69013..4f7053579fe3 100644 --- a/kernel/sched/wait.c +++ b/kernel/sched/wait.c | |||
@@ -196,14 +196,20 @@ prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state) | |||
196 | } | 196 | } |
197 | EXPORT_SYMBOL(prepare_to_wait_exclusive); | 197 | EXPORT_SYMBOL(prepare_to_wait_exclusive); |
198 | 198 | ||
199 | void init_wait_entry(wait_queue_t *wait, int flags) | ||
200 | { | ||
201 | wait->flags = flags; | ||
202 | wait->private = current; | ||
203 | wait->func = autoremove_wake_function; | ||
204 | INIT_LIST_HEAD(&wait->task_list); | ||
205 | } | ||
206 | EXPORT_SYMBOL(init_wait_entry); | ||
207 | |||
199 | long prepare_to_wait_event(wait_queue_head_t *q, wait_queue_t *wait, int state) | 208 | long prepare_to_wait_event(wait_queue_head_t *q, wait_queue_t *wait, int state) |
200 | { | 209 | { |
201 | unsigned long flags; | 210 | unsigned long flags; |
202 | long ret = 0; | 211 | long ret = 0; |
203 | 212 | ||
204 | wait->private = current; | ||
205 | wait->func = autoremove_wake_function; | ||
206 | |||
207 | spin_lock_irqsave(&q->lock, flags); | 213 | spin_lock_irqsave(&q->lock, flags); |
208 | if (unlikely(signal_pending_state(state, current))) { | 214 | if (unlikely(signal_pending_state(state, current))) { |
209 | /* | 215 | /* |