Skip to content

Commit

Permalink
ringtest: poll for new buffers once before updating event index
Browse files Browse the repository at this point in the history
Updating the event index has a memory barrier and causes more work
on the other side to actually signal the event.  It is unnecessary
if a new buffer has already appeared on the ring, so poll once before
doing the update.

The effect of this on the 0.9 ring implementation is pretty much
invisible, but on the new-style ring it provides a consistent 3%
performance improvement.

Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
  • Loading branch information
bonzini authored and mstsirkin committed Oct 30, 2016
1 parent d3c3589 commit 948a8ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/virtio/ringtest/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static void __attribute__((__flatten__)) run_guest(void)
assert(completed <= bufs);
assert(started <= bufs);
if (do_sleep) {
if (enable_call())
if (used_empty() && enable_call())
wait_for_call();
} else {
poll_used();
Expand All @@ -172,7 +172,7 @@ static void __attribute__((__flatten__)) run_host(void)

for (;;) {
if (do_sleep) {
if (enable_kick())
if (avail_empty() && enable_kick())
wait_for_kick();
} else {
poll_avail();
Expand Down

0 comments on commit 948a8ac

Please sign in to comment.