diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/wait.h | 21 | ||||
-rw-r--r-- | include/net/sock.h | 15 |
2 files changed, 26 insertions, 10 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); |
diff --git a/include/net/sock.h b/include/net/sock.h index 7f89e4ba18d1..62d35afcb3ac 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -58,6 +58,7 @@ | |||
58 | #include <linux/memcontrol.h> | 58 | #include <linux/memcontrol.h> |
59 | #include <linux/static_key.h> | 59 | #include <linux/static_key.h> |
60 | #include <linux/sched.h> | 60 | #include <linux/sched.h> |
61 | #include <linux/wait.h> | ||
61 | 62 | ||
62 | #include <linux/filter.h> | 63 | #include <linux/filter.h> |
63 | #include <linux/rculist_nulls.h> | 64 | #include <linux/rculist_nulls.h> |
@@ -1879,12 +1880,12 @@ static inline bool sk_has_allocations(const struct sock *sk) | |||
1879 | } | 1880 | } |
1880 | 1881 | ||
1881 | /** | 1882 | /** |
1882 | * wq_has_sleeper - check if there are any waiting processes | 1883 | * skwq_has_sleeper - check if there are any waiting processes |
1883 | * @wq: struct socket_wq | 1884 | * @wq: struct socket_wq |
1884 | * | 1885 | * |
1885 | * Returns true if socket_wq has waiting processes | 1886 | * Returns true if socket_wq has waiting processes |
1886 | * | 1887 | * |
1887 | * The purpose of the wq_has_sleeper and sock_poll_wait is to wrap the memory | 1888 | * The purpose of the skwq_has_sleeper and sock_poll_wait is to wrap the memory |
1888 | * barrier call. They were added due to the race found within the tcp code. | 1889 | * barrier call. They were added due to the race found within the tcp code. |
1889 | * | 1890 | * |
1890 | * Consider following tcp code paths: | 1891 | * Consider following tcp code paths: |
@@ -1910,15 +1911,9 @@ static inline bool sk_has_allocations(const struct sock *sk) | |||
1910 | * data on the socket. | 1911 | * data on the socket. |
1911 | * | 1912 | * |
1912 | */ | 1913 | */ |
1913 | static inline bool wq_has_sleeper(struct socket_wq *wq) | 1914 | static inline bool skwq_has_sleeper(struct socket_wq *wq) |
1914 | { | 1915 | { |
1915 | /* We need to be sure we are in sync with the | 1916 | return wq && wq_has_sleeper(&wq->wait); |
1916 | * add_wait_queue modifications to the wait queue. | ||
1917 | * | ||
1918 | * This memory barrier is paired in the sock_poll_wait. | ||
1919 | */ | ||
1920 | smp_mb(); | ||
1921 | return wq && waitqueue_active(&wq->wait); | ||
1922 | } | 1917 | } |
1923 | 1918 | ||
1924 | /** | 1919 | /** |