From mboxrd@z Thu Jan 1 00:00:00 1970 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 D87CFC282C0 for ; Fri, 25 Jan 2019 18:53:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A7E3B218D0 for ; Fri, 25 Jan 2019 18:53:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kJRu3ply" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726604AbfAYSxs (ORCPT ); Fri, 25 Jan 2019 13:53:48 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:32981 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbfAYSxs (ORCPT ); Fri, 25 Jan 2019 13:53:48 -0500 Received: by mail-pf1-f196.google.com with SMTP id c123so5173240pfb.0 for ; Fri, 25 Jan 2019 10:53:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GolhdH6G1Bt3n/LnUIOrF5FQMzduvz++cFZ98aV46hI=; b=kJRu3plylhfUBtdc5PuXpKktj6MMUDy4ligXAUDKWfUCxTPKpF2816oGgFSpou+BeL s74CTHgmycVLzMOcwceaD9pg/ATgXT1J1SN6wboVxUVMw6Zo0ebvpazfNSOvjhLA4m0R OI+ctBoJ4+Fat13JSP/ndFb4hlw56ck82uw2Mb1NHck17zjNVN1s+m33dCgV2ccgtZ7g P8/9a/PjyoQSKDFDR7y63EMStkYO91+0tCqaVUhHA7OXx8rLiId7/9Wt79EUQ+kugwbG jA/CVNcq75Ult+2V1HAABjpuW1UaZ23372DxvwXplycACKGqN9RaE9HRCjCLIjRpEjGK Jdiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GolhdH6G1Bt3n/LnUIOrF5FQMzduvz++cFZ98aV46hI=; b=OlD2ihPsKU6/fXItdXYz5qzhCrj630FnkNdkWSZn+i/lNrs78Pzri7ETeanlrAKcyx q+XcElocYocj4yduxiFFsaLcXQR+ZIUHo8wUHZBaOJ4A0w4Qj3IYBfkYVZTIHt6wxn5d kxGQQY7hTyGj2gxsLI5f0KK0XwJadAEo8cn1T7FGVNW3kYpfNYpKYCfdoK+h5yZS7Ih6 KKFWpa1G/hDapk6O8GsTUVCkCAjT/4NfHuYhjBEKACpgDtzZfbszRbM1sg5rT8WPrMY5 rZ/Wc92RAQW6+2ADihLxPxwVXTV5/CEibYDiMylXuRZEZ4AQtMN1zz+Jhk5i98+07Neb 22KQ== X-Gm-Message-State: AJcUuken3MRErZNagTP1KMcYFYjBsR5OrDnKMEEJktPnGxpbWjUIasGe Do64Tm/PetLpghzhwu3T9ZbbGA== X-Google-Smtp-Source: ALg8bN5pYT/Cb1HNuNuRtbrVGI6vAnoY2TR03W7uznbS9jn4X8LtTK71tdMPiwuAdcZK7CXe6qe7IA== X-Received: by 2002:a63:a91a:: with SMTP id u26mr10793870pge.349.1548442426560; Fri, 25 Jan 2019 10:53:46 -0800 (PST) Received: from localhost ([2620:15c:2c4:201:9310:64cb:677b:dcba]) by smtp.gmail.com with ESMTPSA id r8sm32993312pgu.38.2019.01.25.10.53.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Jan 2019 10:53:45 -0800 (PST) From: Wei Wang To: David Miller , netdev@vger.kernel.org Cc: Yuchung Cheng , Neal Cardwell , Eric Dumazet , Wei Wang Subject: [PATCH net-next 2/2] tcp: change pingpong threshold to 3 Date: Fri, 25 Jan 2019 10:53:20 -0800 Message-Id: <20190125185320.164580-3-weiwan@google.com> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog In-Reply-To: <20190125185320.164580-2-weiwan@google.com> References: <20190125185320.164580-1-weiwan@google.com> <20190125185320.164580-2-weiwan@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In order to be more confident about an on-going interactive session, we increment pingpong count by 1 for every interactive transaction and we adjust TCP_PINGPONG_THRESH to 3. This means, we only consider a session in pingpong mode after we see 3 interactive transactions, and start to activate delayed acks in quick ack mode. And in order to not over-count the credits, we only increase pingpong count for the first packet sent in response for the previous received packet. This is mainly to prevent delaying the ack immediately after some handshake protocol but no real interactive traffic pattern afterwards. Signed-off-by: Wei Wang Signed-off-by: Yuchung Cheng Signed-off-by: Eric Dumazet --- include/net/inet_connection_sock.h | 10 +++++++++- net/ipv4/tcp_output.c | 15 +++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index 5c9fa6b72c5a..6d67eede41d2 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -315,7 +315,7 @@ int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname, struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu); -#define TCP_PINGPONG_THRESH 1 +#define TCP_PINGPONG_THRESH 3 static inline void inet_csk_enter_pingpong_mode(struct sock *sk) { @@ -331,4 +331,12 @@ static inline bool inet_csk_in_pingpong_mode(struct sock *sk) { return inet_csk(sk)->icsk_ack.pingpong >= TCP_PINGPONG_THRESH; } + +static inline void inet_csk_inc_pingpong_cnt(struct sock *sk) +{ + struct inet_connection_sock *icsk = inet_csk(sk); + + if (icsk->icsk_ack.pingpong < U8_MAX) + icsk->icsk_ack.pingpong++; +} #endif /* _INET_CONNECTION_SOCK_H */ diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 130e43b31210..79a25b174d0e 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -165,13 +165,16 @@ static void tcp_event_data_sent(struct tcp_sock *tp, if (tcp_packets_in_flight(tp) == 0) tcp_ca_event(sk, CA_EVENT_TX_START); - tp->lsndtime = now; - - /* If it is a reply for ato after last received - * packet, enter pingpong mode. + /* If this is the first data packet sent in response to the + * previous received data, + * and it is a reply for ato after last received packet, + * increase pingpong count. */ - if ((u32)(now - icsk->icsk_ack.lrcvtime) < icsk->icsk_ack.ato) - inet_csk_enter_pingpong_mode(sk); + if (before(tp->lsndtime, icsk->icsk_ack.lrcvtime) && + (u32)(now - icsk->icsk_ack.lrcvtime) < icsk->icsk_ack.ato) + inet_csk_inc_pingpong_cnt(sk); + + tp->lsndtime = now; } /* Account for an ACK we sent. */ -- 2.20.1.321.g9e740568ce-goog