Skip to content

Commit 8cc351a

Browse files
arjunroygregkh
authored andcommitted
tcp: Prevent low rmem stalls with SO_RCVLOWAT.
[ Upstream commit 435ccfa ] With SO_RCVLOWAT, under memory pressure, it is possible to enter a state where: 1. We have not received enough bytes to satisfy SO_RCVLOWAT. 2. We have not entered buffer pressure (see tcp_rmem_pressure()). 3. But, we do not have enough buffer space to accept more packets. In this case, we advertise 0 rwnd (due to #3) but the application does not drain the receive queue (no wakeup because of #1 and #2) so the flow stalls. Modify the heuristic for SO_RCVLOWAT so that, if we are advertising rwnd<=rcv_mss, force a wakeup to prevent a stall. Without this patch, setting tcp_rmem to 6143 and disabling TCP autotune causes a stalled flow. With this patch, no stall occurs. This is with RPC-style traffic with large messages. Fixes: 03f45c8 ("tcp: avoid extra wakeups for SO_RCVLOWAT users") Signed-off-by: Arjun Roy <[email protected]> Acked-by: Soheil Hassas Yeganeh <[email protected]> Acked-by: Neal Cardwell <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7740774 commit 8cc351a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

net/ipv4/tcp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ static inline bool tcp_stream_is_readable(const struct tcp_sock *tp,
484484
return true;
485485
if (tcp_rmem_pressure(sk))
486486
return true;
487+
if (tcp_receive_window(tp) <= inet_csk(sk)->icsk_ack.rcv_mss)
488+
return true;
487489
}
488490
if (sk->sk_prot->stream_memory_read)
489491
return sk->sk_prot->stream_memory_read(sk);

net/ipv4/tcp_input.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4774,7 +4774,8 @@ void tcp_data_ready(struct sock *sk)
47744774
int avail = tp->rcv_nxt - tp->copied_seq;
47754775

47764776
if (avail < sk->sk_rcvlowat && !tcp_rmem_pressure(sk) &&
4777-
!sock_flag(sk, SOCK_DONE))
4777+
!sock_flag(sk, SOCK_DONE) &&
4778+
tcp_receive_window(tp) > inet_csk(sk)->icsk_ack.rcv_mss)
47784779
return;
47794780

47804781
sk->sk_data_ready(sk);

0 commit comments

Comments
 (0)