From: Kuniyuki Iwashima <kuniyu@google.com>
To: paritoshpotukuchi@gmail.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
jv@jvosburgh.net, kuba@kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, pabeni@redhat.com,
paritosh.potukuchi@amd.com
Subject: Re: [PATCH v2 2/2] bonding: reuse neigh_setup from slave neigh_parms
Date: Fri, 3 Jul 2026 06:38:52 +0000 [thread overview]
Message-ID: <20260703064109.1836070-1-kuniyu@google.com> (raw)
In-Reply-To: <20260701081602.3185086-3-paritosh.potukuchi@amd.com>
From: Paritosh Potukuchi <paritoshpotukuchi@gmail.com>
Date: Wed, 1 Jul 2026 08:16:00 +0000
> bond_neigh_init() currently relies on the slave device's
> ndo_neigh_setup() callback to obtain a neigh_setup() handler.
>
> When an initialized neigh_parms instance already exists for the
> slave device, reuse the neigh_setup() callback stored in it instead
> of invoking ndo_neigh_setup() again.
>
> If no neigh_parms instance is found, or no neigh_setup() callback is
> present, retain the existing ndo_neigh_setup() fallback path.
>
> This avoids unnecessary ndo_neigh_setup() invocations while preserving
> existing behaviour.
>
> Signed-off-by: Paritosh Potukuchi <paritosh.potukuchi@amd.com>
> ---
> drivers/net/bonding/bond_main.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index e044fc733b8c..d2e4dae4e97c 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -4719,7 +4719,7 @@ static int bond_neigh_init(struct neighbour *n)
> {
> struct bonding *bond = netdev_priv(n->dev);
> const struct net_device_ops *slave_ops;
> - struct neigh_parms parms;
> + struct neigh_parms parms, *p;
> struct slave *slave;
> int ret = 0;
>
> @@ -4727,6 +4727,14 @@ static int bond_neigh_init(struct neighbour *n)
> slave = bond_first_slave_rcu(bond);
> if (!slave)
> goto out;
> +
> + p = neigh_parms_lookup_dev(n->tbl, slave->dev);
This introduces O(n) list traversal while it can be done
with fixed costs (3 dereferences + 1 call).
Since neigh_table is global (arp_tbl or nd_tbl), the O(n)
list traversal could take longer and rather de-optimise.
> +
> + if (p && p->neigh_setup) {
> + ret = p->neigh_setup(n);
> + goto out;
> + }
> +
> slave_ops = slave->dev->netdev_ops;
> if (!slave_ops->ndo_neigh_setup)
> goto out;
> --
> 2.43.0
next prev parent reply other threads:[~2026-07-03 6:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 8:15 [PATCH v2 0/2] Add and use neigh_parms_lookup_dev() Paritosh Potukuchi
2026-07-01 8:15 ` [PATCH v2 1/2] net: neighbour: add neigh_parms_lookup_dev() helper Paritosh Potukuchi
2026-07-01 8:16 ` [PATCH v2 2/2] bonding: reuse neigh_setup from slave neigh_parms Paritosh Potukuchi
2026-07-03 6:38 ` Kuniyuki Iwashima [this message]
2026-07-03 9:47 ` Paritosh Potukuchi
2026-07-04 1:43 ` Kuniyuki Iwashima
2026-07-06 10:07 ` Paritosh Potukuchi
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=20260703064109.1836070-1-kuniyu@google.com \
--to=kuniyu@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jv@jvosburgh.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paritosh.potukuchi@amd.com \
--cc=paritoshpotukuchi@gmail.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.