From patchwork Tue Sep 20 03:39:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 672078 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 3sdT6r0ksCz9sD6 for ; Tue, 20 Sep 2016 13:40:36 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=AwZUMwFi; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932345AbcITDkU (ORCPT ); Mon, 19 Sep 2016 23:40:20 -0400 Received: from mail-qk0-f173.google.com ([209.85.220.173]:34338 "EHLO mail-qk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754053AbcITDjo (ORCPT ); Mon, 19 Sep 2016 23:39:44 -0400 Received: by mail-qk0-f173.google.com with SMTP id n185so4364062qke.1 for ; Mon, 19 Sep 2016 20:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XYTo6Loya7cwgZTMrNh4fpmDscgJrGmghlBar6f4BLA=; b=AwZUMwFitjN/+6sp7juCpHaGNk5IIeWkkks8ThiQK7F2LQ2N+JbjLsKURfAx1e+JE1 DkP+gFYaCEP+X684jFVSIzXLQRcS2lJdfjkiIlAK4EAQPkzu7DVcq4kx2RjD434EbZcs H5VFGosHDaeBlJLIGHNKj92Au5M/8e2R0aI8taiwh1tWH54Hb3/jvDuS2o0ITqeb7l6i f8T+SCUekaP+LVLHG9AerTuqXuMAXY7HWOyo/QRDBQfro4UvImW/rTB/J/kq8uxM1ol1 F3btrAnTxjQdgSJu8PhrQMWHUxj60GRwkMZeK0brk7SRtTAc5NsX+0G/V5f8lZ1tWvVC qjYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XYTo6Loya7cwgZTMrNh4fpmDscgJrGmghlBar6f4BLA=; b=YzctMzdaMgQVSKxN8drcclqHUoan0JdaV3+UM+/NGwEVYVRXH5WUI/N1H/kGULEy1v qA5O9KMnuIB6UypIhDGNIcjoABjzGlrJKkfbu9a2VjQkiaZoGVh0U8WppkOXe4lz+7ZY hpZ6RPOcKc+8UEAutmxzH505S3jbStjHqxKZS8PTV+J1IvSNlnM5LiEZklREP4njR2zL nYy+8iUAz1WoFiq4OQ0NUu9+KJA2wV08s+70mHbprYfAn1j7FR5aJZOqBD4XgJs7O4QA 8DkORsIt50uXeWE/GGYrCqDHrmwwsnmG+b+jGumHI8aj2kZgnePIT0sQyn8JBSIatBHT nVNQ== X-Gm-Message-State: AE9vXwOMsRfapgLmWU1FH3IzHbJ7+hdLkvfKl9mf58Wbt4y5FzVAZvHbGPD/e5rt2OKV/ejt X-Received: by 10.55.98.22 with SMTP id w22mr32987048qkb.83.1474342783409; Mon, 19 Sep 2016 20:39:43 -0700 (PDT) Received: from joy.nyc.corp.google.com ([100.101.230.104]) by smtp.gmail.com with ESMTPSA id m4sm14901942qkf.29.2016.09.19.20.39.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Sep 2016 20:39:42 -0700 (PDT) From: Neal Cardwell To: David Miller Cc: netdev@vger.kernel.org, Neal Cardwell , Van Jacobson , Yuchung Cheng , Nandita Dukkipati , Eric Dumazet , Soheil Hassas Yeganeh Subject: [PATCH v4 net-next 10/16] tcp: allow congestion control module to request TSO skb segment count Date: Mon, 19 Sep 2016 23:39:17 -0400 Message-Id: <1474342763-16715-11-git-send-email-ncardwell@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1474342763-16715-1-git-send-email-ncardwell@google.com> References: <1474342763-16715-1-git-send-email-ncardwell@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add the tso_segs_goal() function in tcp_congestion_ops to allow the congestion control module to specify the number of segments that should be in a TSO skb sent by tcp_write_xmit() and tcp_xmit_retransmit_queue(). The congestion control module can either request a particular number of segments in TSO skb that we transmit, or return 0 if it doesn't care. This allows the upcoming BBR congestion control module to select small TSO skb sizes if the module detects that the bottleneck bandwidth is very low, or that the connection is policed to a low rate. Signed-off-by: Van Jacobson Signed-off-by: Neal Cardwell Signed-off-by: Yuchung Cheng Signed-off-by: Nandita Dukkipati Signed-off-by: Eric Dumazet Signed-off-by: Soheil Hassas Yeganeh --- include/net/tcp.h | 2 ++ net/ipv4/tcp_output.c | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index a69ed7f..f8f581f 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -913,6 +913,8 @@ struct tcp_congestion_ops { u32 (*undo_cwnd)(struct sock *sk); /* hook for packet ack accounting (optional) */ void (*pkts_acked)(struct sock *sk, const struct ack_sample *sample); + /* suggest number of segments for each skb to transmit (optional) */ + u32 (*tso_segs_goal)(struct sock *sk); /* get info for inet_diag (optional) */ size_t (*get_info)(struct sock *sk, u32 ext, int *attr, union tcp_cc_info *info); diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index e02c8eb..0137956 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1566,6 +1566,17 @@ static u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now) return min_t(u32, segs, sk->sk_gso_max_segs); } +/* Return the number of segments we want in the skb we are transmitting. + * See if congestion control module wants to decide; otherwise, autosize. + */ +static u32 tcp_tso_segs(struct sock *sk, unsigned int mss_now) +{ + const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops; + u32 tso_segs = ca_ops->tso_segs_goal ? ca_ops->tso_segs_goal(sk) : 0; + + return tso_segs ? : tcp_tso_autosize(sk, mss_now); +} + /* Returns the portion of skb which can be sent right away */ static unsigned int tcp_mss_split_point(const struct sock *sk, const struct sk_buff *skb, @@ -2061,7 +2072,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, } } - max_segs = tcp_tso_autosize(sk, mss_now); + max_segs = tcp_tso_segs(sk, mss_now); while ((skb = tcp_send_head(sk))) { unsigned int limit; @@ -2778,7 +2789,7 @@ void tcp_xmit_retransmit_queue(struct sock *sk) last_lost = tp->snd_una; } - max_segs = tcp_tso_autosize(sk, tcp_current_mss(sk)); + max_segs = tcp_tso_segs(sk, tcp_current_mss(sk)); tcp_for_write_queue_from(skb, sk) { __u8 sacked; int segs;