From: Eric Dumazet Date: Tue, 18 Apr 2017 16:45:51 +0000 (-0700) Subject: tcp: remove poll() flakes when receiving RST X-Git-Tag: v5.15~11411^2~151^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d4762639dd36a5f0f433f0c9d82e9743dc21a33;p=platform%2Fkernel%2Flinux-starfive.git tcp: remove poll() flakes when receiving RST When a RST packet is processed, we send two wakeup events to interested polling users. First one by a sk->sk_error_report(sk) from tcp_reset(), followed by a sk->sk_state_change(sk) from tcp_done(). Depending on machine load and luck, poll() can either return POLLERR, or POLLIN|POLLOUT|POLLERR|POLLHUP (this happens on 99 % of the cases) This is probably fine, but we can avoid the confusion by reordering things so that we have more TCP fields updated before the first wakeup. This might even allow us to remove some barriers we added in the past. Signed-off-by: Eric Dumazet Acked-by: Soheil Hassas Yeganeh Signed-off-by: David S. Miller --- diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index a583885..37e2aa9 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4008,10 +4008,10 @@ void tcp_reset(struct sock *sk) /* This barrier is coupled with smp_rmb() in tcp_poll() */ smp_wmb(); + tcp_done(sk); + if (!sock_flag(sk, SOCK_DEAD)) sk->sk_error_report(sk); - - tcp_done(sk); } /*