* [PATCH] tcp: add memory barriers to write space paths
@ 2015-04-20 20:05 Jason Baron
2015-04-21 19:58 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jason Baron @ 2015-04-20 20:05 UTC (permalink / raw)
To: davem; +Cc: netdev, eric.dumazet
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: Jason Baron <jbaron@akamai.com>
---
net/ipv4/tcp.c | 4 +++-
net/ipv4/tcp_input.c | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 094a682..726341e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -520,8 +520,10 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
/* Race breaker. If space is freed after
* 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))
mask |= POLLOUT | POLLWRNORM;
}
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 031cf72..63b3d4e9 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4847,6 +4847,8 @@ static void tcp_check_space(struct sock *sk)
{
if (sock_flag(sk, SOCK_QUEUE_SHRUNK)) {
sock_reset_flag(sk, SOCK_QUEUE_SHRUNK);
+ /* pairs with tcp_poll() */
+ smp_mb__after_atomic();
if (sk->sk_socket &&
test_bit(SOCK_NOSPACE, &sk->sk_socket->flags))
tcp_new_space(sk);
--
1.8.2.rc2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tcp: add memory barriers to write space paths
2015-04-20 20:05 [PATCH] tcp: add memory barriers to write space paths Jason Baron
@ 2015-04-21 19:58 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-04-21 19:58 UTC (permalink / raw)
To: jbaron; +Cc: netdev, eric.dumazet
From: Jason Baron <jbaron@akamai.com>
Date: Mon, 20 Apr 2015 20:05:07 +0000 (GMT)
> 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: Jason Baron <jbaron@akamai.com>
This looks fine, applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-21 19:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-20 20:05 [PATCH] tcp: add memory barriers to write space paths Jason Baron
2015-04-21 19:58 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).