Skip to content

Commit 0176bea

Browse files
oleg-nesterovIngo Molnar
authored andcommitted
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Al Viro <[email protected]> Cc: Bart Van Assche <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Neil Brown <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent eaf9ef5 commit 0176bea

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

include/linux/wait.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ wait_queue_head_t *bit_waitqueue(void *, int);
248248
(!__builtin_constant_p(state) || \
249249
state == TASK_INTERRUPTIBLE || state == TASK_KILLABLE) \
250250

251+
extern void init_wait_entry(wait_queue_t *__wait, int flags);
252+
251253
/*
252254
* The below macro ___wait_event() has an explicit shadow of the __ret
253255
* variable when used from the wait_event_*() macros.
@@ -266,12 +268,7 @@ wait_queue_head_t *bit_waitqueue(void *, int);
266268
wait_queue_t __wait; \
267269
long __ret = ret; /* explicit shadow */ \
268270
\
269-
INIT_LIST_HEAD(&__wait.task_list); \
270-
if (exclusive) \
271-
__wait.flags = WQ_FLAG_EXCLUSIVE; \
272-
else \
273-
__wait.flags = 0; \
274-
\
271+
init_wait_entry(&__wait, exclusive ? WQ_FLAG_EXCLUSIVE : 0); \
275272
for (;;) { \
276273
long __int = prepare_to_wait_event(&wq, &__wait, state);\
277274
\

kernel/sched/wait.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,20 @@ prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state)
196196
}
197197
EXPORT_SYMBOL(prepare_to_wait_exclusive);
198198

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+
199208
long prepare_to_wait_event(wait_queue_head_t *q, wait_queue_t *wait, int state)
200209
{
201210
unsigned long flags;
202211
long ret = 0;
203212

204-
wait->private = current;
205-
wait->func = autoremove_wake_function;
206-
207213
spin_lock_irqsave(&q->lock, flags);
208214
if (unlikely(signal_pending_state(state, current))) {
209215
/*

0 commit comments

Comments
 (0)