From patchwork Wed Aug 22 21:43:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kevin(Yudong) Yang" X-Patchwork-Id: 961079 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@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; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="gCLj4J0q"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41wgyp4MVYz9s4V for ; Thu, 23 Aug 2018 07:43:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727995AbeHWBKE (ORCPT ); Wed, 22 Aug 2018 21:10:04 -0400 Received: from mail-qt0-f202.google.com ([209.85.216.202]:44260 "EHLO mail-qt0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727007AbeHWBKD (ORCPT ); Wed, 22 Aug 2018 21:10:03 -0400 Received: by mail-qt0-f202.google.com with SMTP id o18-v6so2808312qtm.11 for ; Wed, 22 Aug 2018 14:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=xEKGK8smTai55lgS05d70Io0+bloR6xUMOvSlNt6UCo=; b=gCLj4J0qfBptj9DcETZKtIvvpGU6nZIlajOxA54XaKya4jdgqLSnpEC237ekISMz8T pzlEGN/kMZg52huj9hy99881o8caWJed4TH+ojVDb1hc8JXWgJMgyhb0fL4uW+VNQnZf Dh6aC8xXnNV8H+gp0ndowaZpTMcxAlpk9bxgYWQyLpkfyuwzbJxzh6osEJD13MZ1scFW XM0NjQUeDXalEPS/IVX67Obvq4/sfV0tbp67JKRUwpmqxmbrdV9HKsWFh8hECNbtuTfs 4kdXjmhyKngIe1nCzuStSyRljHWYGs7iI+RCWVQcKqWplR2Li3d1pXb77KCffov2sz+m DKJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xEKGK8smTai55lgS05d70Io0+bloR6xUMOvSlNt6UCo=; b=nentzU0nro6zL2ZQDy4lyjI/iETXL8kJYZitHOAUxI20q2gf+EKepsXC0+B88HWHr/ 7IGqWwMlMUpZIRU5s2GKehIt8nX5EwMPg293BVPDQvnBLrtI7nt6ENK7Ak/MoHj5Fl6k WwFYafF4eyKM4YRMnwxmbX3hbJ/uGTkkdOayG4w5Obp1eIIuUvJBSXyDPKsVwTpSbLn8 kyFmp9FHEN+TKPW/Kni80qChT7AV33v7DcDwrOxMMGdu6Rm2m53gRVcU+1rUdgfGYoNe 1/r2s7ccIziMKHoyO5V8ZcPOb+g5lDQ0IFBapnHQfe2bRF2+65wvOQ4Uu8LBC4ahiytc 3sLA== X-Gm-Message-State: APzg51ASada6aPfc2qIgqYdg5Sccizh6xRsfjqLJtzy8rsijPfzaYU5s Es7U0xQKt4utmrIILb/gXZowP3k= X-Google-Smtp-Source: ANB0VdZmrHEZpKhtO3KTtx3ftAxCAU0P23QJEx+NXej98yPo2CFhTdLb8WC6IoavhFab2EhjfJzHV4s= X-Received: by 2002:a0c:bd26:: with SMTP id m38-v6mr8949671qvg.53.1534974206675; Wed, 22 Aug 2018 14:43:26 -0700 (PDT) Date: Wed, 22 Aug 2018 17:43:14 -0400 In-Reply-To: <20180822214316.174161-1-yyd@google.com> Message-Id: <20180822214316.174161-2-yyd@google.com> Mime-Version: 1.0 References: <20180822214316.174161-1-yyd@google.com> X-Mailer: git-send-email 2.18.0.1017.ga543ac7ca45-goog Subject: [PATCH net 1/3] tcp_bbr: add bbr_check_probe_rtt_done() helper From: Kevin Yang To: David Miller Cc: netdev@vger.kernel.org, Kevin Yang , Neal Cardwell , Yuchung Cheng Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch add a helper function bbr_check_probe_rtt_done() to 1. check the condition to see if bbr should exit probe_rtt mode; 2. process the logic of exiting probe_rtt mode. Fixes: 0f8782ea1497 ("tcp_bbr: add BBR congestion control") Signed-off-by: Kevin Yang Signed-off-by: Neal Cardwell Signed-off-by: Yuchung Cheng Reviewed-by: Soheil Hassas Yeganeh --- net/ipv4/tcp_bbr.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c index 13d34427ca3dd..fd7bccf36a263 100644 --- a/net/ipv4/tcp_bbr.c +++ b/net/ipv4/tcp_bbr.c @@ -95,11 +95,10 @@ struct bbr { u32 mode:3, /* current bbr_mode in state machine */ prev_ca_state:3, /* CA state on previous ACK */ packet_conservation:1, /* use packet conservation? */ - restore_cwnd:1, /* decided to revert cwnd to old value */ round_start:1, /* start of packet-timed tx->ack round? */ idle_restart:1, /* restarting after idle? */ probe_rtt_round_done:1, /* a BBR_PROBE_RTT round at 4 pkts? */ - unused:12, + unused:13, lt_is_sampling:1, /* taking long-term ("LT") samples now? */ lt_rtt_cnt:7, /* round trips in long-term interval */ lt_use_bw:1; /* use lt_bw as our bw estimate? */ @@ -396,17 +395,11 @@ static bool bbr_set_cwnd_to_recover_or_restore( cwnd = tcp_packets_in_flight(tp) + acked; } else if (prev_state >= TCP_CA_Recovery && state < TCP_CA_Recovery) { /* Exiting loss recovery; restore cwnd saved before recovery. */ - bbr->restore_cwnd = 1; + cwnd = max(cwnd, bbr->prior_cwnd); bbr->packet_conservation = 0; } bbr->prev_ca_state = state; - if (bbr->restore_cwnd) { - /* Restore cwnd after exiting loss recovery or PROBE_RTT. */ - cwnd = max(cwnd, bbr->prior_cwnd); - bbr->restore_cwnd = 0; - } - if (bbr->packet_conservation) { *new_cwnd = max(cwnd, tcp_packets_in_flight(tp) + acked); return true; /* yes, using packet conservation */ @@ -748,6 +741,20 @@ static void bbr_check_drain(struct sock *sk, const struct rate_sample *rs) bbr_reset_probe_bw_mode(sk); /* we estimate queue is drained */ } +static void bbr_check_probe_rtt_done(struct sock *sk) +{ + struct tcp_sock *tp = tcp_sk(sk); + struct bbr *bbr = inet_csk_ca(sk); + + if (!(bbr->probe_rtt_done_stamp && + after(tcp_jiffies32, bbr->probe_rtt_done_stamp))) + return; + + bbr->min_rtt_stamp = tcp_jiffies32; /* wait a while until PROBE_RTT */ + tp->snd_cwnd = max(tp->snd_cwnd, bbr->prior_cwnd); + bbr_reset_mode(sk); +} + /* The goal of PROBE_RTT mode is to have BBR flows cooperatively and * periodically drain the bottleneck queue, to converge to measure the true * min_rtt (unloaded propagation delay). This allows the flows to keep queues @@ -806,12 +813,8 @@ static void bbr_update_min_rtt(struct sock *sk, const struct rate_sample *rs) } else if (bbr->probe_rtt_done_stamp) { if (bbr->round_start) bbr->probe_rtt_round_done = 1; - if (bbr->probe_rtt_round_done && - after(tcp_jiffies32, bbr->probe_rtt_done_stamp)) { - bbr->min_rtt_stamp = tcp_jiffies32; - bbr->restore_cwnd = 1; /* snap to prior_cwnd */ - bbr_reset_mode(sk); - } + if (bbr->probe_rtt_round_done) + bbr_check_probe_rtt_done(sk); } } /* Restart after idle ends only once we process a new S/ACK for data */ @@ -862,7 +865,6 @@ static void bbr_init(struct sock *sk) bbr->has_seen_rtt = 0; bbr_init_pacing_rate_from_rtt(sk); - bbr->restore_cwnd = 0; bbr->round_start = 0; bbr->idle_restart = 0; bbr->full_bw_reached = 0; From patchwork Wed Aug 22 21:43:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kevin(Yudong) Yang" X-Patchwork-Id: 961080 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@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; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="pcOoiwBl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41wgyq2X2kz9s47 for ; Thu, 23 Aug 2018 07:43:31 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728062AbeHWBKE (ORCPT ); Wed, 22 Aug 2018 21:10:04 -0400 Received: from mail-qt0-f202.google.com ([209.85.216.202]:35036 "EHLO mail-qt0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727842AbeHWBKE (ORCPT ); Wed, 22 Aug 2018 21:10:04 -0400 Received: by mail-qt0-f202.google.com with SMTP id l7-v6so2868138qte.2 for ; Wed, 22 Aug 2018 14:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=aiVNeuZGbMZAgsbzErHsoh2ZO+j6fLdzP0B7x0RMdis=; b=pcOoiwBl8i0ac/1eqBBVC803G4uJ94SafHVWJP2xB+XCf2pFtThzIJil9T22atOuuR xwiEUW/xMcPdI/EGalQHH7eudQbUK6F996toypiTyY5g4OKmzzJ1J1FcgP9G6BBCd/ff kfDC3QqOKUAvLZdo6G1qBbLSKD2ABREreKqCW+aMHNh6EU96N6s6Bdgusv/kORYBDX+A MjobtWKjks2QwM/TVnyXsqsBLVQj7tcYMwiLUec7xLNwprvOZfbiAYzC7JeQk4GpmA77 6VCp4nylICfMw36FN16XNtAW/jLtAHlkvFm3bwgrKcdj6ETqE+lIuI0cd9Z3mv9FZq8v dJ+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=aiVNeuZGbMZAgsbzErHsoh2ZO+j6fLdzP0B7x0RMdis=; b=axmKpQtc0sbnWtqVcUiVKjTGzB/VXh+EHRolbdUpTgjJW+hmPohIvn4Sa0btqtoG7z /r04nWvFrSIag9gzDjRPX5PWXcTFvLObcqjRc/bjwsT9YRNHuttF1EAyti9FTLot3Hyj qyoGcxxtfZlH8k2mdBlO/AT7BJ2GRO9e28d+9dD5UI19SxJ36RK5RaA2OMs+8S2KzG3K c1+NGY4Xm80V3ql7PLbT5qSZaFCbNZY735Kn+Mhw+Wct43z7/GjvfXOY7YLU9J722o5u aQ9GKHjcA2rK6Rntudkxy2XOUUQTkr73mBwGErFpbhBpeqmJsSgnBA+LDLdgWdLE2jY1 kGhA== X-Gm-Message-State: AOUpUlFHjk04cD384fnMtkaF8nuiHk9ZxZTmbO+qKnn0ssKKqz+bDpdw dmQTEGLDm4ftF+wEmNa8qH2GEA4= X-Google-Smtp-Source: AA+uWPwIGI6LuLtehqRw2s3MbSDc7utO1XKZh9hxdpej9lF2NK91c6Xuyis2lPgm3a3nUox0iYLDfas= X-Received: by 2002:a0c:f848:: with SMTP id g8-v6mr30478837qvo.11.1534974207487; Wed, 22 Aug 2018 14:43:27 -0700 (PDT) Date: Wed, 22 Aug 2018 17:43:15 -0400 In-Reply-To: <20180822214316.174161-1-yyd@google.com> Message-Id: <20180822214316.174161-3-yyd@google.com> Mime-Version: 1.0 References: <20180822214316.174161-1-yyd@google.com> X-Mailer: git-send-email 2.18.0.1017.ga543ac7ca45-goog Subject: [PATCH net 2/3] tcp_bbr: in restart from idle, see if we should exit PROBE_RTT From: Kevin Yang To: David Miller Cc: netdev@vger.kernel.org, Kevin Yang , Neal Cardwell Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch fix the case where BBR does not exit PROBE_RTT mode when it restarts from idle. When BBR restarts from idle and if BBR is in PROBE_RTT mode, BBR should check if it's time to exit PROBE_RTT. If yes, then BBR should exit PROBE_RTT mode and restore the cwnd to its full value. Fixes: 0f8782ea1497 ("tcp_bbr: add BBR congestion control") Signed-off-by: Kevin Yang Signed-off-by: Neal Cardwell Reviewed-by: Yuchung Cheng Reviewed-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 fd7bccf36a263..1d4bdd3b5e4d0 100644 --- a/net/ipv4/tcp_bbr.c +++ b/net/ipv4/tcp_bbr.c @@ -174,6 +174,8 @@ static const u32 bbr_lt_bw_diff = 4000 / 8; /* If we estimate we're policed, use lt_bw for this many round trips: */ static const u32 bbr_lt_bw_max_rtts = 48; +static void bbr_check_probe_rtt_done(struct sock *sk); + /* Do we estimate that STARTUP filled the pipe? */ static bool bbr_full_bw_reached(const struct sock *sk) { @@ -308,6 +310,8 @@ static void bbr_cwnd_event(struct sock *sk, enum tcp_ca_event event) */ if (bbr->mode == BBR_PROBE_BW) bbr_set_pacing_rate(sk, bbr_bw(sk), BBR_UNIT); + else if (bbr->mode == BBR_PROBE_RTT) + bbr_check_probe_rtt_done(sk); } } From patchwork Wed Aug 22 21:43:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kevin(Yudong) Yang" X-Patchwork-Id: 961081 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@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; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="IofoLyK0"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41wgyr0LFhz9s4V for ; Thu, 23 Aug 2018 07:43:32 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728106AbeHWBKF (ORCPT ); Wed, 22 Aug 2018 21:10:05 -0400 Received: from mail-qt0-f201.google.com ([209.85.216.201]:51478 "EHLO mail-qt0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727007AbeHWBKE (ORCPT ); Wed, 22 Aug 2018 21:10:04 -0400 Received: by mail-qt0-f201.google.com with SMTP id u13-v6so2791765qtb.18 for ; Wed, 22 Aug 2018 14:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=nWnKy8YRBVBBKYhwn9ESauQOjvPFjjHabimGAYJv/To=; b=IofoLyK0rq0RZmtFi7Jmz45CxzpgF3eG8WQuVBJuXjSCKT0oXEP1tiaz7J7D9XAhNV EEV5NFXhQ8PR0pm8qsbgNXkbdy9a31vkid0jiUD5h6jpb5vaHjI6F0fgDvTmh9gnkeFY +clO0iBdzPztAH1SurGBzZwxX3KCrz3BgwgNMDXkyKezdz/KIyLlv8485ECmbA6+8TeH uOWbnJN3Cz6ybSinNStom0qVMYuGkECzixkg6b611xOXWjkl0OFNIkaCx8rb8CwRBPy/ QBCE/eStkAKnrF8KNT1U5k1JsHkBet1VNuUn6mB869rQbhWb5lyz5Bfufm5OEkuSWBWW MIwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=nWnKy8YRBVBBKYhwn9ESauQOjvPFjjHabimGAYJv/To=; b=FYYFbDfib3JcRqa66eETKaC09PYyOoudQXh2BGwH+ggoBrfs/wTK1ZTJLT8yyYq3Iw KxDE71Bvh04vcH5J5beSPiN7z4bQGCMTEb2LgyTVenfxZJSIfOPwHL3IZKKUg57dzsy9 l1oKs0rZD3Ri2NlS+y1lbfqib4+plP1Pt/jmv6BXkH0eboXdFWe+E1WWMhxbJYuJEPXj p0zcWE1xmhiBkSLOFKcEHO/X/RhmZkz9Ntvcs0l9NYnCiu5CEEzkP0ZoNKZ2PPgGAx0y MY8G2weFNv05Bsk4yr4WDCTSCHkO0TtaOL41/iroVgPF39mtKEdVtsSyF4MxkfynQUak rtMg== X-Gm-Message-State: AOUpUlGLg7hpGneE+movwqIGaK+yREZwrPMfZs1hYWz10cSIoi+s1004 pp+UzTktoT8vsKAdAW3yBtUKJTg= X-Google-Smtp-Source: AA+uWPySBwpseP97CQeQ7AsAnNZi1b7VUI+A+urfLzgT3MLpVBtHQ5O+x/JVs7MmweLTtvOHm0DXyw4= X-Received: by 2002:a37:1a13:: with SMTP id a19-v6mr15110285qka.4.1534974208292; Wed, 22 Aug 2018 14:43:28 -0700 (PDT) Date: Wed, 22 Aug 2018 17:43:16 -0400 In-Reply-To: <20180822214316.174161-1-yyd@google.com> Message-Id: <20180822214316.174161-4-yyd@google.com> Mime-Version: 1.0 References: <20180822214316.174161-1-yyd@google.com> X-Mailer: git-send-email 2.18.0.1017.ga543ac7ca45-goog Subject: [PATCH net 3/3] tcp_bbr: apply PROBE_RTT cwnd cap even if acked==0 From: Kevin Yang To: David Miller Cc: netdev@vger.kernel.org, Kevin Yang , Neal Cardwell Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This commit fixes a corner case where TCP BBR would enter PROBE_RTT mode but not reduce its cwnd. If a TCP receiver ACKed less than one full segment, the number of delivered/acked packets was 0, so that bbr_set_cwnd() would short-circuit and exit early, without cutting cwnd to the value we want for PROBE_RTT. The fix is to instead make sure that even when 0 full packets are ACKed, we do apply all the appropriate caps, including the cap that applies in PROBE_RTT mode. Fixes: 0f8782ea1497 ("tcp_bbr: add BBR congestion control") Signed-off-by: Kevin Yang Signed-off-by: Neal Cardwell Reviewed-by: Yuchung Cheng Reviewed-by: Soheil Hassas Yeganeh --- net/ipv4/tcp_bbr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c index 1d4bdd3b5e4d0..02ff2dde96094 100644 --- a/net/ipv4/tcp_bbr.c +++ b/net/ipv4/tcp_bbr.c @@ -420,10 +420,10 @@ static void bbr_set_cwnd(struct sock *sk, const struct rate_sample *rs, { struct tcp_sock *tp = tcp_sk(sk); struct bbr *bbr = inet_csk_ca(sk); - u32 cwnd = 0, target_cwnd = 0; + u32 cwnd = tp->snd_cwnd, target_cwnd = 0; if (!acked) - return; + goto done; /* no packet fully ACKed; just apply caps */ if (bbr_set_cwnd_to_recover_or_restore(sk, rs, acked, &cwnd)) goto done;