From: "Michael S. Tsirkin" <mst@redhat.com>
To: Wei Wang <weiwan@google.com>
Cc: David Miller <davem@davemloft.net>,
netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
Willem de Bruijn <willemb@google.com>,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH net] virtio-net: suppress bad irq warning for tx napi
Date: Mon, 12 Apr 2021 18:08:16 -0400 [thread overview]
Message-ID: <20210412180353-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20210129002136.70865-1-weiwan@google.com>
OK I started looking at this again. My idea is simple.
A. disable callbacks before we try to drain skbs
B. actually do disable callbacks even with event idx
To make B not regress, we need to
C. detect the common case of disable after event triggering and skip the write then.
I added a new event_triggered flag for that.
Completely untested - but then I could not see the warnings either.
Would be very much interested to know whether this patch helps
resolve the sruprious interrupt problem at all ...
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 82e520d2cb12..a91a2d6d1ee3 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1429,6 +1429,7 @@ static void virtnet_poll_cleantx(struct receive_queue *rq)
return;
if (__netif_tx_trylock(txq)) {
+ virtqueue_disable_cb(vq);
free_old_xmit_skbs(sq, true);
__netif_tx_unlock(txq);
}
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 71e16b53e9c1..213bfe8b6051 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -113,6 +113,9 @@ struct vring_virtqueue {
/* Last used index we've seen. */
u16 last_used_idx;
+ /* Hint for event idx: already triggered no need to disable. */
+ bool event_triggered;
+
union {
/* Available for split ring */
struct {
@@ -739,7 +742,10 @@ static void virtqueue_disable_cb_split(struct virtqueue *_vq)
if (!(vq->split.avail_flags_shadow & VRING_AVAIL_F_NO_INTERRUPT)) {
vq->split.avail_flags_shadow |= VRING_AVAIL_F_NO_INTERRUPT;
- if (!vq->event)
+ if (vq->event)
+ /* TODO: this is a hack. Figure out a cleaner value to write. */
+ vring_used_event(&vq->split.vring) = 0x0;
+ else
vq->split.vring.avail->flags =
cpu_to_virtio16(_vq->vdev,
vq->split.avail_flags_shadow);
@@ -1605,6 +1611,7 @@ static struct virtqueue *vring_create_virtqueue_packed(
vq->weak_barriers = weak_barriers;
vq->broken = false;
vq->last_used_idx = 0;
+ vq->event_triggered = false;
vq->num_added = 0;
vq->packed_ring = true;
vq->use_dma_api = vring_use_dma_api(vdev);
@@ -1919,6 +1926,14 @@ void virtqueue_disable_cb(struct virtqueue *_vq)
{
struct vring_virtqueue *vq = to_vvq(_vq);
+ /* If device triggered an event already it won't trigger one again:
+ * no need to disable.
+ */
+ if (vq->event_triggered) {
+ vq->event_triggered = false;
+ return;
+ }
+
if (vq->packed_ring)
virtqueue_disable_cb_packed(_vq);
else
@@ -2044,6 +2059,10 @@ irqreturn_t vring_interrupt(int irq, void *_vq)
if (unlikely(vq->broken))
return IRQ_HANDLED;
+ /* Just a hint for performance: so it's ok that this can be racy! */
+ if (vq->event)
+ vq->event_triggered = true;
+
pr_debug("virtqueue callback for %p (%p)\n", vq, vq->vq.callback);
if (vq->vq.callback)
vq->vq.callback(&vq->vq);
@@ -2083,6 +2102,7 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
vq->weak_barriers = weak_barriers;
vq->broken = false;
vq->last_used_idx = 0;
+ vq->event_triggered = false;
vq->num_added = 0;
vq->use_dma_api = vring_use_dma_api(vdev);
#ifdef DEBUG
next prev parent reply other threads:[~2021-04-12 22:08 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-29 0:21 [PATCH net] virtio-net: suppress bad irq warning for tx napi Wei Wang
2021-02-02 2:24 ` Jakub Kicinski
2021-02-02 3:06 ` Jason Wang
2021-02-02 14:37 ` Willem de Bruijn
2021-02-03 5:33 ` Jason Wang
2021-02-03 18:28 ` Willem de Bruijn
2021-02-04 3:06 ` Jason Wang
2021-02-04 20:50 ` Willem de Bruijn
2021-02-08 3:29 ` Jason Wang
2021-02-08 19:08 ` Willem de Bruijn
2021-02-09 3:27 ` Jason Wang
2021-02-09 14:58 ` Willem de Bruijn
2021-02-09 18:00 ` Wei Wang
2021-02-10 9:14 ` Michael S. Tsirkin
2021-02-11 0:13 ` Wei Wang
2021-02-18 5:39 ` Jason Wang
2021-02-21 11:33 ` Michael S. Tsirkin
2021-02-02 23:11 ` Michael S. Tsirkin
2021-02-02 23:47 ` Wei Wang
2021-02-02 23:53 ` Willem de Bruijn
2021-02-03 0:06 ` Willem de Bruijn
2021-02-03 10:38 ` Michael S. Tsirkin
2021-02-03 18:24 ` Willem de Bruijn
2021-02-03 23:09 ` Michael S. Tsirkin
2021-02-03 23:52 ` Wei Wang
2021-02-04 20:47 ` Willem de Bruijn
2021-02-05 22:28 ` Wei Wang
2021-04-13 5:15 ` Michael S. Tsirkin
2021-09-29 20:21 ` Wei Wang
2021-09-29 21:53 ` Michael S. Tsirkin
2021-09-29 23:08 ` Wei Wang
2021-09-30 5:40 ` Michael S. Tsirkin
2021-09-30 18:10 ` Dave Taht
2021-04-12 22:08 ` Michael S. Tsirkin [this message]
2021-04-12 22:33 ` Michael S. Tsirkin
2021-04-12 23:14 ` David Miller
2021-04-13 4:24 ` Michael S. Tsirkin
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=20210412180353-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=weiwan@google.com \
--cc=willemb@google.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;
as well as URLs for NNTP newsgroup(s).