[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iKstzu3O2eD1OAhR=Vc1EVyesg14DAp0P42i8juJuH_gA@mail.gmail.com>
Date: Tue, 4 Feb 2025 06:24:49 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: davem@...emloft.net, netdev@...r.kernel.org, pabeni@...hat.com,
andrew+netdev@...n.ch, horms@...nel.org
Subject: Re: [PATCH net-next] net: warn if NAPI instance wasn't shut down
On Mon, Feb 3, 2025 at 10:58 PM Jakub Kicinski <kuba@...nel.org> wrote:
>
> Drivers should always disable a NAPI instance before removing it.
> If they don't the instance may be queued for polling.
> Since commit 86e25f40aa1e ("net: napi: Add napi_config")
> we also remove the NAPI from the busy polling hash table
> in napi_disable(), so not disabling would leave a stale
> entry there.
>
> Use of busy polling is relatively uncommon so bugs may be lurking
> in the drivers. Add an explicit warning.
>
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
> net/core/dev.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index c0021cbd28fc..2b141f20b13b 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -7071,6 +7071,9 @@ void __netif_napi_del_locked(struct napi_struct *napi)
> if (!test_and_clear_bit(NAPI_STATE_LISTED, &napi->state))
> return;
>
> + /* Make sure NAPI is disabled (or was never enabled). */
> + WARN_ON(!test_bit(NAPI_STATE_SCHED, &napi->state));
> +
> if (napi->config) {
> napi->index = -1;
> napi->config = NULL;
> --
> 2.48.1
>
This makes sense. Although a WARN_ON_ONCE() might avoid some noise.
Reviewed-by: Eric Dumazet <edumazet@...gle.com>
Powered by blists - more mailing lists