* Best way to busy-wait for a virtio queue?
@ 2013-03-29 23:12 H. Peter Anvin
2013-04-01 16:07 ` Eric Northup
0 siblings, 1 reply; 2+ messages in thread
From: H. Peter Anvin @ 2013-03-29 23:12 UTC (permalink / raw)
To: KVM
Is there any preferred way to busy-wait on a virtio event? As in: the
guest doesn't have anything useful to do until something is plopped down
on the virtio queue, but would like to proceed as quickly as possible
after that. Passing through an interrupt handler seems like unnecessary
overhead.
Right now I have a poll loop looking like (pseudocode):
outw(0, trigger);
while (readl(ring->output pointer) != final output pointer)
cpu_relax(); /* x86 PAUSE instruction */
... but I have no idea how much sense that makes.
-hpa
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Best way to busy-wait for a virtio queue?
2013-03-29 23:12 Best way to busy-wait for a virtio queue? H. Peter Anvin
@ 2013-04-01 16:07 ` Eric Northup
0 siblings, 0 replies; 2+ messages in thread
From: Eric Northup @ 2013-04-01 16:07 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: KVM
On Fri, Mar 29, 2013 at 4:12 PM, H. Peter Anvin <hpa@zytor.com> wrote:
>
> Is there any preferred way to busy-wait on a virtio event? As in: the
> guest doesn't have anything useful to do until something is plopped down
> on the virtio queue, but would like to proceed as quickly as possible
> after that. Passing through an interrupt handler seems like unnecessary
> overhead.
How much information do you have about the host? It is possible that
leaving the vCPU running is displacing execution from whatever host
thread(s) would be involved in making progress towards the event you
want delivered - in that case, the interrupt overhead might be
balanced out by lower latency of the event delivery.
> Right now I have a poll loop looking like (pseudocode):
>
> outw(0, trigger);
> while (readl(ring->output pointer) != final output pointer)
> cpu_relax(); /* x86 PAUSE instruction */
>
> ... but I have no idea how much sense that makes.
The cleanest expression of the desired semantic I can think of would
be MONITOR/MWAIT, except that KVM doesn't allow those instructions in
the guest. For the case of a 100% non-overcommitted host (including
host i/o processing), there's no reason not to allow the guest to run
those instructions.
Lacking that, I think the above busy-loop w/PAUSE in it will end up
causing a pause-loop exit - so it has largely the same effect but also
works on current hosts.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-01 16:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-29 23:12 Best way to busy-wait for a virtio queue? H. Peter Anvin
2013-04-01 16:07 ` Eric Northup
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox