diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-11-26 00:55:39 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-11-30 14:47:33 -0500 |
commit | 1ce0bf50ae2233c7115a18c0c623662d177b434c (patch) | |
tree | 41860e17fe4b2184055d29e669e503d09796775a /include/linux/wait.h | |
parent | c52fd05a2ff2ad20e2a7056baf314c7d1d624ba9 (diff) |
net: Generalise wq_has_sleeper helper
The memory barrier in the helper wq_has_sleeper is needed by just
about every user of waitqueue_active. This patch generalises it
by making it take a wait_queue_head_t directly. The existing
helper is renamed to skwq_has_sleeper.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/wait.h')
-rw-r--r-- | include/linux/wait.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h index 1e1bf9f963a9..6aa09a875fbd 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h | |||
@@ -107,6 +107,27 @@ static inline int waitqueue_active(wait_queue_head_t *q) | |||
107 | return !list_empty(&q->task_list); | 107 | return !list_empty(&q->task_list); |
108 | } | 108 | } |
109 | 109 | ||
110 | /** | ||
111 | * wq_has_sleeper - check if there are any waiting processes | ||
112 | * @wq: wait queue head | ||
113 | * | ||
114 | * Returns true if wq has waiting processes | ||
115 | * | ||
116 | * Please refer to the comment for waitqueue_active. | ||
117 | */ | ||
118 | static inline bool wq_has_sleeper(wait_queue_head_t *wq) | ||
119 | { | ||
120 | /* | ||
121 | * We need to be sure we are in sync with the | ||
122 | * add_wait_queue modifications to the wait queue. | ||
123 | * | ||
124 | * This memory barrier should be paired with one on the | ||
125 | * waiting side. | ||
126 | */ | ||
127 | smp_mb(); | ||
128 | return waitqueue_active(wq); | ||
129 | } | ||
130 | |||
110 | extern void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait); | 131 | extern void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait); |
111 | extern void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait); | 132 | extern void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait); |
112 | extern void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait); | 133 | extern void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait); |