From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <gnaaman@drivenets.com>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
<kuniyu@amazon.com>, <netdev@vger.kernel.org>,
<pabeni@redhat.com>
Subject: Re: [PATCH net-next v2 1/2] Convert neighbour-table to use hlist
Date: Tue, 8 Oct 2024 07:53:10 -0700 [thread overview]
Message-ID: <20241008145310.85530-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20241008073855.811502-1-gnaaman@drivenets.com>
From: Gilad Naaman <gnaaman@drivenets.com>
Date: Tue, 8 Oct 2024 07:38:55 +0000
> > > @@ -388,21 +366,20 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev,
> > >
> > > for (i = 0; i < (1 << nht->hash_shift); i++) {
> > > struct neighbour *n;
> > > - struct neighbour __rcu **np = &nht->hash_buckets[i];
> > > + struct neighbour __rcu **np =
> > > + (struct neighbour __rcu **)&nht->hash_buckets[i].first;
> >
> > This will be no longer needed for doubly linked list,
>
> This is not as-necessary with a doubly-linked list, but unfortunately
> I cannot eliminate it completely, as the `n` might be released in the loop
> body.
>
> I can convert this function to use a `struct neighour *next` instead,
> if it is more palatable.
Yes, using hlist_for_each_entry_safe() is more preferable.
Mixing for() and while() is harder to read.
[...]
> > > @@ -693,11 +666,10 @@ ___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))) {
> > > + hlist_for_each_entry_rcu(n1,
> > > + &nht->hash_buckets[hash_val],
> > > + list,
> > > + lockdep_is_held(&tbl->lock)) {
> >
> > Let's define hlist_for_each_entry_rcu() as neigh-specific macro.
>
> Can you elaborate on this?
> Do you want the `list` parameter to be eliminated?
I mean like
#define neigh_for_each(...) \
hlist_for_each_entry(...)
#define neigh_for_each_rcu(...) \
hlist_for_each_entry_rcu(...)
are better if there's repeated arguments.
next prev parent reply other threads:[~2024-10-08 14:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-06 6:47 [PATCH net-next v2 0/2] Improve neigh_flush_dev performance Gilad Naaman
2024-10-06 6:47 ` [PATCH net-next v2 1/2] Convert neighbour-table to use hlist Gilad Naaman
2024-10-06 15:52 ` Kuniyuki Iwashima
2024-10-08 7:38 ` Gilad Naaman
2024-10-08 14:53 ` Kuniyuki Iwashima [this message]
2024-10-06 15:56 ` Kuniyuki Iwashima
2024-10-09 13:52 ` kernel test robot
2024-10-06 6:47 ` [PATCH net-next v2 2/2] Create netdev->neighbour association Gilad Naaman
2024-10-09 6:03 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241008145310.85530-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gnaaman@drivenets.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.