Commit 3c715127 authored by jbaron@akamai.com's avatar jbaron@akamai.com Committed by David S. Miller

tcp: add memory barriers to write space paths

Ensure that we either see that the buffer has write space
in tcp_poll() or that we perform a wakeup from the input
side. Did not run into any actual problem here, but thought
that we should make things explicit.
Signed-off-by: default avatarJason Baron <jbaron@akamai.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 71cd26e7
...@@ -520,8 +520,10 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait) ...@@ -520,8 +520,10 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
/* Race breaker. If space is freed after /* Race breaker. If space is freed after
* wspace test but before the flags are set, * wspace test but before the flags are set,
* IO signal will be lost. * IO signal will be lost. Memory barrier
* pairs with the input side.
*/ */
smp_mb__after_atomic();
if (sk_stream_is_writeable(sk)) if (sk_stream_is_writeable(sk))
mask |= POLLOUT | POLLWRNORM; mask |= POLLOUT | POLLWRNORM;
} }
......
...@@ -4845,6 +4845,8 @@ static void tcp_check_space(struct sock *sk) ...@@ -4845,6 +4845,8 @@ static void tcp_check_space(struct sock *sk)
{ {
if (sock_flag(sk, SOCK_QUEUE_SHRUNK)) { if (sock_flag(sk, SOCK_QUEUE_SHRUNK)) {
sock_reset_flag(sk, SOCK_QUEUE_SHRUNK); sock_reset_flag(sk, SOCK_QUEUE_SHRUNK);
/* pairs with tcp_poll() */
smp_mb__after_atomic();
if (sk->sk_socket && if (sk->sk_socket &&
test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) test_bit(SOCK_NOSPACE, &sk->sk_socket->flags))
tcp_new_space(sk); tcp_new_space(sk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment