From patchwork Tue Oct 22 13:43:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Naaman X-Patchwork-Id: 13845724 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 E339919F40E for ; Tue, 22 Oct 2024 13:44:11 +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=1729604653; cv=fail; b=VNCe1ApPHvYGIXCPkjUn0YE9D9qEAaX6dXtrEnUmM+kHD37N7EJPFQ2wsNcdngT2burKI7Gj7iS4yPE76MrHxFc4kA8iTQosAFrIlijvxySHJQWlf/7rWIDwRfbxeg264pWd2giNeIQ/Q7LFK4hl9NsVpiK8c4NTwJYVXUncfSA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729604653; c=relaxed/simple; bh=Y+lnkF8Ve+oTlSHG5xFuCthjiO7GIaGyaQcjdB9ch/A=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=qISW5Xl4ZM8MI/oCHWFQAJnXvTolu9E3Ea9+kgMowrESuiZ2oSjAQwHKuukupnH2dD9gu6dPMa7Jyk1h4wDpPGDi1Rnf4KtuqEzSbMLD09oItLEMk3NQ3iCwxRTfLkHcFM/moqU2UKNk0fqyBv9z59LhjpZe2S+tTTK9QN/JfCk= 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=dCfVThR4; 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="dCfVThR4" Received: from dispatch1-eu1.ppe-hosted.com (ip6-localhost [127.0.0.1]) by dispatch1-eu1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 747B934065A for ; Tue, 22 Oct 2024 13:44:10 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2239.outbound.protection.outlook.com [104.47.51.239]) (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 366F1200058; Tue, 22 Oct 2024 13:44:01 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L5Pdv9i54TB+x44920twLdl6URg0nEvZU8n41Di2Gx8LiuETyrPehLt02KSxYVuIbBW5phVuD3ZtmwJuJb9LV/6UBPvXtp3pS539+y7jLVDFtLw4vBvRRDDVl7vOnpUlALfS4ZvETkvXkr5TOMdSgF4Gn7QtKQ+Jwa950OAPr9qeSGnSbPsFftAw4XQ6c/rQp30BBn1+J2HAeFHqEcgAFpaBw12eLzjfAyziGIQe+rxM5BB1WBpXfRFWHFSiZxFswPVG4pQ7g6Y0LG/z3kB2R4E+hr/Ldg0x43q9Ouo8oBUCgbJtmmMH7fxS5qFRu4hTKGIynY6mxN3ssmDkJ2Pz6Q== 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=2vS1sCcx1vulNQRGkxZjg3vZRSvrG5RUNHXaL7zukBM=; b=dWC8odFPlIclVAI6TAvPYyuvXuC48az8whBDV7/YKkN9b8BknY+sxNHycsxBRjMfoOVhqQn0h6Fjhn+bTpi3qXEUZttdULbVXP1+e0Q8o2t8z+PqSBc3bPPCTnyaSD4Q2fgRkvs8rIfO2B1TZPL23ObVk53UHaqOYOl8iTxQ+2kpEwpvoaCHeGbPlz1GOHNI0rTfSjXrIsC/RAT57DMMB5Hzis0VnZEitIfXdWXhHMD6oi2p5g20WpeniXW30AtVqIFGGMRTHipEBRqqOhClcIjIwFnG8NteSYuMq9sf8TvZIf6eoXNgoFYgmqOSgbJ1K4zy5wdyD563t4MPmQK6+g== 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=2vS1sCcx1vulNQRGkxZjg3vZRSvrG5RUNHXaL7zukBM=; b=dCfVThR4E63G7SwMxgBMBScnlG115iZKVg5jQdjDQELeWA40IiwzaFAKtx2zayJ1v7VPAlNy3udZsuzBy+PBNnmQ7kr1E8YXjtzAB60fpiMs/U13zhKIREkjElT7ci14BFA1da3/VjvjwhFf78jMEiKxco9KI2g8QGlXqc5wFyM= 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 DU0PR08MB9077.eurprd08.prod.outlook.com (2603:10a6:10:471::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 13:43:51 +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.8069.027; Tue, 22 Oct 2024 13:43:51 +0000 From: Gilad Naaman To: netdev , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Gilad Naaman , Kuniyuki Iwashima Subject: [PATCH net-next v7 0/6] neighbour: Improve neigh_flush_dev performance Date: Tue, 22 Oct 2024 13:43:35 +0000 Message-ID: <20241022134343.3354111-1-gnaaman@drivenets.com> X-Mailer: git-send-email 2.46.0 X-ClientProxiedBy: LO2P265CA0192.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::36) 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_|DU0PR08MB9077:EE_ X-MS-Office365-Filtering-Correlation-Id: 805aa6c7-eca4-41a6-a13c-08dcf29f904a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: wfyoX9Ql/9QvNVrTlFPCIzOuaUYw9MjeC7D3isHJDp77Ve8Otvu8NanMZk1iKC55l5bMuL52T2EWCR0UF5cA9wCFenWKEeNPLC0xJOsrb72nkN7ONGo0QQ3KS4QFAAXs/NoMyZChVRZPqOiwbtLUbAPXUyA2Lg+NOmr4XUJeohNebYO3AUuDAk+XIvsd+Ic6MUsdpA6u+pn0SUmjIJkM1LRR7kIDYZs+SIRNXncFap9gukvSl7l5r91mOUOhqfToRjS/vlbKvayCpNOVnk7h7qGx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mDsLEBeaOx3fYsqyEO5SpzhTjLYBBkN8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR08MB5388.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RGkuGQshpaKBSzjU7WDR2NL5hQVxcKs1sNxos2dpGz1DwW3Yb7A6pW6ADJWs0VEukr3QDbyy4GTcuI/CifrhR74FJ0j8hbDu1nQaWK9dO+l6jesluWFPC+yvCr2x+hKry4sH3Bmw5+invn3T+8/0nLxRfvJkIK1+FFLwhsnK/lrdhTprOaHb0PyvpNNQezBUunVMyRhZQrZ72HMR2mVNJsVGqMIzsFi67KlVG3HRPeoXatJM6eFcDJrQA0K9qvvYWyrQQxiYbJxeU43HMPSXTnj7nakLGaelmMUqtHJ5NG0gNj9f6IJptu1WmQOkVav+tPw4qSI/VR5LeH8wppxxCgMXm8s2/Xf7mtCS/TCt+Ly3oHjC7mNivGe4asP9Ki6g+eChsjfC0T70pcVzAW5KMhuqDWfJeHUn9idj3pYmmf+aPqMenLPEOw4QBV4/H899FkOTvRvkLfqGaZbur5eyxjLH2rT+C63RzyjcJi7AwALnP8gdgORkXXcPVk51+rlCJjHnkxCggu9A0bGdGjL9jkSXeHikBcoupQp/8RVUP8UICgYGGf8ulpbSkdI0cDylzvslXITVX3/8dSVp1dxFx+ezEUwScdQU/QVmsOzn/3oivCJZGREecC+NsC1uihfefWkjkjSq7wOy190G43C9nI486dtNHPEdMgXylmvGPrAWRtm3BHtAe1CktWWZVCGx3tnpbg/BidyrH8Q2WjkgKqdQ1CkMhlQ5yc8tMohBRV5NJkhjhrDaz3gEnJD3pyFXWLLu1dp3hmD3TvVaaP5FPdS0QVaKOzK9JFOBaHFP8KPKUfJIzhYDEOBF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fWufILI0vldt5omrL6nC7HhfYUG7NG20QoEvmgrErhRS2U6xe0H96t80h5AzTYylvMuIUpkwBB0/MIn2WEO67rAw338Uc9yJ75d1poFGa1P8HagF78AmSK/OD9towaOlIFLFuR7Jy2Lrk8tev1bYXlxAn+t6bhE4lI3+TpYwSlMay1jc5BWjKKLKP5Jgxzbh/uvg3RSfFyVeethDGvwVXL4joEASHhjZpF8NEQ749M9XzpHKeG33nOlCnoc6opA3jDScZuKF4pNcMDe/ETGaYkZ+Bn8VAXj5Z9LPA9C3mFD0fXpPkaHEkSp4ecBzG2RThR041VjeaZWWjHeraryaBqD+KUP5/jXp2eMLLjPbP6U2C8zLA2qSsD/WguORNdd2grmvppHAALbzzyxHcjCNVeJK+9SR X-OriginatorOrg: drivenets.com X-MS-Exchange-CrossTenant-Network-Message-Id: 805aa6c7-eca4-41a6-a13c-08dcf29f904a X-MS-Exchange-CrossTenant-AuthSource: DB8PR08MB5388.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 13:43:51.5768 (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: B5Zv9fJmlGad64U0TSvCgljIJhMMTXOOHwsC+0UDEw8Sfq/50S0Tws/9Ty5o5umtP/hhmhNE47+R1+Rpxmkw1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9077 X-MDID: 1729604642-1mFG9iPNUuRm X-MDID-O: eu1;ams;1729604642;1mFG9iPNUuRm;;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 neighbour-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 v7: - Fix crash due to use of poisoned hlist_node - Apply samx-tree formatting 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 | 24 +- include/net/neighbour_tables.h | 12 + net/core/neighbour.c | 337 ++++++++---------- net/ipv4/arp.c | 2 +- 6 files changed, 174 insertions(+), 209 deletions(-) create mode 100644 include/net/neighbour_tables.h