From patchwork Thu Nov 7 16:04:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Naaman X-Patchwork-Id: 13866661 Received: from dispatch1-eu1.ppe-hosted.com (dispatch1-eu1.ppe-hosted.com [185.183.29.32]) (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 289E7215F4E for ; Thu, 7 Nov 2024 16:05:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.183.29.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730995515; cv=fail; b=Kjyk2X3ohxM1/Kqp90brh8FA3s27Gy+1R7jPKPuqczksnFyEZ6HM+29taDS45X9kLYgbeHz/+FoUabcUleR994xBosCP+IpQFzL6fsUxHRcuuhf8maVWpzPm/OROcbk4jYEs5k380iWbu30BI8ru6r/sYqBbc399jQfmGPIssJM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730995515; c=relaxed/simple; bh=mqRB1gP4vMSHs4CmsJ+jivnUirb4GLP5EARCNqOpb4s=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=BDoPb+lwbiVqrTmPFy0PTYWSI0XRi6hehLsBfa7Ef9bspWikpgKWy0rBcN+9PiwS0Lz2+NSFTV1aleXi+sI6CPbwvIJDJMHVavNjWCERGdDZ0EiES3vOzcDAd7SGM3d8y+F3QtJnX0F0QMrtEY9B7bhhf/IJcMo2UcNbDfZcnMo= 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=g1rM0S+J; arc=fail smtp.client-ip=185.183.29.32 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="g1rM0S+J" X-Virus-Scanned: Proofpoint Essentials engine Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2170.outbound.protection.outlook.com [104.47.17.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by mx1-eu1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 80C40480063; Thu, 7 Nov 2024 16:05:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cUoSX3ogCrlkjaJFOa/r/O2g1y/9gA4NtxzIj7mGHhbeORP3X4jbxgczPDjO76ZO/TMNP6t4RzsRJ323FPCY0X1QREIHPL0xggnI5cW3oUv2J/NSIQE8s3HmjpMSyjYVQ5/4svgzuMhxCWJRt1/PAYqiMUwDEkO702pIxmtkTzaZQoTUEBbPqsl2AWm2vt5YqILjbmC5OQv4wIbvDhaBxqZOVabCNbbklIgTqb46hxSKGG1l8EM6wRiDg5LYPidaBYyNguEJxf7N7M33M8UFNm5iK3OA2C2lSwKtrrReVUlCnkmnvC4T9308EQ6hYQNuvBYK4L/tct4tF7T/rHt9yg== 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=nCMPM4EnK0/NKN1WB2TM4S1A3Zv8Wam0sG4y9/9GVOo=; b=q+DeA0BdFPclsai5MtlDVkdCsvEj+mamlVBF8Qe492GM2FX8Qx9vUnozbeBHjuDpJov8KLdwn7Quy0MqTApp5sWsiVElNw7UO8uPDHJoR+xeQEhwbvljACaSHJe94RWmSlCMTzvKuq8gy+Sm5h6hXC9eu3k0aDLA00hsKactIMcsxJ67vSZt8Qo8oCM+aJfvBl3iv2M4LFEML1ClmMq11YI0l3vDynt7FG2vyUZJZjmPczHSD/BZqyKmnig20kKJbDnZAgSwdI2PRjmedLd2sMBgjL4KzVyxVGqtWuPKP/j+s5txyJjUL9KmgiAVb/5AOoYXkxs04s7NOrCS3RchQw== 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=nCMPM4EnK0/NKN1WB2TM4S1A3Zv8Wam0sG4y9/9GVOo=; b=g1rM0S+J7uzottKWHoDoKi+jNcNaNkQvrrP2vYE51rDlarhf3yLTD/0TtU/i5ABOW+74Xwr+t8Ykk89iBKAGg0AsnDeb3pKMgawnSXfmzy7X7zgVwHg3xV+7+P2o1GjqSnWUjF9/t07ocLNY+1v0dkKBNobcV5tDotF1Dw7ddVc= 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 AS2PR08MB9296.eurprd08.prod.outlook.com (2603:10a6:20b:598::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Thu, 7 Nov 2024 16:05:03 +0000 Received: from DB8PR08MB5388.eurprd08.prod.outlook.com ([fe80::29dd:6773:4977:dc4e]) by DB8PR08MB5388.eurprd08.prod.outlook.com ([fe80::29dd:6773:4977:dc4e%6]) with mapi id 15.20.8137.018; Thu, 7 Nov 2024 16:05:03 +0000 From: Gilad Naaman To: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Kuniyuki Iwashima Cc: Gilad Naaman Subject: [PATCH net-next v9 0/6] Improve neigh_flush_dev performance Date: Thu, 7 Nov 2024 16:04:37 +0000 Message-Id: <20241107160444.2913124-1-gnaaman@drivenets.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: LO3P123CA0030.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:388::13) 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_|AS2PR08MB9296:EE_ X-MS-Office365-Filtering-Correlation-Id: 22f8c22e-f09d-4c30-5f96-08dcff45f03e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: DumdJdhpvdn9u31M3vd9LpOE9NXTXDoO8dS20ec/5jX4Zt7sD8KoDIbC6xZqD02tz/oz+Ih6COUMOuzIp9hC5TorwKFhebs1w5JPHO9eLruWrylInJ/kt5HmJaPZzQyNBd4VWfxBuEViqOyPLr7S/Qq4hK+SJfC6kkOwVqqeDVmJZRLnNoTsk5mbI8ibB2DDszHqbSmD/Yf+fIQKrtV8xkY3FajumQowHpoftzEt5NJRB5whusUhRR1zYdkN569LFHxjAH996nZtxqmfHm2j3MAN+pUJrVxuYv/7J3Fu9/MVWyeHdD+CinAlOPHjRgbppfUho3ZdNaUzkRU8A0+zGdkbQYGySAhpebU+TEx0CNeQECVZ1xXVZU36mb/Lp2TFH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R08MB5388.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: owBoDPRYWyhXetbjb+P9kbxYGgBerGHzirNC+GmZqXknDdDAu1j/mnZ6xyuENhewkvKTa4qDlg8cJibI0DHwLk4dq9phS0Qh5fTXTDfBWeBzrfHe4iId4L9bG8K1vEUjrycstQlrIYcE48jtzM6vLjqJcsvCMxW6gbaSh3mnnYxBBR1T4527XKZWk9Lp7Dtc6KG5epVd5cN3XjYJEt4vFE2S1J69yZupmsxgyM/1D/PlrJAdsfnHN6QaCtOPH3wlNLYVyfHovi6v8pssAEdwaTNZZDDh3ynpD1sVMFjkZLLUdl00cE6V4Tvnk70Enejn8LHYd3sFQ2UFHXi1l76iDvwVTEm3+G/g+mB1Rhlof/OcqWqohnFIySYd83gOj2f20Ur5mc911RkztIB+w2HnuirzN+Sw5WYKlgRpDkd3FLXnEMwdOir7KzRIvNOvxxnn+k2cvLhA9//ueSDtJ0UbTdPgcvW+xsYZ+RNsxsglfv0tcDTNpzcGQhqoZ6HC6IGe29vtq0EkCxfk+cnF32FWYHGmHLAhB3xOYAgsQ9XL7yclpjNF9wtK0RzDmpwFn0TvrIzTFw/zqfOaDIQDDIu8prOIYmSI+sTHmk6pKI7yM8B2lfSL4UMqlY+oVCz6o3KsBmOjI2S6XgRrmND/903KM61kdq8HItXRQZ3f9Fix0ROJ21whLlmTM+MabFFkm6YjW9ZIpVUKuN+H1Uu+YD44jia+EJBaQSDR9E2hYeBMmAvJoOP2IfmeykcXUSacznx5yEBCatvm6DqrKWXrbiEQzUbSpd3D6pIUOCZQt8AbEuIvkuFR0R8d3mczpHqYdnxxSkwhDIyv+vtB7V3dJBUo7YcvWxm7JcOIDWBRn5CL68c9xLpLCj4y6c4/YslFdoQM0VrZBlcxzQSy+u/0Bbut3yK2k4s+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GanOYhM4/rr8X+e5cdnzsjbNgDVt10XRPJ5Z7mARXwD92yxhK0xDbjY7FPHwmjmPbl9TrNmYEg5ej5AMNk2N3/H/ABCueVco9HndLeoBUATLHamAfl5s2jdcDE8g8HKtotfBYJVfXdHYkEApNwiu5GKVOApMkLqNSatVWa4iDvKbwRUJe7MmseUaxZD37Fz6S7YGmq11gSm+jJE2rz5ubald6N212uSJsn/dw8KnK0XW7qXYQZpzYMNdn6mrmN3Vjxi2k8faUMUbw3r4Nh0tqthfmh8oRTWTJ8gr3pGi9YVgedVIeMBLK3 X-OriginatorOrg: drivenets.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22f8c22e-f09d-4c30-5f96-08dcff45f03e X-MS-Exchange-CrossTenant-AuthSource: DB8PR08MB5388.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 16:05:02.9713 (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: bnbE4e5YtjCw8FkiOd1IUjABLjLbrTF5UpG6WW5c+L6S5DfNi9ZoDAgGtcTprbnAriKwcKE+niIFdEfHQgZXnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9296 X-MDID: 1730995506-1Jz_tj5oqi6Y X-MDID-O: eu1;ams;1730995506;1Jz_tj5oqi6Y;;495c1e7a27a6c3e35a5fabc922783896 X-PPE-TRUSTED: V=1;DIR=OUT; X-Patchwork-Delegate: kuba@kernel.org This patchsets improves the performance of neigh_flush_dev. Currently, the only way to implement it requires traversing all neighbours known to the kernel, across all network-namespaces. This means that some flows are slowed down as a function of neigh-scale, even if the specific link they're handling has little to no neighbours. In order to solve this, this patchset adds a netdev->neighbours list, as well as making the original linked-list doubly-, so that it is possible to unlink neighbours without traversing the hash-bucket to obtain the previous neighbour. The original use-case we encountered was mass-deletion of links (12K VLANs) while there are 50K ARPs and 50K NDPs in the system; though the slowdowns would also appear when the links are set down. Changes in v9: - Use RCU iteration in ___neigh_lookup_noref and neigh_dump_table I kept the reviewed-by tags, as instructed, but note that there are minor changes in commits 2/6 and 4/6 (just adding the `_rcu`). Gilad Naaman (6): neighbour: Add hlist_node to struct neighbour neighbour: Define neigh_for_each_in_bucket neighbour: Convert seq_file functions to use hlist neighbour: Convert iteration to use hlist+macro neighbour: Remove bare neighbour::next pointer neighbour: Create netdev->neighbour association .../networking/net_cachelines/net_device.rst | 1 + include/linux/netdevice.h | 7 + include/net/neighbour.h | 26 +- include/net/neighbour_tables.h | 12 + net/core/neighbour.c | 325 ++++++++---------- net/ipv4/arp.c | 2 +- 6 files changed, 170 insertions(+), 203 deletions(-) create mode 100644 include/net/neighbour_tables.h