Re: [BUG] virtio_net: RX stall caused by masking callbacks after NAPI ownership release

From: Congjie Zhou

Date: Thu Nov 19 2026 - 11:33:17 EST


> Right. So I came up with this then. Pls note i could not repro the
> problem so I am merely reasoning based on theoretical understanding
> of it.
>
> --->
>
> virtio_net: mask callbacks before handing off NAPI ownership
>
> Virtio is special in that enabling or disabling callbacks (interrupts)
> accesses shared virtqueue state and must be serialized with polling. It
> therefore enables callbacks before completing NAPI, and disables them
> again if completion returns false.
>
> With napi_complete_done(), that false return can come after ownership has
> passed to another poll. The first poll can then disable callbacks after
> its successor has enabled them, leaving RX stalled. Virtio therefore
> needs to disable callbacks before handing off NAPI ownership.
>
> Add a prepare/finish NAPI completion API so virtio-net can mask interrupts
> before handing ownership off.
>
> This preserves interrupt suppression without a callback or an additional
> data-path barrier. Ordinary napi_complete_done() compiles identically in
> the tested configuration.
>
> Tested on x86-64 KVM with lock debugging, including IRQ deferral, concurrent
> scheduling, busy polling, netpoll, and threaded NAPI. Split and packed
> virtqueue TCP RX tests with IRQ deferral and busy polling also passed.
>
> Reported-by: Congjie Zhou <zcjie0802@xxxxxx>
> Closes: https://lore.kernel.org/netdev/tencent_D0650F8CA2AAE4C258BFE5BCE805CDB4CA0A@xxxxxx/
> Fixes: 6f8b12d661d0 ("net: napi: add hard irqs deferral feature")
> Assisted-by: LLM

I've tested this patch locally , and everything looks good now, the issue is gone.