Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp541686rwd; Sat, 20 May 2023 02:16:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7jkcM+fFfn2JBUPxDocnxed3HG3J1lBBWqBUDyRZEjmxeD7v7ITj6ekIFkpzaDst5hMyGh X-Received: by 2002:a17:90a:bd18:b0:252:cd29:d3db with SMTP id y24-20020a17090abd1800b00252cd29d3dbmr4427018pjr.39.1684574191286; Sat, 20 May 2023 02:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684574191; cv=none; d=google.com; s=arc-20160816; b=ollvkyST0Ar5nP9lCKcCtP5eFvcrvyk9aicOeQrQkbWlfOIcVrZUI1+cAn/X3coYnB fviBmjz6TEbOpOgVexHVeazc9Jl1YoOqmBkhDkeStBr7rBjgUoOcRVKvcRjwPUBMLMMv YotyyolG4qCTvSdb/CSlk91p5ijAMjKzyWeTkECuyB1/n6rKRa9pdfJWSqSTj1aZo1HA tB5Ay0X94oh7s9mclwJ/jcBOZ6RuBStyBYlvqpxL685EUNuc6Zfp7dyM3M+vbDxlTJSm /wk9g5S2pTy//zBrEG3Sf5hRDF/yUR4Ux7JaESIKOgS9X6v4YGuTvbT9myIXl5KcOyYv +cCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=XfLDx7gZ7ffDR8UWXBnKEy5S/l+ELbSVQlFX2fs43Kw=; b=JhSGopGKBgq3ZXN4wHqvUxffyj4K8h+ETuylrXCD7J83+QepLVYp0S26XNOdr58Oem XdNt2R0Gr+OEptFwCps7wCUliiqDjtqRECvxRn7R6vWjyuNHo2R1rIav+1+xzlnBi6IS 9Z/TyjLAYyyGQONX9wyTaeh4hiRyf0+EiY8Yts5SuR+EYWUTsc2AIG3mW77aivacxWOr o5Z42E7IHQk2eFz7M5vyqZA8j0Bkpv/PM5JV56iOnoZ6peYDgB4NYUuCSR6MhYz6v5aD V4k2TPFpzKoaNV9KOkUK8BeN59Iog0mGyWKnZBNU6MYVrl2XVdOH4TPM8Yuwmp2WZdl8 X2VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=DVd7utPa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r134-20020a632b8c000000b0052c22753de4si1200078pgr.662.2023.05.20.02.16.17; Sat, 20 May 2023 02:16:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=DVd7utPa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbjETJIM (ORCPT + 99 others); Sat, 20 May 2023 05:08:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbjETJIK (ORCPT ); Sat, 20 May 2023 05:08:10 -0400 Received: from mail-yw1-x1141.google.com (mail-yw1-x1141.google.com [IPv6:2607:f8b0:4864:20::1141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 244041A1; Sat, 20 May 2023 02:08:08 -0700 (PDT) Received: by mail-yw1-x1141.google.com with SMTP id 00721157ae682-561a33b6d63so56317157b3.1; Sat, 20 May 2023 02:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684573687; x=1687165687; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XfLDx7gZ7ffDR8UWXBnKEy5S/l+ELbSVQlFX2fs43Kw=; b=DVd7utPaKv/OyCTklhWeNOSb5ePOy4FxZRi/ZfhDt6aXQ60fmOIKXxyNa0BsGTD9kf j9elsz9UXV6tc22s+GilVme8XXCwuXFdRWadgpGqwHUoFBrQuYOXaLYtS6CljYH8TRFb 1Aoxx/JyBqnftWtPHmC02xRJBD8HCIXGEo7dyiYA8bouchhVwv51/roKPlKtchS1TBQe rjlyD2AhJ8n0Y+a9TnTKTXXCh36rGLHtxDSLhtOcW4rG0ey14f4Lb+jJmcgZzLDTapBH HeuC8ksaw9St3SVTBIUycpOIIYoRAAZkThgiCExZtCNZWyE7rS3YvRgBKInxn+nxVXbC hWuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684573687; x=1687165687; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XfLDx7gZ7ffDR8UWXBnKEy5S/l+ELbSVQlFX2fs43Kw=; b=MZ0hya8T4vXW/qqUyOCwcenUsmeB71RA5lCcGRIiCF8d4DPfNsc9/2yTaLnFugVw4+ Ga0dyrdWG4ft99F++TjlwBQ1wiqg/C8FGzZTT1rvwJ0cNoPoiHBuZWkXTtusufze85wT pVRIaK6aTaA7SeZ/xdvOmstofHLL39mkcjn6ZzJ4CpE1uGNhRn7Hh0HsLtf0AenW65sk Q5IHMnhh7jD44fTZvc72Sh0mERF8jRQrV0kSqsb1oBT71j1vnXuwFQikgHbs1e87Xi3N ZTwuNrPIM25vZdESM0xFGJWEm6xMq7dxybKmBsOF6AA2+5StN+qEklQxD/nCfjEPFloJ e3mg== X-Gm-Message-State: AC+VfDzSsc+5bLAIxRRgARIJ0Jl/lEHBVZvXGtdFwleII5HsYg4y/HBW QI27tkUViHhqhPginJ+my+/GCe5sdxdxOGASqMk= X-Received: by 2002:a81:48d3:0:b0:55d:626c:b62f with SMTP id v202-20020a8148d3000000b0055d626cb62fmr4946232ywa.51.1684573687222; Sat, 20 May 2023 02:08:07 -0700 (PDT) MIME-Version: 1.0 References: <20230517124201.441634-1-imagedong@tencent.com> <20230517124201.441634-4-imagedong@tencent.com> In-Reply-To: From: Menglong Dong Date: Sat, 20 May 2023 17:07:55 +0800 Message-ID: Subject: Re: [PATCH net-next 3/3] net: tcp: handle window shrink properly To: Neal Cardwell , Eric Dumazet , kuba@kernel.org Cc: davem@davemloft.net, pabeni@redhat.com, dsahern@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Menglong Dong , Yuchung Cheng Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 19, 2023 at 12:03=E2=80=AFAM Neal Cardwell wrote: > > On Thu, May 18, 2023 at 10:12=E2=80=AFAM Menglong Dong wrote: > > > > On Thu, May 18, 2023 at 9:40=E2=80=AFPM Neal Cardwell wrote: > > > > > > On Wed, May 17, 2023 at 10:35=E2=80=AFPM Menglong Dong wrote: > > > > > > > > On Wed, May 17, 2023 at 10:47=E2=80=AFPM Eric Dumazet wrote: > > > > > > > > > > On Wed, May 17, 2023 at 2:42=E2=80=AFPM wrote: > > > > > > > > > > > > From: Menglong Dong > > > > > > > > > > > > Window shrink is not allowed and also not handled for now, but = it's > > > > > > needed in some case. > > > > > > > > > > > > In the origin logic, 0 probe is triggered only when there is no= any > > > > > > data in the retrans queue and the receive window can't hold the= data > > > > > > of the 1th packet in the send queue. > > > > > > > > > > > > Now, let's change it and trigger the 0 probe in such cases: > > > > > > > > > > > > - if the retrans queue has data and the 1th packet in it is not= within > > > > > > the receive window > > > > > > - no data in the retrans queue and the 1th packet in the send q= ueue is > > > > > > out of the end of the receive window > > > > > > > > > > Sorry, I do not understand. > > > > > > > > > > Please provide packetdrill tests for new behavior like that. > > > > > > > > > > > > > Yes. The problem can be reproduced easily. > > > > > > > > 1. choose a server machine, decrease it's tcp_mem with: > > > > echo '1024 1500 2048' > /proc/sys/net/ipv4/tcp_mem > > > > 2. call listen() and accept() on a port, such as 8888. We call > > > > accept() looply and without call recv() to make the data stay > > > > in the receive queue. > > > > 3. choose a client machine, and create 100 TCP connection > > > > to the 8888 port of the server. Then, every connection sends > > > > data about 1M. > > > > 4. we can see that some of the connection enter the 0-probe > > > > state, but some of them keep retrans again and again. As > > > > the server is up to the tcp_mem[2] and skb is dropped before > > > > the recv_buf full and the connection enter 0-probe state. > > > > Finially, some of these connection will timeout and break. > > > > > > > > With this series, all the 100 connections will enter 0-probe > > > > status and connection break won't happen. And the data > > > > trans will recover if we increase tcp_mem or call 'recv()' > > > > on the sockets in the server. > > > > > > > > > Also, such fundamental change would need IETF discussion first. > > > > > We do not want linux to cause network collapses just because bill= ions > > > > > of devices send more zero probes. > > > > > > > > I think it maybe a good idea to make the connection enter > > > > 0-probe, rather than drop the skb silently. What 0-probe > > > > meaning is to wait for space available when the buffer of the > > > > receive queue is full. And maybe we can also use 0-probe > > > > when the "buffer" of "TCP protocol" (which means tcp_mem) > > > > is full? > > > > > > > > Am I right? > > > > > > > > Thanks! > > > > Menglong Dong > > > > > > Thanks for describing the scenario in more detail. (Some kind of > > > packetdrill script or other program to reproduce this issue would be > > > nice, too, as Eric noted.) > > > > > > You mention in step (4.) above that some of the connections keep > > > retransmitting again and again. Are those connections receiving any > > > ACKs in response to their retransmissions? Perhaps they are receiving > > > dupacks? > > > > Actually, these packets are dropped without any reply, even dupacks. > > skb will be dropped directly when tcp_try_rmem_schedule() > > fails in tcp_data_queue(). That's reasonable, as it's > > useless to reply a ack to the sender, which will cause the sender > > fast retrans the packet, because we are out of memory now, and > > retrans can't solve the problem. > > I'm not sure I see the problem. If retransmits can't solve the > problem, then why are you proposing that data senders keep > retransmitting forever (via 0-window-probes) in this kind of scenario? > Because the connection will break if the count of retransmits up to tcp_retires2, but probe-0 can keep for a long time. > A single dupack without SACK blocks will not cause the sender to fast > retransmit. (Only 3 dupacks would trigger fast retransmit.) > > Three or more dupacks without SACK blocks will cause the sender to > fast retransmit the segment above SND.UNA once if the sender doesn't > have SACK support. But in this case AFAICT fast-retransmitting once is > a fine strategy, since the sender should keep retrying transmits (with > backoff) until the receiver potentially has memory available to > receive the packet. > > > > > > If so, then perhaps we could solve this problem without > > > depending on a violation of the TCP spec (which says the receive > > > window should not be retracted) in the following way: when a data > > > sender suffers a retransmission timeout, and retransmits the first > > > unacknowledged segment, and receives a dupack for SND.UNA instead of > > > an ACK covering the RTO-retransmitted segment, then the data sender > > > should estimate that the receiver doesn't have enough memory to buffe= r > > > the retransmitted packet. In that case, the data sender should enter > > > the 0-probe state and repeatedly set the ICSK_TIME_PROBE0 timer to > > > call tcp_probe_timer(). > > > > > > Basically we could try to enhance the sender-side logic to try to > > > distinguish between two kinds of problems: > > > > > > (a) Repeated data packet loss caused by congestion, routing problems, > > > or connectivity problems. In this case, the data sender uses > > > ICSK_TIME_RETRANS and tcp_retransmit_timer(), and backs off and only > > > retries sysctl_tcp_retries2 times before timing out the connection > > > > > > (b) A receiver that is repeatedly sending dupacks but not ACKing > > > retransmitted data because it doesn't have any memory. In this case, > > > the data sender uses ICSK_TIME_PROBE0 and tcp_probe_timer(), and back= s > > > off but keeps retrying as long as the data sender receives ACKs. > > > > > > > I'm not sure if this is an ideal method, as it may be not rigorous > > to conclude that the receiver is oom with dupacks. A packet can > > loss can also cause multi dupacks. > > When a data sender suffers an RTO and retransmits a single data > packet, it would be very rare for the data sender to receive multiple > pure dupacks without SACKs. This would only happen in the rare case > where (a) the connection did not have SACK enabled, and (b) there was > a hole in the received sequence space and there were still packets in > flight when the (spurioius) RTO fired. > > But if we want to be paranoid, then this new response could be written > to only trigger if SACK is enabled (the vast, vast majority of cases). > If SACK is enabled, and an RTO of a data packet starting at sequence > S1 results in the receiver sending only a dupack for S1 without SACK > blocks, then this clearly shows the issue is not packet loss but > suggests a receiver unable to buffer the given data packet, AFAICT. > Yeah, you are right on this point, multi pure dupacks can mean out of memory of the receiver. But we still need to know if the receiver recovers from OOM. Without window shrink, the window in the ack of zero-window probe packet is not zero on OOM. Hi, Eric and kuba, do you have any comments on this case? Thanks! Menglong Dong > thanks, > neal > > > > > Thanks! > > Menglong Dong > > > > > AFAICT that would be another way to reach the happy state you mention= : > > > "all the 100 connections will enter 0-probe status and connection > > > break won't happen", and we could reach that state without violating > > > the TCP protocol spec and without requiring changes on the receiver > > > side (so that this fix could help in scenarios where the > > > memory-constrained receiver is an older stack without special new > > > behavior). > > > > > > Eric, Yuchung, Menglong: do you think something like that would work? > > > > > > neal