public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: sdf.kernel@gmail.com
To: Jakub Kicinski <kuba@kernel.org>
Cc: Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, jiri@resnulli.us, jv@jvosburgh.net
Subject: Re: [PATCH net-next v5 01/14] net: add address list snapshot and reconciliation infrastructure (123ac7a76378)
Date: Mon, 06 Apr 2026 15:29:20 -0700	[thread overview]
Message-ID: <d6fb496a84ec3809eaa6c417132d5e2d.sdf.kernel@gmail.com> (raw)
In-Reply-To: <20260404000602.2413848-1-kuba@kernel.org>

> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> ---
>     net: add address list snapshot and reconciliation infrastructure
> 
> This commit introduces address list snapshot and reconciliation routines
> to support the async rx_mode path. It provides functions to snapshot the
> lists, and to reconcile the hardware sync state back to the original lists
> after driver processing.
> 
> > diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
> > --- a/net/core/dev_addr_lists.c
> > +++ b/net/core/dev_addr_lists.c
> [ ... ]
> > @@ -501,6 +503,114 @@ void __hw_addr_init(struct netdev_hw_addr_list *list)
> [ ... ]
> > +void __hw_addr_list_reconcile(struct netdev_hw_addr_list *real_list,
> > +			      struct netdev_hw_addr_list *work,
> > +			      struct netdev_hw_addr_list *ref, int addr_len)
> > +{
> [ ... ]
> > +		real_ha = __hw_addr_lookup(real_list, ref_ha->addr, addr_len,
> > +					   ref_ha->type);
> > +		if (!real_ha) {
> > +			/* The real entry was concurrently removed. If the
> > +			 * driver synced this addr to hardware (delta > 0),
> > +			 * re-insert it as a stale entry so the next work
> > +			 * run unsyncs it from hardware.
> > +			 */
> > +			if (delta > 0) {
> > +				real_ha = __hw_addr_create(ref_ha->addr,
> > +							   addr_len,
> > +							   ref_ha->type, false,
> > +							   false);
> 
> Does this code silently leak a hardware MAC filter if the GFP_ATOMIC allocation
> fails? If the software loses track of this address, it appears future sync runs
> will never unsync it from the hardware.
>
> Could this failure be avoided by unlinking ref_ha from the ref list (which is
> about to be unconditionally freed via __hw_addr_flush) and moving it directly
> into real_list?

Will unlink the ref_ha from ref list and relink, that should work.

> 
> > +				if (real_ha) {
> > +					real_ha->sync_cnt = 1;
> > +					real_ha->refcount = 1;
> 
> Does this code break compatibility with reference-counted sync APIs?
>
> While __hw_addr_sync_dev() increments by 1, drivers processing snapshots with
> __hw_addr_ref_sync_dev() might increment sync_cnt by the total number of
> references. If such an entry is concurrently removed, recreation with a
> hardcoded value of 1 could instruct the next async run to unsync only 1
> reference, permanently leaking the remaining hardware references.
>
> Should these be dynamically initialized to real_ha->sync_cnt = delta and
> real_ha->refcount = delta?

Idk, I did convince myself that the delta can be only 1 here and felt
like it's easier to follow, but will switch to sync_cnt=delta.

> 
> > +					list_add_tail_rcu(&real_ha->list,
> > +							  &real_list->list);
> > +					__hw_addr_insert(real_list, real_ha,
> > +							 addr_len);
> > +					real_list->count++;
> > +				}
> > +			}
> > +			continue;
> > +		}
> [ ... ]
> > diff --git a/net/core/dev_addr_lists_test.c b/net/core/dev_addr_lists_test.c
> > --- a/net/core/dev_addr_lists_test.c
> > +++ b/net/core/dev_addr_lists_test.c
> [ ... ]
> > @@ -225,6 +245,339 @@ static void dev_addr_test_add_excl(struct kunit *test)
> [ ... ]
> > +static void dev_addr_test_snapshot_sync(struct kunit *test)
> > +{
> [ ... ]
> > +	netif_addr_lock_bh(netdev);
> > +	__hw_addr_init(&snap);
> > +	__hw_addr_init(&ref);
> > +	KUNIT_ASSERT_EQ(test, 0,
> > +			__hw_addr_list_snapshot(&snap, &netdev->uc, ETH_ALEN));
> > +	KUNIT_ASSERT_EQ(test, 0,
> > +			__hw_addr_list_snapshot(&ref, &netdev->uc, ETH_ALEN));
> > +	netif_addr_unlock_bh(netdev);
> 
> Will this cause a system deadlock if the assertion fails?
>
> If KUNIT_ASSERT_EQ triggers (e.g. from an out-of-memory condition in
> __hw_addr_list_snapshot), it immediately aborts the test case thread and skips
> the rest of the function, leaving the netif_addr_lock_bh spinlock permanently
> held and bottom-halves disabled.
>
> Could this be replaced with KUNIT_EXPECT_EQ and explicit goto error handling
> to ensure netif_addr_unlock_bh is always reached?

Will do.

> 
> [ ... ]
> > +static void dev_addr_test_snapshot_benchmark(struct kunit *test)
> > +{
> [ ... ]
> > +	for (iter = 0; iter < 1000; iter++) {
> > +		netif_addr_lock_bh(netdev);
> > +		__hw_addr_init(&snap);
> > +
> > +		start = ktime_get();
> > +		KUNIT_ASSERT_EQ(test, 0,
> > +				__hw_addr_list_snapshot(&snap, &netdev->uc,
> > +							ETH_ALEN));
> > +		duration += ktime_to_ns(ktime_sub(ktime_get(), start));
> > +
> > +		netif_addr_unlock_bh(netdev);
> 
> Will this also cause a deadlock if the assertion fails while the lock is held?

Same here, will do.

  reply	other threads:[~2026-04-06 22:29 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02 22:55 [PATCH net-next v5 00/14] net: sleepable ndo_set_rx_mode Stanislav Fomichev
2026-04-02 22:55 ` [PATCH net-next v5 01/14] net: add address list snapshot and reconciliation infrastructure Stanislav Fomichev
2026-04-04  0:06   ` Jakub Kicinski
2026-04-06 22:29     ` sdf.kernel [this message]
2026-04-02 22:55 ` [PATCH net-next v5 02/14] net: introduce ndo_set_rx_mode_async and netdev_rx_mode_work Stanislav Fomichev
2026-04-04  0:06   ` Jakub Kicinski
2026-04-06 22:29     ` [PATCH net-next v5 02/14] net: introduce ndo_set_rx_mode_async and netdev_rx_mode_work (61d75e67dcd2) sdf.kernel
2026-04-04  0:27   ` [PATCH net-next v5 02/14] net: introduce ndo_set_rx_mode_async and netdev_rx_mode_work Jakub Kicinski
2026-04-06 22:29     ` [PATCH net-next v5 02/14] net: introduce ndo_set_rx_mode_async and netdev_rx_mode_work (61d75e67dcd2) sdf.kernel
2026-04-02 22:55 ` [PATCH net-next v5 03/14] net: move promiscuity handling into netdev_rx_mode_work Stanislav Fomichev
2026-04-04  0:06   ` Jakub Kicinski
2026-04-06 22:29     ` [PATCH net-next v5 03/14] net: move promiscuity handling into netdev_rx_mode_work (ddeab417d841) sdf.kernel
2026-04-02 22:55 ` [PATCH net-next v5 04/14] net: cache snapshot entries for ndo_set_rx_mode_async Stanislav Fomichev
2026-04-02 22:55 ` [PATCH net-next v5 05/14] fbnic: convert to ndo_set_rx_mode_async Stanislav Fomichev
2026-04-04  0:06   ` Jakub Kicinski
2026-04-06 22:29     ` [PATCH net-next v5 05/14] fbnic: convert to ndo_set_rx_mode_async (1d5e76c60ed0) sdf.kernel
2026-04-02 22:55 ` [PATCH net-next v5 06/14] mlx5: convert to ndo_set_rx_mode_async Stanislav Fomichev
2026-04-04  0:06   ` Jakub Kicinski
2026-04-06 22:29     ` [PATCH net-next v5 06/14] mlx5: convert to ndo_set_rx_mode_async (3691f90f6593) sdf.kernel
2026-04-02 22:55 ` [PATCH net-next v5 07/14] bnxt: convert to ndo_set_rx_mode_async Stanislav Fomichev
2026-04-04  0:06   ` Jakub Kicinski
2026-04-06 22:29     ` [PATCH net-next v5 07/14] bnxt: convert to ndo_set_rx_mode_async (c1776bbe53ec) sdf.kernel
2026-04-02 22:55 ` [PATCH net-next v5 08/14] bnxt: use snapshot in bnxt_cfg_rx_mode Stanislav Fomichev
2026-04-04  0:06   ` Jakub Kicinski
2026-04-06 22:29     ` [PATCH net-next v5 08/14] bnxt: use snapshot in bnxt_cfg_rx_mode (74e346419df6) sdf.kernel
2026-04-02 22:55 ` [PATCH net-next v5 09/14] iavf: convert to ndo_set_rx_mode_async Stanislav Fomichev
2026-04-04  0:06   ` Jakub Kicinski
2026-04-06 22:29     ` [PATCH net-next v5 09/14] iavf: convert to ndo_set_rx_mode_async (b1dc10d5dff2) sdf.kernel
2026-04-02 22:55 ` [PATCH net-next v5 10/14] netdevsim: convert to ndo_set_rx_mode_async Stanislav Fomichev
2026-04-02 22:55 ` [PATCH net-next v5 11/14] dummy: " Stanislav Fomichev
2026-04-02 22:55 ` [PATCH net-next v5 12/14] net: warn ops-locked drivers still using ndo_set_rx_mode Stanislav Fomichev
2026-04-02 22:55 ` [PATCH net-next v5 13/14] selftests: net: add team_bridge_macvlan rx_mode test Stanislav Fomichev
2026-04-02 22:55 ` [PATCH net-next v5 14/14] selftests: net: use ip commands instead of teamd in team " Stanislav Fomichev

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=d6fb496a84ec3809eaa6c417132d5e2d.sdf.kernel@gmail.com \
    --to=sdf.kernel@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiri@resnulli.us \
    --cc=jv@jvosburgh.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox