All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Balaji Rao <balajirrao@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: [PATCH] virtio: remove overzealous BUG_ON.
Date: Mon, 7 Apr 2008 14:30:28 +1000	[thread overview]
Message-ID: <200804071430.28399.rusty@rustcorp.com.au> (raw)

The 'disable_cb' callback is designed as an optimization to tell the host
we don't need callbacks now.  As it is not reliable, the debug check is
overzealous: it can happen on two CPUs at the same time.  Document this.

Even if it were reliable, the virtio_net driver doesn't disable
callbacks on transmit so the START_USE/END_USE debugging reentrance
protection can be easily tripped even on UP.

Thanks to Balaji Rao for the bug report and testing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
CC: Balaji Rao <balajirrao@gmail.com>

diff -r 0b3e64be7696 drivers/virtio/virtio_ring.c
--- a/drivers/virtio/virtio_ring.c	Mon Apr 07 07:40:08 2008 +1000
+++ b/drivers/virtio/virtio_ring.c	Mon Apr 07 13:37:03 2008 +1000
@@ -214,10 +215,7 @@ static void vring_disable_cb(struct virt
 {
 	struct vring_virtqueue *vq = to_vvq(_vq);
 
-	START_USE(vq);
-	BUG_ON(vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT);
 	vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
-	END_USE(vq);
 }
 
 static bool vring_enable_cb(struct virtqueue *_vq)
diff -r 0b3e64be7696 include/linux/virtio.h
--- a/include/linux/virtio.h	Mon Apr 07 07:40:08 2008 +1000
+++ b/include/linux/virtio.h	Mon Apr 07 13:37:03 2008 +1000
@@ -41,6 +41,8 @@ struct virtqueue
  *	Returns NULL or the "data" token handed to add_buf.
  * @disable_cb: disable callbacks
  *	vq: the struct virtqueue we're talking about.
+ *	Note that this is not necessarily synchronous, hence unreliable and only
+ *	useful as an optimization.
  * @enable_cb: restart callbacks after disable_cb.
  *	vq: the struct virtqueue we're talking about.
  *	This re-enables callbacks; it returns "false" if there are pending
@@ -48,7 +50,8 @@ struct virtqueue
  *	checking for more work, and enabling callbacks.
  *
  * Locking rules are straightforward: the driver is responsible for
- * locking.  No two operations may be invoked simultaneously.
+ * locking.  No two operations may be invoked simultaneously, with the exception
+ * of @disable_cb.
  *
  * All operations can be called in any context.
  */

             reply	other threads:[~2008-04-07  4:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-07  4:30 Rusty Russell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-04-07  4:30 [PATCH] virtio: remove overzealous BUG_ON Rusty Russell
2008-04-07 13:50 ` Anthony Liguori
2008-04-07 13:50 ` Anthony Liguori
2008-04-07 20:09   ` Rusty Russell
2008-04-07 20:09     ` Rusty Russell
2008-04-07 13:50 ` Anthony Liguori

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=200804071430.28399.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=balajirrao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --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 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.