* [PATCH v2] virtio_net: disable cb when NAPI is busy-polled
@ 2026-06-23 9:19 Longjun Tang
2026-06-23 9:55 ` Eric Dumazet
2026-06-23 10:10 ` Michael S. Tsirkin
0 siblings, 2 replies; 4+ messages in thread
From: Longjun Tang @ 2026-06-23 9:19 UTC (permalink / raw)
To: mst, xuanzhuo; +Cc: jasowang, edumazet, virtualization, tanglongjun, lange_tang
From: Longjun Tang <tanglongjun@kylinos.cn>
When busy-poll is active, napi_schedule_prep() returns false in
virtqueue_napi_schedule(), so virtqueue_disable_cb() is skipped.
The device may keep firing irqs until reaches virtqueue_napi_complete().
Under load (received == budget), it will lead to a large number
of spurious interrupts.
Fix it by disabling the callback at the virtnet_poll() entry. This keeps
the callback off while we poll and re-enable by virtqueue_napi_complete()
when going idle.
Signed-off-by: Longjun Tang <tanglongjun@kylinos.cn>
---
V1 -> V2: Remain agnostic to busy polling
---
drivers/net/virtio_net.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index f4adcfee7a80..0a11f2b32500 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -3008,6 +3008,11 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
unsigned int xdp_xmit = 0;
bool napi_complete;
+ /* Keep callbacks suppressed for the duration of this poll,
+ * busy-poll need.
+ */
+ virtqueue_disable_cb(rq->vq);
+
virtnet_poll_cleantx(rq, budget);
received = virtnet_receive(rq, budget, &xdp_xmit);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] virtio_net: disable cb when NAPI is busy-polled
2026-06-23 9:19 [PATCH v2] virtio_net: disable cb when NAPI is busy-polled Longjun Tang
@ 2026-06-23 9:55 ` Eric Dumazet
2026-06-23 10:15 ` Michael S. Tsirkin
2026-06-23 10:10 ` Michael S. Tsirkin
1 sibling, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2026-06-23 9:55 UTC (permalink / raw)
To: Longjun Tang, netdev; +Cc: mst, xuanzhuo, jasowang, virtualization, tanglongjun
On Tue, Jun 23, 2026 at 2:19 AM Longjun Tang <lange_tang@163.com> wrote:
>
> From: Longjun Tang <tanglongjun@kylinos.cn>
>
> When busy-poll is active, napi_schedule_prep() returns false in
> virtqueue_napi_schedule(), so virtqueue_disable_cb() is skipped.
> The device may keep firing irqs until reaches virtqueue_napi_complete().
> Under load (received == budget), it will lead to a large number
> of spurious interrupts.
>
> Fix it by disabling the callback at the virtnet_poll() entry. This keeps
> the callback off while we poll and re-enable by virtqueue_napi_complete()
> when going idle.
>
> Signed-off-by: Longjun Tang <tanglongjun@kylinos.cn>
>
I added netdev@ to get more attention from networking napi polling experts,
Please add a Fixes: tag as this will ease code review.
My rough guess is:
Fixes: ceef438d613f ("virtio_net: remove custom busy_poll")
Thanks.
> ---
> V1 -> V2: Remain agnostic to busy polling
> ---
> drivers/net/virtio_net.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index f4adcfee7a80..0a11f2b32500 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -3008,6 +3008,11 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
> unsigned int xdp_xmit = 0;
> bool napi_complete;
>
> + /* Keep callbacks suppressed for the duration of this poll,
> + * busy-poll need.
> + */
> + virtqueue_disable_cb(rq->vq);
> +
> virtnet_poll_cleantx(rq, budget);
>
> received = virtnet_receive(rq, budget, &xdp_xmit);
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] virtio_net: disable cb when NAPI is busy-polled
2026-06-23 9:19 [PATCH v2] virtio_net: disable cb when NAPI is busy-polled Longjun Tang
2026-06-23 9:55 ` Eric Dumazet
@ 2026-06-23 10:10 ` Michael S. Tsirkin
1 sibling, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2026-06-23 10:10 UTC (permalink / raw)
To: Longjun Tang; +Cc: xuanzhuo, jasowang, edumazet, virtualization, tanglongjun
On Tue, Jun 23, 2026 at 05:19:01PM +0800, Longjun Tang wrote:
> From: Longjun Tang <tanglongjun@kylinos.cn>
>
> When busy-poll is active, napi_schedule_prep() returns false in
> virtqueue_napi_schedule(), so virtqueue_disable_cb() is skipped.
> The device may keep firing irqs until reaches virtqueue_napi_complete().
> Under load (received == budget), it will lead to a large number
> of spurious interrupts.
>
> Fix it by disabling the callback at the virtnet_poll() entry. This keeps
> the callback off while we poll and re-enable by virtqueue_napi_complete()
> when going idle.
>
> Signed-off-by: Longjun Tang <tanglongjun@kylinos.cn>
Patch is correct
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Ideally, I like to see performance numbers in such cases, to be included with commit log.
> ---
> V1 -> V2: Remain agnostic to busy polling
> ---
> drivers/net/virtio_net.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index f4adcfee7a80..0a11f2b32500 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -3008,6 +3008,11 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
> unsigned int xdp_xmit = 0;
> bool napi_complete;
>
> + /* Keep callbacks suppressed for the duration of this poll,
> + * busy-poll need.
> + */
> + virtqueue_disable_cb(rq->vq);
> +
> virtnet_poll_cleantx(rq, budget);
>
> received = virtnet_receive(rq, budget, &xdp_xmit);
> --
> 2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] virtio_net: disable cb when NAPI is busy-polled
2026-06-23 9:55 ` Eric Dumazet
@ 2026-06-23 10:15 ` Michael S. Tsirkin
0 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2026-06-23 10:15 UTC (permalink / raw)
To: Eric Dumazet
Cc: Longjun Tang, netdev, xuanzhuo, jasowang, virtualization,
tanglongjun
On Tue, Jun 23, 2026 at 02:55:30AM -0700, Eric Dumazet wrote:
> On Tue, Jun 23, 2026 at 2:19 AM Longjun Tang <lange_tang@163.com> wrote:
> >
> > From: Longjun Tang <tanglongjun@kylinos.cn>
> >
> > When busy-poll is active, napi_schedule_prep() returns false in
> > virtqueue_napi_schedule(), so virtqueue_disable_cb() is skipped.
> > The device may keep firing irqs until reaches virtqueue_napi_complete().
> > Under load (received == budget), it will lead to a large number
> > of spurious interrupts.
> >
> > Fix it by disabling the callback at the virtnet_poll() entry. This keeps
> > the callback off while we poll and re-enable by virtqueue_napi_complete()
> > when going idle.
> >
> > Signed-off-by: Longjun Tang <tanglongjun@kylinos.cn>
> >
>
> I added netdev@ to get more attention from networking napi polling experts,
>
> Please add a Fixes: tag as this will ease code review.
>
> My rough guess is:
>
> Fixes: ceef438d613f ("virtio_net: remove custom busy_poll")
>
> Thanks.
Exactly. The old custom virtnet_busy_poll did napi_schedule_prep + virtqueue_disable_cb itself.
I'd even say CC stable interrupt storms are devastating to performance.
> > ---
> > V1 -> V2: Remain agnostic to busy polling
> > ---
> > drivers/net/virtio_net.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > index f4adcfee7a80..0a11f2b32500 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -3008,6 +3008,11 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
> > unsigned int xdp_xmit = 0;
> > bool napi_complete;
> >
> > + /* Keep callbacks suppressed for the duration of this poll,
> > + * busy-poll need.
> > + */
> > + virtqueue_disable_cb(rq->vq);
> > +
> > virtnet_poll_cleantx(rq, budget);
> >
> > received = virtnet_receive(rq, budget, &xdp_xmit);
> > --
> > 2.43.0
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-23 10:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23 9:19 [PATCH v2] virtio_net: disable cb when NAPI is busy-polled Longjun Tang
2026-06-23 9:55 ` Eric Dumazet
2026-06-23 10:15 ` Michael S. Tsirkin
2026-06-23 10:10 ` Michael S. Tsirkin
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.