From patchwork Wed Aug 14 15:09:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinicius Peixoto X-Patchwork-Id: 1972456 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WkWrG4nzyz1yXl for ; Thu, 15 Aug 2024 01:09:34 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1seFcu-000601-3w; Wed, 14 Aug 2024 15:09:28 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1seFcs-0005ya-Qk for kernel-team@lists.ubuntu.com; Wed, 14 Aug 2024 15:09:26 +0000 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 933B13F162 for ; Wed, 14 Aug 2024 15:09:26 +0000 (UTC) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-201e318ac63so4896935ad.1 for ; Wed, 14 Aug 2024 08:09:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723648163; x=1724252963; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1YHBql8ah36a0m7bHKqpMIrWEAJ2bsa1hC3dqiKpNqc=; b=kxcLplovqp9LK7BvOGVQELo7p3DUWL+v9pP+rRk5+lhlJlXNjB0n6got/IoPphAvhO H4yy2KSvfHD3vdeRXy+ODLoEhn29+l4vtWh5GVn3Cgjdxb1hhuntVGUetkegJvjeLSx/ Vwf1LPqRtCWTirJsYLL2UvAUxqsiTICAj4wZx3h6cLi634dvhgsrK232WLZpx1zV6mS/ k6aimREbpkgNVFzpE4IG9IkFB3IPv/eaf/qSvP3wwlbWpC7ndSozApKzKv0eMIweP5XW Xtgz3ONli9cuglD4Sc2vr0ebamw3VagaTWQAhwHBcwf+ofNfVikEzSBcodt/z+WEk5t9 OH5Q== X-Gm-Message-State: AOJu0Yy6kHdcRzw82qe+F2Mfeb5wFBlMBn8cEICfsvXCLW9peJ2EU9sX egISkVtovzHeWplo7EVvfWhjxqK6+wOo40SQC5pDWKYXQPJlAAr8K/M+U/Lg/yxG4oX34b6RrR4 SLHVR+xQUHn8z1pyRZtpQZFHN42wAKGFWgIUy2K6x3Rzy+Xbll+tMMo9ki+178toxirqHrLNujp /ezZQAOa3bWA== X-Received: by 2002:a17:903:11c8:b0:1fb:247b:aa2a with SMTP id d9443c01a7336-201d64ece9dmr40888205ad.59.1723648163558; Wed, 14 Aug 2024 08:09:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqSaaPg/5VHfuOTJOqbJ11R6znJGObyEX9ex4U/AieB/VoQP7OdyjtEVIo2VaxLG644dS+kg== X-Received: by 2002:a17:903:11c8:b0:1fb:247b:aa2a with SMTP id d9443c01a7336-201d64ece9dmr40888035ad.59.1723648163227; Wed, 14 Aug 2024 08:09:23 -0700 (PDT) Received: from canonical.com ([2804:1b3:a700:3d2c:3248:f628:658d:3fd4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201cd14b374sm30816285ad.71.2024.08.14.08.09.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:09:22 -0700 (PDT) From: Vinicius Peixoto To: kernel-team@lists.ubuntu.com Subject: [SRU][noble:linux-gcp][PATCH v2 1/2] tcp: derive delack_max with tcp_rto_min helper Date: Wed, 14 Aug 2024 12:09:15 -0300 Message-ID: <20240814150916.476249-2-vinicius.peixoto@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240814150916.476249-1-vinicius.peixoto@canonical.com> References: <20240814150916.476249-1-vinicius.peixoto@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kevin Yang BugLink: https://bugs.launchpad.net/bugs/2076950 Rto_min now has multiple sources, ordered by preprecedence high to low: ip route option rto_min, icsk->icsk_rto_min. When derive delack_max from rto_min, we should not only use ip route option, but should use tcp_rto_min helper to get the correct rto_min. Signed-off-by: Kevin Yang Reviewed-by: Neal Cardwell Reviewed-by: Yuchung Cheng Reviewed-by: Eric Dumazet Reviewed-by: Tony Lu Reviewed-by: Jakub Kicinski Signed-off-by: David S. Miller (cherry-picked from commit 512bd0f9f926a05c724a9fd72bc4e14213845e01) Signed-off-by: Vinicius Peixoto --- net/ipv4/tcp_output.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 02caeb7bcf63..4ea34079acfe 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -4124,16 +4124,9 @@ EXPORT_SYMBOL(tcp_connect); u32 tcp_delack_max(const struct sock *sk) { - const struct dst_entry *dst = __sk_dst_get(sk); - u32 delack_max = inet_csk(sk)->icsk_delack_max; - - if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) { - u32 rto_min = dst_metric_rtt(dst, RTAX_RTO_MIN); - u32 delack_from_rto_min = max_t(int, 1, rto_min - 1); + u32 delack_from_rto_min = max(tcp_rto_min(sk), 2) - 1; - delack_max = min_t(u32, delack_max, delack_from_rto_min); - } - return delack_max; + return min(inet_csk(sk)->icsk_delack_max, delack_from_rto_min); } /* Send out a delayed ack, the caller does the policy checking From patchwork Wed Aug 14 15:09:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinicius Peixoto X-Patchwork-Id: 1972457 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WkWrL65Jjz1yXl for ; Thu, 15 Aug 2024 01:09:38 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1seFcx-000637-9O; Wed, 14 Aug 2024 15:09:31 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1seFcv-00061O-D1 for kernel-team@lists.ubuntu.com; Wed, 14 Aug 2024 15:09:29 +0000 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 31CCB3F162 for ; Wed, 14 Aug 2024 15:09:29 +0000 (UTC) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-1fd8a1a75e7so59186195ad.3 for ; Wed, 14 Aug 2024 08:09:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723648167; x=1724252967; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yggSkHNBcltbhlITbWg0ojd2bIG4T/wdHZGPfyf6E9E=; b=BJslnnFwXIWu0bu4yO/5qDT9IXP6gQtophVpXZjb81RDFJsbYxvJm6AOVSOuI2y4O4 XjHwgQDdri8X7cs9tor5kZ4iqwLjtn6HT8/4FhZtlyNM3qVS0U9N5oYsW0c1CECNO32X hb5K/YjnPrQCUwCDScLDfINIFzx4mRhNUxSUkQaF+d8UGWXJJC1fSgTxmU26MD3K/dBI t/utqVCzyVcGnerTSIjHGO1UIVg4xZSDq182JZx6fHvjV6HWt+qoBnWbAKH3h1XpHqnZ fvPV5jW5zg/F3e8FiU7rvQS92AWL1KcN7Pgu719G+VekM+OjPtJB38d+P9JqG+INIMHq FeeA== X-Gm-Message-State: AOJu0Yx6+shl5R7lL74mCt2SyfFL+ghIUaCwbCJIRi0awAQE0Rg9a7Z7 f9d2b45jF1K2Tp9xySYrQCHoK7X0ahkBoz4G9JB/xyK+eklMA6s//81GKaEizqMEBIGyAswNoYk JyUf/y+0jB2vugzJHQ5DXtQWlQv64y64ai/HqxPCrpNhleePuFD2LN+++IYEpbiitfpJLLlNO9P Z/ZEgJT1L+mw== X-Received: by 2002:a17:903:230c:b0:1f6:f0fe:6cc9 with SMTP id d9443c01a7336-201d6519913mr36838725ad.54.1723648166855; Wed, 14 Aug 2024 08:09:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3Yqto/Mi9wNXSV+sN7Wwi/zmQqiN5Bi0q09pKs0/wkj1kR/JTh/8jQZ8XzrKzdckRpiA48w== X-Received: by 2002:a17:903:230c:b0:1f6:f0fe:6cc9 with SMTP id d9443c01a7336-201d6519913mr36838425ad.54.1723648166498; Wed, 14 Aug 2024 08:09:26 -0700 (PDT) Received: from canonical.com ([2804:1b3:a700:3d2c:3248:f628:658d:3fd4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201cd1bcadbsm30752585ad.221.2024.08.14.08.09.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:09:25 -0700 (PDT) From: Vinicius Peixoto To: kernel-team@lists.ubuntu.com Subject: [SRU][noble:linux-gcp][PATCH v2 2/2] tcp: add sysctl_tcp_rto_min_us Date: Wed, 14 Aug 2024 12:09:16 -0300 Message-ID: <20240814150916.476249-3-vinicius.peixoto@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240814150916.476249-1-vinicius.peixoto@canonical.com> References: <20240814150916.476249-1-vinicius.peixoto@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kevin Yang BugLink: https://bugs.launchpad.net/bugs/2076950 Adding a sysctl knob to allow user to specify a default rto_min at socket init time, other than using the hard coded 200ms default rto_min. Note that the rto_min route option has the highest precedence for configuring this setting, followed by the TCP_BPF_RTO_MIN socket option, followed by the tcp_rto_min_us sysctl. Signed-off-by: Kevin Yang Reviewed-by: Neal Cardwell Reviewed-by: Yuchung Cheng Reviewed-by: Eric Dumazet Reviewed-by: Tony Lu Reviewed-by: Jakub Kicinski Signed-off-by: David S. Miller (backported from commit f086edef71be7174a16c1ed67ac65a085cda28b1) [vpeixoto: fixed context conflict due to missing 1c106eb01cee ("net: ipv{6,4}: Remove the now superfluous sentinel elements from ctl_table array")] Signed-off-by: Vinicius Peixoto --- Documentation/networking/ip-sysctl.rst | 13 +++++++++++++ include/net/netns/ipv4.h | 1 + net/ipv4/sysctl_net_ipv4.c | 8 ++++++++ net/ipv4/tcp.c | 4 +++- net/ipv4/tcp_ipv4.c | 1 + 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst index 7afff42612e9..ce47b37bd35f 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -1196,6 +1196,19 @@ tcp_pingpong_thresh - INTEGER Default: 1 +tcp_rto_min_us - INTEGER + Minimal TCP retransmission timeout (in microseconds). Note that the + rto_min route option has the highest precedence for configuring this + setting, followed by the TCP_BPF_RTO_MIN socket option, followed by + this tcp_rto_min_us sysctl. + + The recommended practice is to use a value less or equal to 200000 + microseconds. + + Possible Values: 1 - INT_MAX + + Default: 200000 + UDP variables ============= diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index c356c458b340..a91bb971f901 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h @@ -170,6 +170,7 @@ struct netns_ipv4 { u8 sysctl_tcp_sack; u8 sysctl_tcp_window_scaling; u8 sysctl_tcp_timestamps; + int sysctl_tcp_rto_min_us; u8 sysctl_tcp_recovery; u8 sysctl_tcp_thin_linear_timeouts; u8 sysctl_tcp_slow_start_after_idle; diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 7e4f16a7dcc1..5d22d4f2d7de 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -1502,6 +1502,14 @@ static struct ctl_table ipv4_net_table[] = { .proc_handler = proc_dou8vec_minmax, .extra1 = SYSCTL_ONE, }, + { + .procname = "tcp_rto_min_us", + .data = &init_net.ipv4.sysctl_tcp_rto_min_us, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ONE, + }, { } }; diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 94b129301d38..3418ca15af03 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -413,6 +413,7 @@ void tcp_init_sock(struct sock *sk) { struct inet_connection_sock *icsk = inet_csk(sk); struct tcp_sock *tp = tcp_sk(sk); + int rto_min_us; tp->out_of_order_queue = RB_ROOT; sk->tcp_rtx_queue = RB_ROOT; @@ -421,7 +422,8 @@ void tcp_init_sock(struct sock *sk) INIT_LIST_HEAD(&tp->tsorted_sent_queue); icsk->icsk_rto = TCP_TIMEOUT_INIT; - icsk->icsk_rto_min = TCP_RTO_MIN; + rto_min_us = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_rto_min_us); + icsk->icsk_rto_min = usecs_to_jiffies(rto_min_us); icsk->icsk_delack_max = TCP_DELACK_MAX; tp->mdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT); minmax_reset(&tp->rtt_min, tcp_jiffies32, ~0U); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index abd47159d7e4..fc0339fffff6 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -3505,6 +3505,7 @@ static int __net_init tcp_sk_init(struct net *net) net->ipv4.sysctl_tcp_shrink_window = 0; net->ipv4.sysctl_tcp_pingpong_thresh = 1; + net->ipv4.sysctl_tcp_rto_min_us = jiffies_to_usecs(TCP_RTO_MIN); return 0; }