From patchwork Thu Dec 7 17:43:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 845721 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="IlK/BB+x"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yt2sW2PfVz9ryT for ; Fri, 8 Dec 2017 04:43:59 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753063AbdLGRnr (ORCPT ); Thu, 7 Dec 2017 12:43:47 -0500 Received: from mail-yb0-f196.google.com ([209.85.213.196]:42691 "EHLO mail-yb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752234AbdLGRnm (ORCPT ); Thu, 7 Dec 2017 12:43:42 -0500 Received: by mail-yb0-f196.google.com with SMTP id t127so3280709ybf.9 for ; Thu, 07 Dec 2017 09:43:42 -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; bh=pEVHDBYx+rLUcKow/50dWCNpuuoPMHnA1jOr38Ngplk=; b=IlK/BB+xq4jHb1anZhyDM1m1ILCW4QzPxEL08dJpURohLpubDbpJLYBYpyYTFteyi+ sw0/4vWUexenX3xh0XJnB3eGuivXQuuTjaTxDHCLoejLwJpLLc5e5o3Fujl40R6yMoIS UQ4yoGDvot4lpsXKyOx8W82CdiT5pHLwa0y8kYdOGK3A8XznrnlUTJL0BYMjOZ8Q9OaO 9CLVV6XpkH707Nw9MFFkus51DrDGI1d41kdgKZxBGvvrnjt+QU+dITctr17sp6f25upb SykUSo1Rg6T1et6Bib9T9ruKMecXycb2j5wlNneZjbCql0L1CN7ce5PsK6brMHHYN8CR Frjw== 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; bh=pEVHDBYx+rLUcKow/50dWCNpuuoPMHnA1jOr38Ngplk=; b=crQoqRHTOyFNCYu8jaTqpWkYD6zVh+XVCs64MYspX9Q+A+HimROLwh4PjI4jvZfuoM IUnetl5rZm0NwFZnFo3KxmaVYy6Ho77OzwEry8v6KxkSyrfuKPPZlbNodgs2dKgHzX7p mL7lNprXav9nMsS+7Rzdtd/STXmGHj1bDbrhLcW5CBoVXoL9JFSPcB/rVbLrEFrn+Juo iAUP29Z4WoYcHaXEMbb8Eh8IA2GsnVZJmIymCnRmHsOuRTZ7vL+6o/xQA3JBMD2ID8TE NZKmO+HnygSKPtPM025CdX0kUtG7ahjQ1reL8Mk1pqr/7z6u1N+W8UbdDKgDL9/193IL qfIQ== X-Gm-Message-State: AKGB3mKOPtDf8ZPWMTO26BzYxTn2lX4dpqrmMCAfWGN6JKIJXc0TgPRf WpaNI+Ku0DMYFejgP8e9uGXwFg== X-Google-Smtp-Source: AGs4zMZazCJn2XscW71BwWFVF0wm/nFG+ro5RfMmTOb+7OK0/esMe1PTtkoSMzBXb+XR6h7p65XkMQ== X-Received: by 10.37.37.79 with SMTP id l76mr1145457ybl.39.1512668621587; Thu, 07 Dec 2017 09:43:41 -0800 (PST) Received: from joy.nyc.corp.google.com ([100.101.212.71]) by smtp.gmail.com with ESMTPSA id m129sm2577019ywd.66.2017.12.07.09.43.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Dec 2017 09:43:40 -0800 (PST) From: Neal Cardwell To: David Miller Cc: netdev@vger.kernel.org, Neal Cardwell Subject: [PATCH net 1/3] tcp_bbr: record "full bw reached" decision in new full_bw_reached bit Date: Thu, 7 Dec 2017 12:43:30 -0500 Message-Id: <20171207174332.17689-2-ncardwell@google.com> X-Mailer: git-send-email 2.15.1.424.g9478a66081-goog In-Reply-To: <20171207174332.17689-1-ncardwell@google.com> References: <20171207174332.17689-1-ncardwell@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This commit records the "full bw reached" decision in a new full_bw_reached bit. This is a pure refactor that does not change the current behavior, but enables subsequent fixes and improvements. In particular, this enables simple and clean fixes because the full_bw and full_bw_cnt can be unconditionally zeroed without worrying about forgetting that we estimated we filled the pipe in Startup. And it enables future improvements because multiple code paths can be used for estimating that we filled the pipe in Startup; any new code paths only need to set this bit when they think the pipe is full. Note that this fix intentionally reduces the width of the full_bw_cnt counter, since we have never used the most significant bit. Signed-off-by: Neal Cardwell Reviewed-by: Yuchung Cheng Acked-by: Soheil Hassas Yeganeh --- net/ipv4/tcp_bbr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c index 69ee877574d0..3089c956b9f9 100644 --- a/net/ipv4/tcp_bbr.c +++ b/net/ipv4/tcp_bbr.c @@ -110,7 +110,8 @@ struct bbr { u32 lt_last_lost; /* LT intvl start: tp->lost */ u32 pacing_gain:10, /* current gain for setting pacing rate */ cwnd_gain:10, /* current gain for setting cwnd */ - full_bw_cnt:3, /* number of rounds without large bw gains */ + full_bw_reached:1, /* reached full bw in Startup? */ + full_bw_cnt:2, /* number of rounds without large bw gains */ cycle_idx:3, /* current index in pacing_gain cycle array */ has_seen_rtt:1, /* have we seen an RTT sample yet? */ unused_b:5; @@ -180,7 +181,7 @@ static bool bbr_full_bw_reached(const struct sock *sk) { const struct bbr *bbr = inet_csk_ca(sk); - return bbr->full_bw_cnt >= bbr_full_bw_cnt; + return bbr->full_bw_reached; } /* Return the windowed max recent bandwidth sample, in pkts/uS << BW_SCALE. */ @@ -717,6 +718,7 @@ static void bbr_check_full_bw_reached(struct sock *sk, return; } ++bbr->full_bw_cnt; + bbr->full_bw_reached = bbr->full_bw_cnt >= bbr_full_bw_cnt; } /* If pipe is probably full, drain the queue and then enter steady-state. */ @@ -850,6 +852,7 @@ static void bbr_init(struct sock *sk) bbr->restore_cwnd = 0; bbr->round_start = 0; bbr->idle_restart = 0; + bbr->full_bw_reached = 0; bbr->full_bw = 0; bbr->full_bw_cnt = 0; bbr->cycle_mstamp = 0; From patchwork Thu Dec 7 17:43:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 845719 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="bwtmlUdM"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yt2sK1hTDz9s81 for ; Fri, 8 Dec 2017 04:43:49 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753331AbdLGRns (ORCPT ); Thu, 7 Dec 2017 12:43:48 -0500 Received: from mail-yb0-f194.google.com ([209.85.213.194]:45919 "EHLO mail-yb0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752573AbdLGRnp (ORCPT ); Thu, 7 Dec 2017 12:43:45 -0500 Received: by mail-yb0-f194.google.com with SMTP id 184so3273303ybw.12 for ; Thu, 07 Dec 2017 09:43:45 -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; bh=a91zpLd3o7FYrFH9+1NmiCwVlncWypSv3aY3RxBND74=; b=bwtmlUdMmEaXDNvpYqs1xPucdVpIIBMLiIomeKUF8NQA/NP3BkrV61o8htVQb2IBsr kWlEyJ+te4ceAGwCJmdkVXOKqeKy0lI0Jp9+NjDwxON4K8F5nWBUOaNgbNFmY41F2uS+ g8HV+M97VRMQG5+7E48VcsTUsbXSA0TJvVv+UzyBLExt/kHU7RG8PhYqV2a494vlYja3 +mo+ZG+uLteKXomQ5ukgnaQOfDmWKMJIev4SEcFB7I0q2c3cnBT/GSdZNaPV4zJLilE9 IY1h55Uy9SM6iVnQshBsey1fxw8fcwlfbjUW67IXLWjUQ5BVkzV8I3aw14hgqOYWByFE 8TRg== 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; bh=a91zpLd3o7FYrFH9+1NmiCwVlncWypSv3aY3RxBND74=; b=lhyhxP2nwHDXTwKSfsro1CSKVAR8dBNpbUje3dAkYdORZQCANhqCpiUnEU7MP5KGyA fxhXP9nvLxpMxqkPoiezMtGZsl+CIn2dhvtgJ9uu2lqkJtVIfTiGVIRffrSDGXrXy7tO Y+7jkj+us5gJYt+yn5qqvh8ZEH3uKHyRhF6BodZZ7C6jS63iH17C47euhEpjfw7bUZ0s 9qPEKAlJS6OgLO2kFESclztnntNdfFJpWilQASksC/Pt4Ri/O6kZQ6ZgzzSTQ9B/l8z1 q7hjXedagXYCQc+uyYSbFCJYjkF+GVN2Alf7mXobKuov35oAj9Eo3HxMYlstMve4oQZN bjIA== X-Gm-Message-State: AKGB3mJkVci4kCclMuFBZsE18HpL3ORNkGRhYiGTkAxucq2VeskybR8g 0phtSgpFadHH/+fiBHU+98mPkg/+WuA= X-Google-Smtp-Source: AGs4zMZuIoIuOTBA/zG9v9lbwOBmIy7rqVsjaTpiVIQyfnyBDmtfxfkIj6dx4vMc32ULrHDjyKmtrQ== X-Received: by 10.37.92.194 with SMTP id q185mr8532237ybb.257.1512668624850; Thu, 07 Dec 2017 09:43:44 -0800 (PST) Received: from joy.nyc.corp.google.com ([100.101.212.71]) by smtp.gmail.com with ESMTPSA id m129sm2577019ywd.66.2017.12.07.09.43.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Dec 2017 09:43:43 -0800 (PST) From: Neal Cardwell To: David Miller Cc: netdev@vger.kernel.org, Neal Cardwell Subject: [PATCH net 2/3] tcp_bbr: reset full pipe detection on loss recovery undo Date: Thu, 7 Dec 2017 12:43:31 -0500 Message-Id: <20171207174332.17689-3-ncardwell@google.com> X-Mailer: git-send-email 2.15.1.424.g9478a66081-goog In-Reply-To: <20171207174332.17689-1-ncardwell@google.com> References: <20171207174332.17689-1-ncardwell@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fix BBR so that upon notification of a loss recovery undo BBR resets the full pipe detection (STARTUP exit) state machine. Under high reordering, reordering events can be interpreted as loss. If the reordering and spurious loss estimates are high enough, this could previously cause BBR to spuriously estimate that the pipe is full. Since spurious loss recovery means that our overall sending will have slowed down spuriously, this commit gives a flow more time to probe robustly for bandwidth and decide the pipe is really full. Signed-off-by: Neal Cardwell Reviewed-by: Yuchung Cheng Acked-by: Soheil Hassas Yeganeh --- net/ipv4/tcp_bbr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c index 3089c956b9f9..ab3ff14ea7f7 100644 --- a/net/ipv4/tcp_bbr.c +++ b/net/ipv4/tcp_bbr.c @@ -874,6 +874,10 @@ static u32 bbr_sndbuf_expand(struct sock *sk) */ static u32 bbr_undo_cwnd(struct sock *sk) { + struct bbr *bbr = inet_csk_ca(sk); + + bbr->full_bw = 0; /* spurious slow-down; reset full pipe detection */ + bbr->full_bw_cnt = 0; return tcp_sk(sk)->snd_cwnd; } From patchwork Thu Dec 7 17:43:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 845720 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="N5RVLgsh"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yt2sR1YxHz9ryT for ; Fri, 8 Dec 2017 04:43:55 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753345AbdLGRnx (ORCPT ); Thu, 7 Dec 2017 12:43:53 -0500 Received: from mail-yb0-f193.google.com ([209.85.213.193]:42696 "EHLO mail-yb0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753302AbdLGRnu (ORCPT ); Thu, 7 Dec 2017 12:43:50 -0500 Received: by mail-yb0-f193.google.com with SMTP id t127so3280880ybf.9 for ; Thu, 07 Dec 2017 09:43:50 -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; bh=SRBPwudrdtVR0Xd+cbD2JrDjuJRkrEubFkQueL1DeMk=; b=N5RVLgshCPiTP2m48+wpxTV6hPMO5jX+6IirguCZkwYVyS77lz5M0nAg+mfL6JJMRr idIuVW0Bs0+zle5qzX1s0dPILeedM2gOSyCE7tIqDRxGMI4C8khU5oCRF5qKEMzWx0zb v12J1gi2WCca5RvOS2qlgyuW6ZoZBvXoqwA+Tyo10pa0iRRcOUr+p0258qbpG5/TAAnK f/oKioWbE0264kPtwvrhsyWTOR+w82LcfYm8keWIJ3TjBYJ9/xk7IiVVjBglm2oJ9ll5 KG6TvN9vu4Cq5nnNihN8Utu+IFckVV/Ds/Yg/1VKPkmK9EIMNi4dFv2E35PSEnBI4thr TEnA== 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; bh=SRBPwudrdtVR0Xd+cbD2JrDjuJRkrEubFkQueL1DeMk=; b=a3d06WE8kSMM1qnIOByHyNiRVrJ/zhy0FJpv1waZFhIb+w3ZnK+fUVii5OGCZXjwIC BC+hjMoNVOw6MSav8H3cRxyZE1nVA1XkeIRHUJNuRMM2VxMscZTHIssHtBGCex9kVQRl NiiSy/GeMJOMubdHDgcwMX7ul3sXVF2jmtEXQ1K23JwwECG0seuNsB7oM2UjMaUCnqde zii0tjZcONES1gbJ8Yb3Y2zKf0/qulQCt6aX/I8FkvbEaCWq6a9qV+XsOXjQ91boyyvO nmqUl8M2UwKQQ8L7qL0h85po5e9cOJWRTex/Yr1xAy46rlpU57WVty6PvBjSrr6v7sTj ev8g== X-Gm-Message-State: AKGB3mK8yEPhvKmlHuO5XIs7XJpawok3g51eL2gIdKjTooRURDRQ1Y1E 7NJta432elFU5k5JgX1sS39UIw== X-Google-Smtp-Source: AGs4zMZsbTNTwREn7z9xe7lTdd8WN6JtpxFZJoeMEZNSuCiPayKCYkwD9Ioz86ihz2ky8X2pq1i5dA== X-Received: by 10.37.104.70 with SMTP id d67mr320885ybc.470.1512668629751; Thu, 07 Dec 2017 09:43:49 -0800 (PST) Received: from joy.nyc.corp.google.com ([100.101.212.71]) by smtp.gmail.com with ESMTPSA id m129sm2577019ywd.66.2017.12.07.09.43.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Dec 2017 09:43:48 -0800 (PST) From: Neal Cardwell To: David Miller Cc: netdev@vger.kernel.org, Neal Cardwell Subject: [PATCH net 3/3] tcp_bbr: reset long-term bandwidth sampling on loss recovery undo Date: Thu, 7 Dec 2017 12:43:32 -0500 Message-Id: <20171207174332.17689-4-ncardwell@google.com> X-Mailer: git-send-email 2.15.1.424.g9478a66081-goog In-Reply-To: <20171207174332.17689-1-ncardwell@google.com> References: <20171207174332.17689-1-ncardwell@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fix BBR so that upon notification of a loss recovery undo BBR resets long-term bandwidth sampling. Under high reordering, reordering events can be interpreted as loss. If the reordering and spurious loss estimates are high enough, this can cause BBR to spuriously estimate that we are seeing loss rates high enough to trigger long-term bandwidth estimation. To avoid that problem, this commit resets long-term bandwidth sampling on loss recovery undo events. Signed-off-by: Neal Cardwell Reviewed-by: Yuchung Cheng Acked-by: Soheil Hassas Yeganeh --- net/ipv4/tcp_bbr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c index ab3ff14ea7f7..8322f26e770e 100644 --- a/net/ipv4/tcp_bbr.c +++ b/net/ipv4/tcp_bbr.c @@ -878,6 +878,7 @@ static u32 bbr_undo_cwnd(struct sock *sk) bbr->full_bw = 0; /* spurious slow-down; reset full pipe detection */ bbr->full_bw_cnt = 0; + bbr_reset_lt_bw_sampling(sk); return tcp_sk(sk)->snd_cwnd; }