From patchwork Fri Jul 14 21:49:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 788817 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3x8RDk1brdz9s7F for ; Sat, 15 Jul 2017 07:49:58 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="S0ko85uv"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751200AbdGNVtz (ORCPT ); Fri, 14 Jul 2017 17:49:55 -0400 Received: from mail-qt0-f181.google.com ([209.85.216.181]:32958 "EHLO mail-qt0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751178AbdGNVtu (ORCPT ); Fri, 14 Jul 2017 17:49:50 -0400 Received: by mail-qt0-f181.google.com with SMTP id r30so72290664qtc.0 for ; Fri, 14 Jul 2017 14:49:50 -0700 (PDT) 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=PJoTIICoy+5hrS5C8ic5vmqcip+nHJLFJl6WfSsIQ0I=; b=S0ko85uvtTNlYLYfv1PQ1lTugJYCj8oMAIiyW7RzHYNI1o6I/mP3ZvDytkc+AweNnN 4idpFFOshkaZJ2pANlt8JQXnObQKPL+o326OLEmwSmDX8nrLwhU3QenOSY6ZmkFnzfhw 7ztv6qF3M6xQVIcMjJdE08s9EfETPpFm/zlx5+sGhGeT0FLRNqu0zfkUbv0tXuT2hwxO IKpT/NYd8Oyl1uqzHCYxGdU8yD/+F3XugyxcN5YSDWPQi50BOUP8kHEAjfMR9oWKPpF3 eRjcONK7IwD+9IHDBQJuIBwLa58CalmOnKjb8OrcM0WNvse3o8CaN3Z1vKny0lcxilhR oFTg== 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=PJoTIICoy+5hrS5C8ic5vmqcip+nHJLFJl6WfSsIQ0I=; b=jU3VgxgAs7dSEaB3V7b4z4S/hRsn5oALtg4zC9NDhBFN2Sb00Xtt2ARrM3ngum1wNS 3abtUT1RgqLOGOw04zfwVSkQV7yCMzf+g8sUxbfTHOv97DQDz0kpTzsZMHQOPH//skEK 2faH0VOxnStHn7s/vLTwYaC2m4C/4zFTcV5ccDyFbp71+x/xvqpnDaWKhgek+EE2MaVC I+ck88tiwYFhBjCPh/TR201HKvvFw/ZTsmR64Knj1CdO0Q7bJA8RDWUh6mWfcryvfxh7 rzkNM+mcaHYU/Yi90ThnF+dAmO2I1q6AdBeNAhdPGVPdbF1SgifQZRh62Ggld22J+/WO 03Mw== X-Gm-Message-State: AIVw112K81KRMEjJvVBY6sghsHyX7/qMlCbyg0km+iNMwoW8r5Fd+diN txe/xTmpsS7nnp7e X-Received: by 10.237.59.243 with SMTP id s48mr14994446qte.192.1500068989655; Fri, 14 Jul 2017 14:49:49 -0700 (PDT) Received: from joy.nyc.corp.google.com ([100.101.212.71]) by smtp.gmail.com with ESMTPSA id f124sm6940655qkj.57.2017.07.14.14.49.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Jul 2017 14:49:48 -0700 (PDT) From: Neal Cardwell To: David Miller Cc: netdev@vger.kernel.org, Neal Cardwell , Yuchung Cheng , Soheil Hassas Yeganeh Subject: [PATCH net 5/5] tcp_bbr: init pacing rate on first RTT sample Date: Fri, 14 Jul 2017 17:49:25 -0400 Message-Id: <20170714214925.30720-5-ncardwell@google.com> X-Mailer: git-send-email 2.13.2.932.g7449e964c-goog In-Reply-To: <20170714214925.30720-1-ncardwell@google.com> References: <20170714214925.30720-1-ncardwell@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fixes the following behavior: for connections that had no RTT sample at the time of initializing congestion control, BBR was initializing the pacing rate to a high nominal rate (based an a guess of RTT=1ms, in case this is LAN traffic). Then BBR never adjusted the pacing rate downward upon obtaining an actual RTT sample, if the connection never filled the pipe (e.g. all sends were small app-limited writes()). This fix adjusts the pacing rate upon obtaining the first RTT sample. Fixes: 0f8782ea1497 ("tcp_bbr: add BBR congestion control") Signed-off-by: Neal Cardwell Signed-off-by: Yuchung Cheng Signed-off-by: Soheil Hassas Yeganeh --- net/ipv4/tcp_bbr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c index 42e0017f2ebc..69ee877574d0 100644 --- a/net/ipv4/tcp_bbr.c +++ b/net/ipv4/tcp_bbr.c @@ -112,7 +112,8 @@ struct bbr { cwnd_gain:10, /* current gain for setting cwnd */ full_bw_cnt:3, /* number of rounds without large bw gains */ cycle_idx:3, /* current index in pacing_gain cycle array */ - unused_b:6; + has_seen_rtt:1, /* have we seen an RTT sample yet? */ + unused_b:5; u32 prior_cwnd; /* prior cwnd upon entering loss recovery */ u32 full_bw; /* recent bw, to estimate if pipe is full */ }; @@ -225,11 +226,13 @@ static u32 bbr_bw_to_pacing_rate(struct sock *sk, u32 bw, int gain) static void bbr_init_pacing_rate_from_rtt(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); + struct bbr *bbr = inet_csk_ca(sk); u64 bw; u32 rtt_us; if (tp->srtt_us) { /* any RTT sample yet? */ rtt_us = max(tp->srtt_us >> 3, 1U); + bbr->has_seen_rtt = 1; } else { /* no RTT sample yet */ rtt_us = USEC_PER_MSEC; /* use nominal default RTT */ } @@ -247,8 +250,12 @@ static void bbr_init_pacing_rate_from_rtt(struct sock *sk) */ static void bbr_set_pacing_rate(struct sock *sk, u32 bw, int gain) { + struct tcp_sock *tp = tcp_sk(sk); + struct bbr *bbr = inet_csk_ca(sk); u32 rate = bbr_bw_to_pacing_rate(sk, bw, gain); + if (unlikely(!bbr->has_seen_rtt && tp->srtt_us)) + bbr_init_pacing_rate_from_rtt(sk); if (bbr_full_bw_reached(sk) || rate > sk->sk_pacing_rate) sk->sk_pacing_rate = rate; } @@ -837,6 +844,7 @@ static void bbr_init(struct sock *sk) minmax_reset(&bbr->bw, bbr->rtt_cnt, 0); /* init max bw to 0 */ + bbr->has_seen_rtt = 0; bbr_init_pacing_rate_from_rtt(sk); bbr->restore_cwnd = 0;