From patchwork Mon Oct 28 08:10:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Naaman X-Patchwork-Id: 13853145 X-Patchwork-Delegate: kuba@kernel.org Received: from dispatch1-eu1.ppe-hosted.com (dispatch1-eu1.ppe-hosted.com [185.132.181.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFC8218C03B; Mon, 28 Oct 2024 08:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.181.7 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730103056; cv=fail; b=ZzRdEu5SrflmeCa0j8lK+JHctxycQb1C32a0WYKSRjsGoGySwsbiqb6LY47QJZoXY44Cs9OU7ISt6SCJ6+5iwV0TEo36e16K1YRSqmoSHBrzMNdvjd1SToQWJ/wZoWyCqe/YSVjSNmOHK4XSHd+N+l5qzYxn/3gxsogrXJr3MN0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730103056; c=relaxed/simple; bh=rUHBDT4trXJmkb5tyswTaGPIxsqofj4yArimpxGUwPg=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=a46IQLCtt194JJ5npYQearLeHnK248NbJOsOEjiLR43gIxw8vMVZH9RTetKaxDIyzLMDlEEx+2uSzDAd3qyii+fmGEm17Y+G7lZ9a801saFCq1BSal6f886mZFRQdIQRSZcIuoaTSQPFihDehHHY4zpPc1r50ks9ceVYSZCMo4A= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=drivenets.com; spf=pass smtp.mailfrom=drivenets.com; dkim=pass (1024-bit key) header.d=drivenets.onmicrosoft.com header.i=@drivenets.onmicrosoft.com header.b=bpZ35MJF; arc=fail smtp.client-ip=185.132.181.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=drivenets.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=drivenets.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=drivenets.onmicrosoft.com header.i=@drivenets.onmicrosoft.com header.b="bpZ35MJF" X-Virus-Scanned: Proofpoint Essentials engine Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2105.outbound.protection.outlook.com [104.47.18.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1-eu1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 5ED296C0060; Mon, 28 Oct 2024 08:10:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O6SrEl6IAihY5iIfbk276cn7VTlnZ44T43nXIQJ8eIcc4SYmYoCL9CmXASxq82TLQngvMAKAfhwKwOlo+nppJJUSmgo2qcDBFxDSYvVr9bJX9lFvy05lfg+311Yv4z+QhLnlJoryv0y9MeuL3LA0uWRFs/khS7YHK8ODgCw1/nKhYzm9JqDRhqDj2wseSera4Vnf/eZAlfEgVKeN7YfpPHf72cV4oM5IUZZQo2DTtpe0Ey7KQkivIQmzMEYvPMuy98vEaBgY10u4sV8ieqxOdQ8Bv4GLxEnyGnXis+fgJvtLkZq1BN1EenvRUtx/iAjJU5HhII0UWqPPObBT/oAcnQ== 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=KpwZHf6EQzxJWttrlJs/mDpuDq9smaNvf3KW1JbI9UY=; b=e2Qj4uUYbNC7czKxo1JPLEU9j0JmCrWwhW8BqJNojEPNhH0K8To5HORbj12rIbOrR5PGFjrXRNLMvbjkGV9xEOCC/ntqmUwxssvCUazrMR3WJDjN36/JgBJ8vOcU7Yq8SYsNZyBGQparBljY/s7R2Zzi7rzYj+THZY3HQhatuGS4OJwMU1GWJayAL80kFVGYDjYGNqaQWEeQ/PUMmHLDYZh7u6Sezi9eoWIYUtGd7ZX2xp40yu+c9zzL2PwPozHhv3bYcrjVlxQbtF++RJfJSAUk4irVvs7uqYX0mx5dTueRmah3Y8l5LqnoODptu+InzP2SB5W72ElEMW4A699ICA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=drivenets.com; dmarc=pass action=none header.from=drivenets.com; dkim=pass header.d=drivenets.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=drivenets.onmicrosoft.com; s=selector2-drivenets-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KpwZHf6EQzxJWttrlJs/mDpuDq9smaNvf3KW1JbI9UY=; b=bpZ35MJFqEFX3wbDTw2iTah34f9RvH2OWz+U+qH4ykcaUndcIUuQN3A8KjM32vonu9I0D4sJ7/Y0ja9cTsFUbuFM/uAT5yERUfUKwIs6wYiiIwy7zvQHWUrWubRZyQK4d6wKv9P7whPfdCoEGLxetGD8XNxMWiOYvHjMSop6iUQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=drivenets.com; Received: from DB8PR08MB5388.eurprd08.prod.outlook.com (2603:10a6:10:11c::7) by DB9PR08MB7841.eurprd08.prod.outlook.com (2603:10a6:10:39c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21; Mon, 28 Oct 2024 08:10:43 +0000 Received: from DB8PR08MB5388.eurprd08.prod.outlook.com ([fe80::29dd:6773:4977:dc4e]) by DB8PR08MB5388.eurprd08.prod.outlook.com ([fe80::29dd:6773:4977:dc4e%5]) with mapi id 15.20.8093.024; Mon, 28 Oct 2024 08:10:37 +0000 From: Gilad Naaman To: Marcelo Ricardo Leitner , Xin Long , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Cc: Gilad Naaman Subject: [PATCH net-next] sctp: Avoid enqueuing addr events redundantly Date: Mon, 28 Oct 2024 08:10:09 +0000 Message-ID: <20241028081012.3565885-1-gnaaman@drivenets.com> X-Mailer: git-send-email 2.46.0 X-ClientProxiedBy: LO2P265CA0092.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::32) To DB8PR08MB5388.eurprd08.prod.outlook.com (2603:10a6:10:11c::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8PR08MB5388:EE_|DB9PR08MB7841:EE_ X-MS-Office365-Filtering-Correlation-Id: 15487743-1ab7-4385-a184-08dcf728018c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: bq71RQ3j8bTjvdDmR7LIdnw+7Db34j+5c/7KUJg4x73yVrwJunvRYg8HY33AtjEzDErzPv3Y/EQ/m0/H+HocK4dCtLSsemUsVF9iEJ67BsS798tXbdVAtA3EzD6ciLj/olHEEIRYBJX/JjhxoN80RzED3CnIjpuvWAwmBO30wkDPDzJCCwc+9z+S3VGGI4kPJepww8C24Xl9U2iqrXRxi4fZF0GrQUOTk7ZLzqjxx7Q3GTv1bBGbkL2pVAKqYL5me5hNA96P4lmNV2h4uQ65yhFyi+nR5b7W0eKoaxJOZuABeIgeIZR9CWa1KmRwwWqZ2hNVqIwRv04Knp/wZCi3jl9UAhDMuxm+z/f5bt6G80wT7kKGt6rAU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M;H:DB8PR08MB5388.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(52116014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zzg0tBdUvUidrQ6xSjrSOKT+2yQl6LSSyUwlxzjqV29jf9he4mOB57qiGgnP7R4B7mJC5lSkEYQfIqA0BCftWTmfxyoomF6TjoMVR2EajR3l/kxfMt4uJALJm9cfo2+hLSVfSbDzPQwStVe0p0lzhYG3GbF3MiO0dhuo6UY4u8RJHgyMWR+gZjOGQplUWQxl1+/i+lgMvCTWt2n45Ixjc5sD3CG8FXYdxqIX/mjcNOTmrHD+yamtjMmZUXvWRnfLHAZid3EOoMI2OuLwzjW1rHYYEGLbIhzUC3R5iPnwlTk+QYksmCO0m7IVEAoQ0fecEvtyaU0i1WRdsvBylg+7Viog6K4Hw8jnXBA6zKoXiqAJnHer8ZjQS4JqIGUUhZa4kbpeDtVx4ejN1PP5VfiiCJikLsDPSsLZ6CjGGvMYiybhjspbFrAmVz2uqVdkQ9LtyGngVif1IrGvmCB0c8iY+GSfsb198/HQRtSteDlyE0iH6soOiHoghcE0EBthdqN5IUfoXDJfcrwFHUkScrNLXWPU3gd63Qy41H6Ohzo3HSjhdePVSSDofIiqlnL3GvmYfc08pRqaZ0yCtdb2XSebdbQYzK/vFgpVbrC4KQRlU5y3pgCa6V2XiRLOmSuoR6iRviFYXq+Juv0L1iCuxQwkZuN7M6CkKC8GlIPud8CZQEqWLHkH7nbQcucc5A7PpzKaxY9Xr7BUqGW7Tr3lGIWxYX/ii6PUqy4/DEczF3H76gUW1DtK//1FQVIpcjzuKyB3wJtEI1kxPUrWskLgGU4bzvHNExO29ynJRo9ctZw9NL5PgzzEtD844OVXP/FYes/e65PeIvf6y7Le3iMlD9KLDGlu7BJqjnqczOV5TI2oZdTkgtbYxnaPKW+dss4dmEAe1klB0F+bDByO3Vko20wrxR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jJh6MdOsbzf0KKlmOXctyAQ4NEGLc+f9gGvG/5F4pMdm6WeK9e6Ex+lEoq4Mb/eNcpEHPuJPOT89o1PSoWTnapQ/C4jve3rwuWit5+FOUvj1o123cIf1AU+y/Xj2MdIigv900PzCln5+aMh0Zc5r2bQ74795DChPYtLBsjRIun34MmO9PQdz3WBjmsexr+86qDMUFVjhwhAmflu5RQu4W/NOHeOhhQzSMSf08NjkLzZ+jF+LkqvwCYrLL1aSCkldqyhKXdhiOzWAolfYihZ+krlIDhEkcWbijwEL12Ic25Kpi/uaB7lD6Kguose X-OriginatorOrg: drivenets.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15487743-1ab7-4385-a184-08dcf728018c X-MS-Exchange-CrossTenant-AuthSource: DB8PR08MB5388.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2024 08:10:37.8363 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 662f82da-cf45-4bdf-b295-33b083f5d229 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lWO+m+kU2LmIBD88SQxwtHSEbcKlSXtHyt+IU3lxNGJAFpOU2Y35V9aGyqH0yY/8Zz2Y/avb8mrPyXS0rJ2Oxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7841 X-MDID: 1730103046-t_UVn2DocGQx X-MDID-O: eu1;fra;1730103046;t_UVn2DocGQx;;7bea9940ffb8aa46f58eafa9edde571c X-PPE-TRUSTED: V=1;DIR=OUT; X-Patchwork-Delegate: kuba@kernel.org Avoid modifying or enqueuing new events if it's possible to tell that no one will consume them. Since enqueueing requires searching the current queue for opposite events for the same address, adding addresses en-masse turns this inetaddr_event into a bottle-neck, as it will get slower and slower with each address added. Signed-off-by: Gilad Naaman --- net/sctp/protocol.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 39ca5403d4d7..2e548961b740 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -738,6 +738,20 @@ void sctp_addr_wq_mgmt(struct net *net, struct sctp_sockaddr_entry *addr, int cm */ spin_lock_bh(&net->sctp.addr_wq_lock); + + /* Avoid searching the queue or modifying it if there are no consumers, + * as it can lead to performance degradation if addresses are modified + * en-masse. + * + * If the queue already contains some events, update it anyway to avoid + * ugly races between new sessions and new address events. + */ + if (list_empty(&net->sctp.auto_asconf_splist) && + list_empty(&net->sctp.addr_waitq)) { + spin_unlock_bh(&net->sctp.addr_wq_lock); + return; + } + /* Offsets existing events in addr_wq */ addrw = sctp_addr_wq_lookup(net, addr); if (addrw) {