From: Rusty Russell <rusty@rustcorp.com.au>
To: virtualization@lists.linux-foundation.org
Cc: Anthony Liguori <aliguori@us.ibm.com>
Subject: Re: [PATCH][RESEND] Relax BUG_ON()s when enabling/disabling virt_ring interrupts
Date: Mon, 7 Jan 2008 15:29:53 +1100 [thread overview]
Message-ID: <200801071529.53263.rusty@rustcorp.com.au> (raw)
In-Reply-To: <200801071427.31369.rusty@rustcorp.com.au>
On Monday 07 January 2008 14:27:31 Rusty Russell wrote:
> + /* Other side may have missed us turning off the interrupt,
> + * but we should preserve disable semantic for virtio users. */
> + if (unlikely(!(vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT))) {
> + pr_debug("virtqueue interrupt after disable for %p\n", vq);
> + return IRQ_HANDLED;
> + }
Of course, this test is exactly backwards.
Rusty.
virtio: handle interrupts after callbacks turned off
Anthony Liguori found double interrupt suppression in the virtio_net
driver, triggered by two skb_recv_done's in a row. This is because
virtio_ring's interrupt suppression is a best-effort optimization: it
contains no synchronization so the host can miss it and still send
interrupts.
But it's certainly nicer for virtio users if calling disable_cb
actually disables callbacks, so we check for the race in the interrupt
routine.
Note: SMP guests might require syncronization here, but since
disable_cb is actually called from interrupt context, there has to be
some form of synchronization before the next same interrupt handler is
called (Linux guarantees that the same device's irq handler will never
run simultanously on multiple CPUs).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
drivers/virtio/virtio_ring.c | 7 +++++++
1 file changed, 7 insertions(+)
diff -r bdc6894568d1 drivers/virtio/virtio_ring.c
--- a/drivers/virtio/virtio_ring.c Mon Jan 07 12:28:47 2008 +1100
+++ b/drivers/virtio/virtio_ring.c Mon Jan 07 15:28:23 2008 +1100
@@ -265,6 +265,13 @@ irqreturn_t vring_interrupt(int irq, voi
if (unlikely(vq->broken))
return IRQ_HANDLED;
+ /* Other side may have missed us turning off the interrupt,
+ * but we should preserve disable semantic for virtio users. */
+ if (unlikely(vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) {
+ pr_debug("virtqueue interrupt after disable for %p\n", vq);
+ return IRQ_HANDLED;
+ }
+
pr_debug("virtqueue callback for %p (%p)\n", vq, vq->vq.callback);
if (vq->vq.callback)
vq->vq.callback(&vq->vq);
prev parent reply other threads:[~2008-01-07 4:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-06 2:43 [PATCH][RESEND] Relax BUG_ON()s when enabling/disabling virt_ring interrupts Anthony Liguori
2008-01-07 3:27 ` Rusty Russell
2008-01-07 4:29 ` Rusty Russell [this message]
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=200801071529.53263.rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=aliguori@us.ibm.com \
--cc=virtualization@lists.linux-foundation.org \
/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).