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;