Re: [PATCH net v3] net: Use a dedicated flag to track disabled napi instances
From: Daniel Machon
Date: Mon Oct 26 2026 - 07:00:49 EST
Hi Maxime,
> Trying to disable the napi threaded state while the napi instance is
> disabled will hang forever in napi_stop_kthread(), as it waits for
> NAPIF_STATE_SCHED_THREADED to clear.
>
> This won't happen until the next ____napi_schedule() call, which won't
> happen as it's disabled.
>
> This happens in 2 instances :
>
> - Drivers that create but don't use napi instances (stmmac's rxtx napi
> for AF_XDP for example), here it's a driver bug
>
> - Drivers that create their napi instances in .probe(). Here, setting
> threaded off while the interface is down will hang :
>
> ip link set eth0 down
> echo 1 > /sys/class/net/eth0/threaded
> echo 0 > /sys/class/net/eth0/threaded
> -> hang
>
> Checking on netif_running() isn't enough, as napi instances may be
> transiently disabled when changing the MTU for example, let's use a
> dedicated flag to track if the instance is disabled.
>
> This allows immediately disabling the kthread when the instance is
> disabled.
>
> This was tested on mvpp2 (probe-time napi_add) and stmmac.
I could reproduce the hang on lan966x by toggling /sys/class/net/<if>/threaded
while changing the MTU, which disables and re-enables the NAPI around an FDMA
reload. Without this patch it deadlocks within a few iterations. With it
applied, the same test ran clean.
> Fixes: 689883de94dd ("net: stop napi kthreads when THREADED napi is disabled")
> Signed-off-by: Maxime Chevallier <maxime.chevallier@xxxxxxxxxxx>
Tested-by: Daniel Machon <daniel.machon@xxxxxxxxxxxxx>