[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241015233851.68607-1-kuniyu@amazon.com>
Date: Tue, 15 Oct 2024 16:38:51 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <gnaaman@...venets.com>
CC: <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<kuniyu@...zon.com>, <netdev@...r.kernel.org>, <pabeni@...hat.com>
Subject: Re: [PATCH net-next v4 4/6] Convert neighbour iteration to use hlist+macro
From: Gilad Naaman <gnaaman@...venets.com>
Date: Tue, 15 Oct 2024 16:59:24 +0000
> diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> index 4bdf7649ca57..cca524a55c97 100644
> --- a/net/core/neighbour.c
> +++ b/net/core/neighbour.c
> @@ -391,8 +391,7 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev,
> struct neighbour *n;
> struct neighbour __rcu **np = &nht->hash_buckets[i];
>
> - while ((n = rcu_dereference_protected(*np,
> - lockdep_is_held(&tbl->lock))) != NULL) {
> + neigh_for_each(n, &nht->hash_heads[i]) {
> if (dev && n->dev != dev) {
> np = &n->next;
> continue;
> @@ -427,6 +426,7 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev,
> n->nud_state = NUD_NONE;
> neigh_dbg(2, "neigh %p is stray\n", n);
> }
> + np = &n->next;
> write_unlock(&n->lock);
> neigh_cleanup_and_release(n);
> }
Is this chunk necessary ?
> @@ -976,6 +970,7 @@ 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 hlist_node *tmp;
> struct neighbour __rcu **np;
> unsigned int i;
> struct neigh_hash_table *nht;
nit: let's sort variables in reverse xmas tree order.
> @@ -3124,11 +3117,11 @@ void __neigh_for_each_release(struct neigh_table *tbl,
> lockdep_is_held(&tbl->lock));
> for (chain = 0; chain < (1 << nht->hash_shift); chain++) {
> struct neighbour *n;
> + struct hlist_node *tmp;
> struct neighbour __rcu **np;
nit: reverse xmas tree order.
>
> np = &nht->hash_buckets[chain];
> - while ((n = rcu_dereference_protected(*np,
> - lockdep_is_held(&tbl->lock))) != NULL) {
> + neigh_for_each_safe(n, tmp, &nht->hash_heads[chain]) {
> int release;
>
> write_lock(&n->lock);
> --
> 2.46.0
Powered by blists - more mailing lists