From patchwork Mon Nov 4 08:04:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Naaman X-Patchwork-Id: 13861015 X-Patchwork-Delegate: kuba@kernel.org Received: from dispatch1-eu1.ppe-hosted.com (dispatch1-eu1.ppe-hosted.com [185.183.29.33]) (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 492E8198E81 for ; Mon, 4 Nov 2024 08:05:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.183.29.33 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730707510; cv=fail; b=pm0PAUNWd3OemHdN/uos8Q7uFlEys9cFqPIBjrvxv04PGjX6k/7NL+6pQ8bLZaG7wFGs1gR1FdaJ8shH0nWDS7R3OdBecGsJQQI2+fzcf+Zr0b34r3IbsydpT9ZZMjR05p4rq/OfYiiOwcEylCwn1kOohDTKXl2E0WdG+TwfHu0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730707510; c=relaxed/simple; bh=vVrFD+mYj8KaLwn71l4y1PgIZG/YTtZWZ4x8ILga3K4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=gwEQDUPo/SggrzP+N8knlVB3PqFhW6146NrIjkTWtr1b0TNAHrqoVL4sGV9sIQzatWcQs82pNQ5e34Um6ZRGcgFuxMxb0EGwFp4rwMLA5GDZ04s7zl2UREZhrY9+HJI/Z4Vi5vZVsNmeDBb5rTiMYFsaytE5brqvaXXqFZb87H4= 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=ZYu8t/su; arc=fail smtp.client-ip=185.183.29.33 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="ZYu8t/su" X-Virus-Scanned: Proofpoint Essentials engine Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1-eu1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 8EB1E200059; Mon, 4 Nov 2024 08:05:00 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AvBJA03RaKe5KIx7dAmLc7JrjKzkHUB/cG5K1qyFIHPjwinyMEAs5d60yYE/BewKc+ktLnvKxHcc+AiL7zhbQ5GP+xY6XKeaX8WiCGwacks1ENScSGlOxnPq75QOEy+nN6pGxFPR0bhtfqI897vTQ5dlmCa1Gpy/GWpaP+GqnxFAqpVSTxobrOzdixY6LtZNgDqxH64grRXgcDvQEw6EolTJ3l6jKV82DFVM7g2fmBx+oQ/Bx+sUyq77T0/R8Es5WfiDA84SnPNKfxp65mCe8cXYZftHgVt8cPMcGrX4NcwO4EYSRo77/V8RTEUQUTXEPCrG7ISKfeFfB5JKoMYBIw== 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=ZbgFucxQvEkfPX3c4BS+jKyeG6S9cBJLgvhxhFnned4=; b=v5o+56qKYgQrYiQK4liwovnCggOQkztvfBDbYKJCgHpmCgBcAEGHptlSovRKxU27WapgOMwfdWlE6+/8HepSfYL41QcDXPsuyFtKAg7M4a3LCAujn3Pd2nMX0Q8Jzj55MpJDHqTHtDuhr1XJXuzGXR/2WQro9Fry5QHMMAOAKsetYjXWlYeJA7XMT1WcLJEmGpffQtj9RuVrVUMhfiMVbOzYzKP8AEcBmtm7aNdHptB6a7szOjW8HT88hQO3VXkUI+VsD5iEQqRwgZoxPpKvGMmQC0b1WzlftVBm7UulP91mTUriEnzNBpsTk9at6Z2Z7eGDBtdV7mlWSTWexouuag== 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=ZbgFucxQvEkfPX3c4BS+jKyeG6S9cBJLgvhxhFnned4=; b=ZYu8t/su4CCOxg5ZzwNaisHqHPNsnB42xZHm70NiNYq61okIrzSoV1KZKLL1ZMZwqthFrrtPSAFAXiyhIBpQSt6kdyhZ8QXt8dg/4aUdaYnDJ0vCrFpMxK0yryL0UfL1MeukjWDPDStmOdZ9XC1KqgSFlJjn7kUFyk6wAhKdX2c= 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 AM8PR08MB5553.eurprd08.prod.outlook.com (2603:10a6:20b:1da::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Mon, 4 Nov 2024 08:04:59 +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.8114.028; Mon, 4 Nov 2024 08:04:59 +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 v8 4/6] neighbour: Convert iteration to use hlist+macro Date: Mon, 4 Nov 2024 08:04:32 +0000 Message-ID: <20241104080437.103-5-gnaaman@drivenets.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241104080437.103-1-gnaaman@drivenets.com> References: <20241104080437.103-1-gnaaman@drivenets.com> X-ClientProxiedBy: LO4P123CA0206.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a5::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_|AM8PR08MB5553:EE_ X-MS-Office365-Filtering-Correlation-Id: ce8a3e5d-5af4-4d71-8242-08dcfca7609d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: h3MEMcyCIqHyZRFikKudxShbJ8lJUf264ooy73vsOF//N9fAnGJHmropQXKLKTQs3bjsHk5jZ3d2jRqiXgM8VFRkoSylHlByVnXOF0MEVX5TcaZ/wT9H2YoLE/9YWfN0gl2mDcILsRuoHoIMueZLE+wdteVWPmh2L3Eduwmi2oXZek8ZTgrvjidiay9CHppu3sSDdW5B7Mi7lNI8S1/faDQGbu8+GwSo7Brd6h08+2XvJJCv1UY222XK9dqJ51fsb4S6xPudFFvHmG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xMIRxHd3qj5urGwtDx5sKfg3mVarbI8= 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)(1800799024)(376014)(366016)(52116014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j45KtvoJ1UKZVP5+3dUxzWwxW42XXbsfUiqPzzmG7O6R0A4Zbt459ogCIdqLMgTKu1GZtqNFscOs1ZBVyWcq09qilL8AqTC1hFjcx+HxLbX2BjHDb7JwpjHF3BN/PYLW1lFeFnrFrwgz/rIshtjrVqUrWZMT90JLEmBSiVAp/KYMUcO+CjOnJxyMTGbQbQdp3Ny+pIt1B+5N8x3kF2YVCxbjBxVTuWtsJ7E1UxYVun8UWXmevajVu+C/xVa2vcDAURC7Gc2FEvSBz+ETnfshH24aGMxZUcbQkSoHGAXljp4g/QFV8+r2OZYVlPkVXJ54/Ej/L7OwzNLxap7jup83FlOvvPew5xNq6IQ1SXulX0GKW0OpOlwhyS7sl5RTCwICHchk5b3iKKvDS3tkFCADx3hYYkbOsKlzhQMFpdUEZ8xP08yKQCQ2z0DNlqwsfWyV1JOE857uqwi6LYD4++7retqS0hikFy2+jJhcBXac5NeoRtKsANkwgYf2RpwB5v3zqecRJnAPAZhWnZZwdnjK74Q6uer4XbT3PCdBLwGGI/gi/0IqYrii7Rsa0v4qTOfUVTZkeCa2VAMWYEBePpZC+M4nyjMMWRaYBhx4yI+R8NpSGztvarhJgV9sOcjGjKtlnNYsZhEFLDxZpLMfW95zWFP/2tdLBnThOYEAgxmg9V2QV+vLdXWNdIzYn21fpOYbSRLQAhl4t5Htt/gv42949m/kfexWgll2CkDP8qzWJiTx9SsyK6li4cylVWfIvH0mw6dAKxCUMkNRcwF2ym9z+rt9em0kt8l+KQg65js+nJSbXnnr/fYSJR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SKCAUKRMyD0nulkQHfGY1WrZu4pcSdn/aXKgAUcp2qBVQivG0WUvwVYJ1NKZMVHlp4vwKmc3y/3qhGpeGiVa+NzGGZkncsmjAZfxteALaWFXu+VBHg3KhAbfS/2eVsfXhqbv/6F7elC8XMhz8+n7QhFa4t5bSbuYJ633KCOhjG8YIjY73j/u02kst6mz3ZEVxkyuqijgIiaGE69NS2D1fE4T/WJxxPChUTA2BbT8H0URhA/k6n6OULwE898z5oh6eEaD1RWd+22X9bkM4q40P6lHPN2IrUe73TpOxc/C3tkly/YPKseOntqZUefcusf0LjY6MtWdpdt/A2DyRut5VhPIvmSY+xql+oWoI9zSbB1+TwRDhx4+m31/upQXVVkbCj3WozW+B1ziTbrZxNBtfesfnrxqYv45h0EwPTBiFPMrX X-OriginatorOrg: drivenets.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce8a3e5d-5af4-4d71-8242-08dcfca7609d X-MS-Exchange-CrossTenant-AuthSource: DB8PR08MB5388.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2024 08:04:59.1943 (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: v/TMbZ/1lm8b2AW8Cy05t4km2Ic0hJaf3M4Po50OzGBlMdmYXRU72si4rlAJ8sZCLNq5w7zOzXFyetHiPkNgWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5553 X-MDID: 1730707501-bVQLl_P179bN X-MDID-O: eu1;ams;1730707501;bVQLl_P179bN;;495c1e7a27a6c3e35a5fabc922783896 X-PPE-TRUSTED: V=1;DIR=OUT; X-Patchwork-Delegate: kuba@kernel.org Remove all usage of the bare neighbour::next pointer, replacing them with neighbour::hash and its for_each macro. Signed-off-by: Gilad Naaman Reviewed-by: Kuniyuki Iwashima --- include/net/neighbour.h | 5 +---- net/core/neighbour.c | 47 ++++++++++++++++------------------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 69aaacd1419f..68b1970d9045 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -309,12 +309,9 @@ static inline struct neighbour *___neigh_lookup_noref( u32 hash_val; hash_val = hash(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift); - for (n = rcu_dereference(nht->hash_buckets[hash_val]); - n != NULL; - n = rcu_dereference(n->next)) { + neigh_for_each_in_bucket(n, &nht->hash_heads[hash_val]) if (n->dev == dev && key_eq(n, pkey)) return n; - } return NULL; } diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 3485d6b3ba99..f7119380d983 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -387,11 +387,11 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev, lockdep_is_held(&tbl->lock)); for (i = 0; i < (1 << nht->hash_shift); i++) { - struct neighbour *n; struct neighbour __rcu **np = &nht->hash_buckets[i]; + struct hlist_node *tmp; + struct neighbour *n; - while ((n = rcu_dereference_protected(*np, - lockdep_is_held(&tbl->lock))) != NULL) { + neigh_for_each_in_bucket_safe(n, tmp, &nht->hash_heads[i]) { if (dev && n->dev != dev) { np = &n->next; continue; @@ -587,18 +587,14 @@ static struct neigh_hash_table *neigh_hash_grow(struct neigh_table *tbl, return old_nht; for (i = 0; i < (1 << old_nht->hash_shift); i++) { - struct neighbour *n, *next; + struct hlist_node *tmp; + struct neighbour *n; - for (n = rcu_dereference_protected(old_nht->hash_buckets[i], - lockdep_is_held(&tbl->lock)); - n != NULL; - n = next) { + neigh_for_each_in_bucket_safe(n, tmp, &old_nht->hash_heads[i]) { hash = tbl->hash(n->primary_key, n->dev, new_nht->hash_rnd); hash >>= (32 - new_nht->hash_shift); - next = rcu_dereference_protected(n->next, - lockdep_is_held(&tbl->lock)); rcu_assign_pointer(n->next, rcu_dereference_protected( @@ -693,11 +689,7 @@ ___neigh_create(struct neigh_table *tbl, const void *pkey, goto out_tbl_unlock; } - for (n1 = rcu_dereference_protected(nht->hash_buckets[hash_val], - lockdep_is_held(&tbl->lock)); - n1 != NULL; - n1 = rcu_dereference_protected(n1->next, - lockdep_is_held(&tbl->lock))) { + neigh_for_each_in_bucket(n1, &nht->hash_heads[hash_val]) { if (dev == n1->dev && !memcmp(n1->primary_key, n->primary_key, key_len)) { if (want_ref) neigh_hold(n1); @@ -949,10 +941,11 @@ static void neigh_connect(struct neighbour *neigh) static void neigh_periodic_work(struct work_struct *work) { struct neigh_table *tbl = container_of(work, struct neigh_table, gc_work.work); - struct neighbour *n; + struct neigh_hash_table *nht; struct neighbour __rcu **np; + struct hlist_node *tmp; + struct neighbour *n; unsigned int i; - struct neigh_hash_table *nht; NEIGH_CACHE_STAT_INC(tbl, periodic_gc_runs); @@ -979,8 +972,7 @@ static void neigh_periodic_work(struct work_struct *work) for (i = 0 ; i < (1 << nht->hash_shift); i++) { np = &nht->hash_buckets[i]; - while ((n = rcu_dereference_protected(*np, - lockdep_is_held(&tbl->lock))) != NULL) { + neigh_for_each_in_bucket_safe(n, tmp, &nht->hash_heads[i]) { unsigned int state; write_lock(&n->lock); @@ -2730,9 +2722,8 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, for (h = s_h; h < (1 << nht->hash_shift); h++) { if (h > s_h) s_idx = 0; - for (n = rcu_dereference(nht->hash_buckets[h]), idx = 0; - n != NULL; - n = rcu_dereference(n->next)) { + idx = 0; + neigh_for_each_in_bucket(n, &nht->hash_heads[h]) { if (idx < s_idx || !net_eq(dev_net(n->dev), net)) goto next; if (neigh_ifindex_filtered(n->dev, filter->dev_idx) || @@ -3099,9 +3090,7 @@ void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void for (chain = 0; chain < (1 << nht->hash_shift); chain++) { struct neighbour *n; - for (n = rcu_dereference(nht->hash_buckets[chain]); - n != NULL; - n = rcu_dereference(n->next)) + neigh_for_each_in_bucket(n, &nht->hash_heads[chain]) cb(n, cookie); } read_unlock_bh(&tbl->lock); @@ -3113,18 +3102,18 @@ EXPORT_SYMBOL(neigh_for_each); void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct neighbour *)) { - int chain; struct neigh_hash_table *nht; + int chain; nht = rcu_dereference_protected(tbl->nht, lockdep_is_held(&tbl->lock)); for (chain = 0; chain < (1 << nht->hash_shift); chain++) { - struct neighbour *n; struct neighbour __rcu **np; + struct hlist_node *tmp; + struct neighbour *n; np = &nht->hash_buckets[chain]; - while ((n = rcu_dereference_protected(*np, - lockdep_is_held(&tbl->lock))) != NULL) { + neigh_for_each_in_bucket_safe(n, tmp, &nht->hash_heads[chain]) { int release; write_lock(&n->lock);