From: "Michael S. Tsirkin" <mst@redhat.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: qemu-devel@nongnu.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: [Qemu-devel] Re: [PATCH RFC] virtio: put last seen used index into ring itself
Date: Thu, 6 May 2010 09:19:46 +0300 [thread overview]
Message-ID: <20100506061945.GA8363@redhat.com> (raw)
In-Reply-To: <201005061201.35223.rusty@rustcorp.com.au>
On Thu, May 06, 2010 at 12:01:34PM +0930, Rusty Russell wrote:
> On Thu, 6 May 2010 06:28:14 am Michael S. Tsirkin wrote:
> > Rusty,
> > this is a simplified form of a patch you posted in the past.
> > I have a vhost patch that, using this feature, shows external
> > to host bandwidth grow from 5 to 7 GB/s, by avoiding
> > an interrupt in the window after previous interrupt
> > was sent and before interrupts were disabled for the vq.
> > With vhost under some external to host loads I see
> > this window being hit about 30% sometimes.
>
> Fascinating. So you use this to guess if the guest is still processing?
Exactly.
> I haven't thought about it hard, but is that racy?
I thought about this really hard and I don't think it's
necessarily racy, as long as (pseudo code):
guest:
start:
disable interrupts
read(used)
write(last used)
enable interrupts
mb()
if read(used)
goto start
host:
write used
mb()
if (reached(read(last used), used))
interrupt
IOW, guest does read then write then read, host does write then read.
Now, the only way to miss an interrupt is if we read last used
value before it is written so we think guest is still processing.
But if that happens, this means that host has written used before
guest updated last used, and for this reason peek will see
used value and restart polling.
IOW, to miss an interrupt host must read a stale value.
For this host must read before guest write, then
host write already happened, so second read in
guest will see an updated value host has written.
Now, I also added an mb() in guest between read and write so
that last used index write can not get ahead of used index read.
It does feel good to have it there, but I can not say why
it's helpful. Works fine without it, but then these
subtle races might be hard to trigger. What do you think?
> Obviously happy to apply this when you finalize it.
>
> Thanks!
> Rusty.
next prev parent reply other threads:[~2010-05-06 6:24 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-05 20:58 [Qemu-devel] [PATCH RFC] virtio: put last seen used index into ring itself Michael S. Tsirkin
2010-05-05 21:18 ` [Qemu-devel] " Dor Laor
2010-05-06 2:31 ` Rusty Russell
2010-05-06 6:19 ` Michael S. Tsirkin [this message]
2010-05-07 3:33 ` Rusty Russell
2010-05-09 21:06 ` Michael S. Tsirkin
2010-05-06 10:00 ` [Qemu-devel] " Avi Kivity
2010-05-07 3:23 ` Rusty Russell
2010-05-11 19:27 ` Avi Kivity
2010-05-11 19:52 ` Michael S. Tsirkin
2010-05-19 7:39 ` Rusty Russell
2010-05-19 8:06 ` Avi Kivity
2010-05-19 22:33 ` Michael S. Tsirkin
2010-05-20 6:04 ` Avi Kivity
2010-05-20 5:01 ` Rusty Russell
2010-05-20 5:08 ` Rusty Russell
2010-05-23 15:31 ` Michael S. Tsirkin
2010-05-23 15:41 ` Avi Kivity
2010-05-23 15:51 ` Michael S. Tsirkin
2010-05-23 16:03 ` Avi Kivity
2010-05-23 16:30 ` Michael S. Tsirkin
2010-05-24 6:37 ` Avi Kivity
2010-05-24 8:05 ` Michael S. Tsirkin
2010-05-24 11:00 ` Avi Kivity
2010-05-23 17:28 ` Michael S. Tsirkin
2010-05-23 15:56 ` Michael S. Tsirkin
2010-05-20 7:00 ` Avi Kivity
2010-05-20 14:34 ` Rusty Russell
2010-05-20 15:46 ` Avi Kivity
2010-05-20 10:04 ` Michael S. Tsirkin
2010-05-11 18:46 ` [Qemu-devel] " Ryan Harper
2010-05-11 19:48 ` 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=20100506061945.GA8363@redhat.com \
--to=mst@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=rusty@rustcorp.com.au \
--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).