[PATCH 2/2] wait: Use the per-task wait_queue_t in ___wait_event macro

From: Rasmus Villemoes
Date: Tue Jun 10 2014 - 08:31:30 EST


The ___wait_event macro satisfies the requirements for making use of
the per-task wait_queue_t, so use it. This should make the stack
footprint of all users of the wait_event_* macros smaller.

Signed-off-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
---
include/linux/wait.h | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/linux/wait.h b/include/linux/wait.h
index 94279be..5f51252 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -207,17 +207,17 @@ wait_queue_head_t *bit_waitqueue(void *, int);
#define ___wait_event(wq, condition, state, exclusive, ret, cmd) \
({ \
__label__ __out; \
- wait_queue_t __wait; \
+ wait_queue_t *__wait = current_wq_get(); \
long __ret = ret; /* explicit shadow */ \
\
- INIT_LIST_HEAD(&__wait.task_list); \
+ INIT_LIST_HEAD(&__wait->task_list); \
if (exclusive) \
- __wait.flags = WQ_FLAG_EXCLUSIVE; \
+ __wait->flags = WQ_FLAG_EXCLUSIVE; \
else \
- __wait.flags = 0; \
+ __wait->flags = 0; \
\
for (;;) { \
- long __int = prepare_to_wait_event(&wq, &__wait, state);\
+ long __int = prepare_to_wait_event(&wq, __wait, state); \
\
if (condition) \
break; \
@@ -225,7 +225,7 @@ wait_queue_head_t *bit_waitqueue(void *, int);
if (___wait_is_interruptible(state) && __int) { \
__ret = __int; \
if (exclusive) { \
- abort_exclusive_wait(&wq, &__wait, \
+ abort_exclusive_wait(&wq, __wait, \
state, NULL); \
goto __out; \
} \
@@ -234,8 +234,9 @@ wait_queue_head_t *bit_waitqueue(void *, int);
\
cmd; \
} \
- finish_wait(&wq, &__wait); \
-__out: __ret; \
+ finish_wait(&wq, __wait); \
+__out: current_wq_put(__wait); \
+ __ret; \
})

#define __wait_event(wq, condition) \
--
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/