Message ID | 20230808115835.2862058-1-imagedong@tencent.com (mailing list archive) |
---|---|
Headers | show |
Series | net: tcp: support probing OOM | expand |
> On Aug 8, 2023, at 20:49, Eric Dumazet <edumazet@google.com> wrote: > > On Tue, Aug 8, 2023 at 1:59 PM <menglong8.dong@gmail.com> wrote: >> [……] >> >> diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c >> index d45c96c7f5a4..f30d1467771c 100644 >> --- a/net/ipv4/tcp_timer.c >> +++ b/net/ipv4/tcp_timer.c >> @@ -454,6 +454,18 @@ static void tcp_fastopen_synack_timer(struct sock *sk, struct request_sock *req) >> req->timeout << req->num_timeout, TCP_RTO_MAX); >> } >> >> +static bool tcp_rtx_probe0_timed_out(struct sock *sk) > > const struct sock *sk > >> +{ >> + struct tcp_sock *tp = tcp_sk(sk); > > const struct tcp_sock *tp = tcp_sk(sk); > >> + u32 timeout_ts, rtx_ts, rcv_ts; >> + >> + rtx_ts = tp->retrans_stamp; >> + rcv_ts = tp->rcv_tstamp; >> + timeout_ts = after(rtx_ts, rcv_ts) ? rtx_ts : rcv_ts; >> + timeout_ts += TCP_RTO_MAX; > > If we are concerned with a socket dying too soon, I would suggest > adding 2*TCP_RTO_MAX instead of TCP_RTO_MAX > > When a receiver is OOMing, it is possible the ACK RWIN 0 can not be sent all, > so tp->rcv_tstamp will not be refreshed. Or ACK could be lost in the > network path. Yeah, I concern abort this too. I introduce the funtion “tcp_rtx_probe0_timed_out()” here is to offer a more reliable way to check the timeout in the feature. And for this time, we can fix the problem first, as you advised, adding 2*TCP_RTO_MAX instead of TCP_RTO_MAX. > This also suggests the net_dbg_ratelimited("Peer %pI4:%u/%u > unexpectedly shrunk window %u:%u (repaired)\n"...) messages > are slightly wrong, because they could be printed even if we did not > receive a new ACK packet from the remote peer. > > Perhaps we should change them to include delays (how long @skb stayed > in rtx queue, how old is the last ACK we received) Sounds great, which is more valuable. I’ll change them in the next version. Thanks! Menglong Dong >> + >> + return after(inet_csk(sk)->icsk_timeout, timeout_ts); >> +} >> >> /** >> * tcp_retransmit_timer() - The TCP retransmit timeout handler >> @@ -519,7 +531,7 @@ void tcp_retransmit_timer(struct sock *sk) >> tp->snd_una, tp->snd_nxt); >> } >> #endif >> - if (tcp_jiffies32 - tp->rcv_tstamp > TCP_RTO_MAX) { >> + if (tcp_rtx_probe0_timed_out(sk)) { >> tcp_write_err(sk); >> goto out; >> } >> -- >> 2.40.1
From: Menglong Dong <imagedong@tencent.com> In this series, we make some small changes to make the tcp retransmission become zero-window probes if the receiver drops the skb because of memory pressure. In the 1st patch, we reply a zero-window ACK if the skb is dropped because out of memory, instead of dropping the skb silently. In the 2nd patch, we allow a zero-window ACK to update the window. In the 3rd patch, fix unexcepted socket die when snd_wnd is 0 in tcp_retransmit_timer(). After these changes, the tcp can probe the OOM of the receiver forever. Changes since v2: - refactor the code to avoid code duplication in the 1st patch - use after() instead of max() in tcp_rtx_probe0_timed_out() Changes since v1: - send 0 rwin ACK for the receive queue empty case when necessary in the 1st patch - send the ACK immediately by using the ICSK_ACK_NOW flag in the 1st patch - consider the case of the connection restart from idle, as Neal comment, in the 3rd patch Menglong Dong (3): net: tcp: send zero-window ACK when no memory net: tcp: allow zero-window ACK update the window net: tcp: fix unexcepted socket die when snd_wnd is 0 include/net/inet_connection_sock.h | 3 ++- net/ipv4/tcp_input.c | 20 +++++++++++++------- net/ipv4/tcp_output.c | 14 +++++++++++--- net/ipv4/tcp_timer.c | 14 +++++++++++++- 4 files changed, 39 insertions(+), 12 deletions(-)