From patchwork Tue Mar 18 00:27:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 14020086 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011016.outbound.protection.outlook.com [52.101.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA82F155753; Tue, 18 Mar 2025 00:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.16 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742257689; cv=fail; b=uMFPM7iehOESo6LHuVo221y7ipYBdi2jn4D8bz3QvX+bWYeZ+kDVItoQjYQHjO02npoPol75dGEDkPvJZwBhQgKAdX6AUlbtrFAjuShHx2AVsuQr1DvziPj4SetQ2NdhexDnI4ZlFSBVDmBohpeYwn0jpgOhEpTJBi2YivOmulA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742257689; c=relaxed/simple; bh=tKsZlajXLpAOIbyJ8qGKdzctObD1YPtdFcgDVM+hUHU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=gZ/hGrfulgVrWfiDfDkJ8OAEacVHlzzI8Mi1s8LZbQGtWUKbIyYsK67p6bRuvizx5jUzacW+UdVZqeiFFdUbhjHvxp30QKSmgUaUUb94lTEJ21gS4hPLe+mEHiQOr/OZRAyfMxc+iVdtAdK67J0BWcdGCzmnVsmgo+gysvv7yS8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=Jd2enOf2; arc=fail smtp.client-ip=52.101.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="Jd2enOf2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZNIJSeDGbCq8sVWz5b1aqht6jIpmQHo6I1DS8G2gxgITgk4moai6OCoteEicujF2x6a/LUs7sSnUctaiZhQVDU2DA2wh5txLHL/moRUDhlT5rbWfZ5ugmV2w4H91nN9PEoXrxAMs4UOho1B8MrOV3dr+ViaOiGwBb9lf8va5h2mCfi9cc9GkgKxK8oZ1aUV82PfU2DyC4AHc3YeABVmvcDO167hFfvienZgXt/1eiuRdBdg1dkdDpNnKJAQ62pj5h+V5yRu1zHCi93SV96kcTo6rtHPBiRwHG6RUM99BUsI3UVSxuNNAe+eh883HRdtD4ofKcAWF08viTkaR8EtN/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LphzWS9GjpX6oHrIgVfxf1jJOgRAdXuN7feHQH5h6s4=; b=GTk5YGTM9uzBCAgrDVygV9qxnAD80UPqemVCsehFs9lBQ0WoukExW7GiYkmQtelInbPmW31H2+xWuQ+EivuE0KjysScKDn85NW1TzcZ76ru0r207F3qM/9KzNxom6b8biqB2ifT+D2MeVfv8Cb/sJH8nMTo9AiVAaciw3yenfaZv17oU8GLywY1SzmRHJuhFRUQWlem8ACMHd/EvzyErDnbvvIks782H5ibYddCWTJ7U8GAJ/Q1wJQBASrDS6GfavT6rM7z5HTVsaXr5hjXeJteXaEvxzeFUaC5nUL0Dze8gcZC1UPfBDc3qX0kW4rZ/so9MlgmXm7F8A2ldK34D2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.100) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LphzWS9GjpX6oHrIgVfxf1jJOgRAdXuN7feHQH5h6s4=; b=Jd2enOf2Ryf4CA8Nh+KSQ8MTy8b1I9oz1dF36Ug0CKEItIzf6JwTsGTcfNfsIwi+OG9UXzmOHEKerbtejWMDAbR9kHJ10ao8SY/YjwaKw+A9/Yj2jPYr3YVElPTHmXThQD0rm1WJP9FwnuDQ3c4TdJnFbNgbvX6I+uzPerDCIb+6yeG6WrIYlJsTA98mq4Lz50tofJJplFHOk3Whmk8krBRQ9LiueaMNCcAxOr+UfcMTgR/FJ4/mkJBq9aBjVdo55gLwoMig4rhBXsbIsCjAA9byoof9hFvIjhJDUXVbswT/JkAhUnsk0siBmn8guf4I08UW8MBV1u25ZIdaX5rctw== Received: from DB7PR02CA0011.eurprd02.prod.outlook.com (2603:10a6:10:52::24) by AM0PR07MB6305.eurprd07.prod.outlook.com (2603:10a6:20b:15f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.33; Tue, 18 Mar 2025 00:28:04 +0000 Received: from DB1PEPF00039230.eurprd03.prod.outlook.com (2603:10a6:10:52:cafe::89) by DB7PR02CA0011.outlook.office365.com (2603:10a6:10:52::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.33 via Frontend Transport; Tue, 18 Mar 2025 00:28:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.100) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.100 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.100; helo=fr711usmtp2.zeu.alcatel-lucent.com; pr=C Received: from fr711usmtp2.zeu.alcatel-lucent.com (131.228.6.100) by DB1PEPF00039230.mail.protection.outlook.com (10.167.8.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.20 via Frontend Transport; Tue, 18 Mar 2025 00:28:04 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr711usmtp2.zeu.alcatel-lucent.com (GMO) with ESMTP id 52I0RNBu024935; Tue, 18 Mar 2025 00:28:11 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, dave.taht@gmail.com, pabeni@redhat.com, jhs@mojatatu.com, kuba@kernel.org, stephen@networkplumber.org, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, horms@kernel.org, andrew+netdev@lunn.ch, donald.hunter@gmail.com, ast@fiberby.net, liuhangbin@gmail.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@cablelabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH v2 net-next 14/15] tcp: try to avoid safer when ACKs are thinned Date: Tue, 18 Mar 2025 01:27:09 +0100 Message-Id: <20250318002710.29483-15-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250318002710.29483-1-chia-yu.chang@nokia-bell-labs.com> References: <20250318002710.29483-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF00039230:EE_|AM0PR07MB6305:EE_ X-MS-Office365-Filtering-Correlation-Id: 428cefdd-286a-4600-1806-08dd65b3bf64 X-LD-Processed: 5d471751-9675-428d-917b-70f44f9630b0,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?OXPsr8ZxPeVCRALcb4Yx7V1GeDMmQnG?= =?utf-8?q?Z0oZM+BMBNXnrImj6yOgn1w2hohGLZ3rLVu07E3oAhxSvysWgqZ/f0VHp4eLuRI16?= =?utf-8?q?qNIJYRcURmSyTKVfBa3c/22LeRJFKVgG+hF94VleKVd9eKyINRQwwE20cDPUJKt0Y?= =?utf-8?q?+lRrjZEZa4BLlhZUM8HpkPgjLXR+rJCotAYzZoy3ZW5EllUwymoVuivKKfQoedQdZ?= =?utf-8?q?TBskDfU+2dF5nRTI4NkMT/wFKc5tfWtS/9wGA1xf1v9Np28QpWiV73lZudfqCUKSC?= =?utf-8?q?KSFzRQToNN+PDNQgsorws03J/DqlG0o4A5TpnCxIx/oqlEnU7+kqj3X3QYe2hjbyt?= =?utf-8?q?Ua8hWbOsbzTrHckuG2CHt/K8I5pFQBu/HRoGDPeDegsydOu91ndpkF1d3PN9c/OOK?= =?utf-8?q?XjxvYxUxQlhpqxQ5aHngl2OJsB0ldj7ZhmkCYD76A35mjpSovDFyA1scchoV2AHnc?= =?utf-8?q?8hqkZ8LZxi/l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efTA2J7ec4dBFUb0C0PFztf0yLMlq4ZDhEIdspB2cEA5sj6sPWv?= =?utf-8?q?2EiPZ1t+pSIrbJMxsqqah2tLCJ6mmVQoCPJm9oloZCnG0rPNkzW+oQRa2JWSAXKl7?= =?utf-8?q?AtvU3Hqqix?= X-Forefront-Antispam-Report: CIP:131.228.6.100;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr711usmtp2.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2025 00:28:04.0101 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 428cefdd-286a-4600-1806-08dd65b3bf64 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.100];Helo=[fr711usmtp2.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF00039230.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR07MB6305 From: Ilpo Järvinen Add newly acked pkts EWMA. When ACK thinning occurs, select between safer and unsafe cep delta in AccECN processing based on it. If the packets ACKed per ACK tends to be large, don't conservatively assume ACE field overflow. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/linux/tcp.h | 1 + net/ipv4/tcp.c | 4 +++- net/ipv4/tcp_input.c | 20 +++++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index ccb5918c8b41..06c0ff87ad4a 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -310,6 +310,7 @@ struct tcp_sock { prev_ecnfield:2,/* ECN bits from the previous segment */ accecn_opt_demand:2,/* Demand AccECN option for n next ACKs */ est_ecnfield:2;/* ECN field for AccECN delivered estimates */ + u16 pkts_acked_ewma;/* Pkts acked EWMA for AccECN cep heuristic */ u64 accecn_opt_tstamp; /* Last AccECN option sent timestamp */ u32 app_limited; /* limited until "delivered" reaches this val */ u32 rcv_wnd; /* Current receiver window */ diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index c4eadf6dd6fb..01532c2b6acd 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3369,6 +3369,7 @@ int tcp_disconnect(struct sock *sk, int flags) tcp_accecn_init_counters(tp); tp->prev_ecnfield = 0; tp->accecn_opt_tstamp = 0; + tp->pkts_acked_ewma = 0; if (icsk->icsk_ca_initialized && icsk->icsk_ca_ops->release) icsk->icsk_ca_ops->release(sk); memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); @@ -5080,6 +5081,7 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, delivered_ecn_bytes); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, received_ce); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, received_ecn_bytes); + CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, pkts_acked_ewma); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, accecn_opt_tstamp); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, app_limited); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rcv_wnd); @@ -5088,7 +5090,7 @@ static void __init tcp_struct_check(void) /* 32bit arches with 8byte alignment on u64 fields might need padding * before tcp_clock_cache. */ - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 130 + 6); + CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 132 + 4); /* RX read-write hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, bytes_received); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 5c71135b43f7..cbcb3a2d4786 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -690,6 +690,10 @@ static void tcp_count_delivered(struct tcp_sock *tp, u32 delivered, tcp_count_delivered_ce(tp, delivered); } +#define PKTS_ACKED_WEIGHT 6 +#define PKTS_ACKED_PREC 6 +#define ACK_COMP_THRESH 4 + /* Returns the ECN CE delta */ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, u32 delivered_pkts, u32 delivered_bytes, @@ -709,6 +713,19 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, opt_deltas_valid = tcp_accecn_process_option(tp, skb, delivered_bytes, flag); + if (delivered_pkts) { + if (!tp->pkts_acked_ewma) { + tp->pkts_acked_ewma = delivered_pkts << PKTS_ACKED_PREC; + } else { + u32 ewma = tp->pkts_acked_ewma; + + ewma = (((ewma << PKTS_ACKED_WEIGHT) - ewma) + + (delivered_pkts << PKTS_ACKED_PREC)) >> + PKTS_ACKED_WEIGHT; + tp->pkts_acked_ewma = min_t(u32, ewma, 0xFFFFU); + } + } + if (!(flag & FLAG_SLOWPATH)) { /* AccECN counter might overflow on large ACKs */ if (delivered_pkts <= TCP_ACCECN_CEP_ACE_MASK) @@ -757,7 +774,8 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, if (d_ceb < safe_delta * tp->mss_cache >> TCP_ACCECN_SAFETY_SHIFT) return delta; - } + } else if (tp->pkts_acked_ewma > (ACK_COMP_THRESH << PKTS_ACKED_PREC)) + return delta; return safe_delta; }