Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9155FC10F14 for ; Tue, 16 Apr 2019 17:55:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 61A032087C for ; Tue, 16 Apr 2019 17:55:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eS99cjdh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730440AbfDPRz0 (ORCPT ); Tue, 16 Apr 2019 13:55:26 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:33936 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730382AbfDPRzZ (ORCPT ); Tue, 16 Apr 2019 13:55:25 -0400 Received: by mail-pg1-f201.google.com with SMTP id z7so13021512pgc.1 for ; Tue, 16 Apr 2019 10:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=sxLMciU9u2UrLVfwq/yZuENHYbQw12/rG9FRflbHQCg=; b=eS99cjdhFMRC3yBEBbGtyOG9S+g4l4OZ4h14Gqlxq5y3GRal3c3vcF09OELD1faU6o TdbHIuUWnC9wp3TDLkn9VYqJXY7CQ9qBY8Kzb718lyKrzvusQshyS7mbWlbuPPuK9qa6 FK8v3182eqRp+/KfRj4BsOduBPa7YIR5O9inB1+nFAGrjh/klEwRalqtwrnf5IPfjzcc CYep1oVs6QKRNqnzDxJeXRV4PZusFWbm/TWJE2gTHj4D9JkVWKGu9+TX8TfICU7aNw2s QykhESweFSNb/kBNR5qerkHliYYt99SbKjIB+S+MWL2M5qsbwqBGQe/fsRJtgrzm9KWf B3bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=sxLMciU9u2UrLVfwq/yZuENHYbQw12/rG9FRflbHQCg=; b=ihB99vqK7DFZRQD+bsgKt8i0TNepr5HWkVMXkle4CRp0AHDIiM5C0J+DVrxn3mG6Nx 8yaDc/uJFkLklPWisHi8H9/0CvSLPko32tck3l2oj+70EGjrWAnl81RRJ8TxfCTrYwAK 3vgLeOcitfXQfK04G8gTeaUMI80sz4sC9txsdjYX2c4VvYffjrFIWUzMVomgNHZoFw4d E2/LGJEXXzxxx+46qCUoFrIdwtOpzu5QS6Ex5vzjiBWENTgKuyyGdqJFxIgUcRppmYmq GZqwFt+Y9qpImyLBth2N6Q4Q9j6eBYhX7MIh2iRAbcazf3y3eR+kHDnly77VIEzAiaX4 3Rlg== X-Gm-Message-State: APjAAAUJdOC2sg/8VtwBlkkaUnSK7je7MX7qv+hhyky+xbb36jDZC1cU J43y657UncOV4bud5RRtFxC4Is7jELHd9w== X-Google-Smtp-Source: APXvYqwDVR3soBUipdQB0E2AcPFV6MdloLfuLeDJxhKx+yRexabMXq5JXZVg/GqwG1OcGc9a7MAsWYuFDIi+sA== X-Received: by 2002:a17:902:740b:: with SMTP id g11mr3145312pll.127.1555437323889; Tue, 16 Apr 2019 10:55:23 -0700 (PDT) Date: Tue, 16 Apr 2019 10:55:20 -0700 Message-Id: <20190416175520.56712-1-edumazet@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH net] tcp: tcp_grow_window() needs to respect tcp_space() From: Eric Dumazet To: "David S . Miller" Cc: netdev , Eric Dumazet , Eric Dumazet , Soheil Hassas Yeganeh , Neal Cardwell , Wei Wang Content-Type: text/plain; charset="UTF-8" Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org For some reason, tcp_grow_window() correctly tests if enough room is present before attempting to increase tp->rcv_ssthresh, but does not prevent it to grow past tcp_space() This is causing hard to debug issues, like failing the (__tcp_select_window(sk) >= tp->rcv_wnd) test in __tcp_ack_snd_check(), causing ACK delays and possibly slow flows. Depending on tcp_rmem[2], MTU, skb->len/skb->truesize ratio, we can see the problem happening on "netperf -t TCP_RR -- -r 2000,2000" after about 60 round trips, when the active side no longer sends immediate acks. This bug predates git history. Signed-off-by: Eric Dumazet Acked-by: Soheil Hassas Yeganeh Acked-by: Neal Cardwell Acked-by: Wei Wang --- net/ipv4/tcp_input.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 5def3c48870e17f42ac9424a6ee091ac4824dabc..731d3045b50a0fb9a89c887a154db9a3da8c7ddd 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -402,11 +402,12 @@ static int __tcp_grow_window(const struct sock *sk, const struct sk_buff *skb) static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb) { struct tcp_sock *tp = tcp_sk(sk); + int room; + + room = min_t(int, tp->window_clamp, tcp_space(sk)) - tp->rcv_ssthresh; /* Check #1 */ - if (tp->rcv_ssthresh < tp->window_clamp && - (int)tp->rcv_ssthresh < tcp_space(sk) && - !tcp_under_memory_pressure(sk)) { + if (room > 0 && !tcp_under_memory_pressure(sk)) { int incr; /* Check #2. Increase window, if skb with such overhead @@ -419,8 +420,7 @@ static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb) if (incr) { incr = max_t(int, incr, 2 * skb->len); - tp->rcv_ssthresh = min(tp->rcv_ssthresh + incr, - tp->window_clamp); + tp->rcv_ssthresh += min(room, incr); inet_csk(sk)->icsk_ack.quick |= 1; } } -- 2.21.0.392.gf8f6787159e-goog