Linux virtualization list
 help / color / mirror / Atom feed
From: "Lange Tang" <lange_tang@163.com>
To: "jasowang@redhat.com" <jasowang@redhat.com>
Cc: "mst@redhat.com" <mst@redhat.com>,
	"xuanzhuo@linux.alibaba.com" <xuanzhuo@linux.alibaba.com>,
	"edumazet@google.com" <edumazet@google.com>,
	"Tang Longjun" <tanglongjun@kylinos.cn>,
	"virtualization@lists.linux.dev" <virtualization@lists.linux.dev>
Subject: Re:Re: [PATCH 1/2] virtio_net: disable cb when in busy-polling
Date: Tue, 7 Apr 2026 15:02:02 +0800 (CST)	[thread overview]
Message-ID: <18d16bfe.6bd3.19d66bf8c59.Coremail.lange_tang@163.com> (raw)
In-Reply-To: <CACGkMEtakF0EUYT11N=aNjphY_Ra4YsRaJZmJ4UD0VL5aPxX9g@mail.gmail.com>

At 2026-04-03 10:57:58, "Jason Wang" <jasowang@redhat.com> wrote:
>On Tue, Mar 31, 2026 at 6:27 PM Longjun Tang <lange_tang@163.com> wrote:
>>
>> From: Longjun Tang <tanglongjun@kylinos.cn>
>>
>> virtnet_poll() is shared between NAPI softirq context and the busy-poll
>> path (sk_busy_loop).  In the busy-poll path the caller drives the loop
>> directly and does not rely on interrupts to schedule NAPI; keeping
>> callbacks enabled is wasteful and risks a flood of IRQ_NONE returns that
>> can trigger the kernel's spurious-IRQ detector.
>>
>> Signed-off-by: Longjun Tang <tanglongjun@kylinos.cn>
>> ---
>>  drivers/net/virtio_net.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
>> index 72d6a9c6a5a2..df365fba2c40 100644
>> --- a/drivers/net/virtio_net.c
>> +++ b/drivers/net/virtio_net.c
>> @@ -3078,6 +3078,9 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
>>         unsigned int xdp_xmit = 0;
>>         bool napi_complete;
>>
>> +       if (READ_ONCE(napi->state) & NAPIF_STATE_IN_BUSY_POLL)
>> +               virtqueue_disable_cb(rq->vq);
>> +
>
>I guess the root cause is virtuqeue_disable_cb() doesn't disable cb in
>this case?
>
>static void virtqueue_napi_schedule(struct napi_struct *napi,
>                                    struct virtqueue *vq)
>{
>        if (napi_schedule_prep(napi)) {
>virtqueue_disable_cb(vq);
>                __napi_schedule(napi);
>        }
>}
>
>If there's an interrupt in the middle of NAPIF_STATE_IN_BUSY_POLL,
>napi_schedule_prep() will return false, so we lose the chance to
>disable cb.
>

Sorry for the late reply!

Regarding the root cause you mentioned, the chance to disable cb is indeed lost 
when the following three conditions are met:
1. In NAPIF_STATE_IN_BUSY_POLL
2. Interrupt occurs
3. more_used returns true

However, in another scenario:
1. In NAPIF_STATE_IN_BUSY_POLL
2. Interrupt occurs
3. more_used returns false
In this second scenario, there is no chance to disable cb during the execution 
of the virtnet_poll until virtqueue_napi_complete.

>Thanks
>
>>         virtnet_poll_cleantx(rq, budget);
>>
>>         received = virtnet_receive(rq, budget, &xdp_xmit);
>> --
>> 2.43.0
>>

  reply	other threads:[~2026-04-07  7:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 10:26 [PATCH 0/2] fix virtio_net/virtio when in busy-polling Longjun Tang
2026-03-31 10:26 ` [PATCH 1/2] virtio_net: disable cb " Longjun Tang
2026-04-03  2:57   ` Jason Wang
2026-04-07  7:02     ` Lange Tang [this message]
2026-03-31 10:26 ` [PATCH 2/2] virtio_ring: return IRQ_HANDLED for stale interrupts when cb disabled Longjun Tang
2026-04-03  2:55   ` Jason Wang
2026-04-07  7:28     ` Lange Tang

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=18d16bfe.6bd3.19d66bf8c59.Coremail.lange_tang@163.com \
    --to=lange_tang@163.com \
    --cc=edumazet@google.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=tanglongjun@kylinos.cn \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.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