From patchwork Sat Sep 17 17:35:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 671251 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 3sbzr22cnpz9s2Q for ; Sun, 18 Sep 2016 03:37:38 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=DRkPZ16r; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932338AbcIQRh3 (ORCPT ); Sat, 17 Sep 2016 13:37:29 -0400 Received: from mail-qt0-f181.google.com ([209.85.216.181]:35458 "EHLO mail-qt0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754105AbcIQRg2 (ORCPT ); Sat, 17 Sep 2016 13:36:28 -0400 Received: by mail-qt0-f181.google.com with SMTP id 93so56185162qtg.2 for ; Sat, 17 Sep 2016 10:36:27 -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=DRkPZ16roFnCoS6O34owKtEq+8ISTblfVhOUL2qDCQUbu2h46ZTTl5TJy2VDIKRHl+ u91s3QDIKXAUy29Z2Fec/C1EWGAPZN9J2BUnQNwIbdTB65vk7U8Gg/gnc35MFuTJfzN3 kKKQ6L3WAcgPWSW3DypeDWKpCC4GvaP1z6my2SjOqMo3l3Yq0kzlM+ieTJTGCxWQG8hO 4odS7YPrShDO5AjxQB32ELw+Q9+qcxrwaGKhLYRyZIiJdo3mb0ZFujRrMWnevGLncmpk P2vTK/LtqOyzy8A2cqLyUZ58axJByvoUkyIWEx5HczFuWmTuMbydScKqsV6Ie0EFvSLJ vYAA== 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=eCdsW73vpCqHURHFxMOkWbE2S2ukcvmY7KlM83bgyBsF+la0IUfEXnSOtdeMfmoz25 JRiRNBN+bApjQHuAz5B1WFBqqftGCPsO8of19891Wms1VjxuRJXW/4XkA8DGSFadS5oL L0nQySBWrfbOzGWwslcTXalLFzzhwannQrgWQJKTpgIGdWFdlXNCb42lkHn6gz02IUjK 74qAyZYS67prkrxX2fHdgbZh0/xih/cPflT9EWfEEwTetEW217UECqTvVEWOdAICMBQw d1wIBn2HjJp59AV2Nvf9uC5l/79fwwZTeCdUr28U0YjKzVQ8oYdwkbIoLfJ4rLSrxq0o z87A== X-Gm-Message-State: AE9vXwNOavbwk1u170Tu2814UebYwqNELnRJTZQHrTTBkOxp7SYhVJtu/fP0pVRmJTow3YvL X-Received: by 10.237.49.5 with SMTP id 5mr21249034qtg.136.1474133786887; Sat, 17 Sep 2016 10:36:26 -0700 (PDT) Received: from joy.nyc.corp.google.com ([100.101.230.104]) by smtp.gmail.com with ESMTPSA id t21sm8068625qkg.4.2016.09.17.10.36.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 17 Sep 2016 10:36:26 -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 v2 net-next 10/16] tcp: allow congestion control module to request TSO skb segment count Date: Sat, 17 Sep 2016 13:35:43 -0400 Message-Id: <1474133749-12895-11-git-send-email-ncardwell@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1474133749-12895-1-git-send-email-ncardwell@google.com> References: <1474133749-12895-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;