From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: mst@redhat.com
Subject: [PATCH] ringtest: Look at next descriptor before setting up event index
Date: Mon, 19 Sep 2016 13:38:59 +0200 [thread overview]
Message-ID: <1474285139-11612-1-git-send-email-pbonzini@redhat.com> (raw)
This avoids an expensive memory barrier if the next descriptor
is already there. The benefit is around 10%.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
tools/virtio/ringtest/ring.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/virtio/ringtest/ring.c b/tools/virtio/ringtest/ring.c
index c25c8d248b6b..e617e20538bf 100644
--- a/tools/virtio/ringtest/ring.c
+++ b/tools/virtio/ringtest/ring.c
@@ -182,6 +182,9 @@ bool enable_call()
{
unsigned head = (ring_size - 1) & guest.last_used_idx;
+ if (!(ring[head].flags & DESC_HW))
+ return false;
+
event->call_index = guest.last_used_idx;
/* Flush call index write */
/* Barrier D (for pairing) */
@@ -215,6 +218,9 @@ bool enable_kick()
{
unsigned head = (ring_size - 1) & host.used_idx;
+ if (ring[head].flags & DESC_HW)
+ return false;
+
event->kick_index = host.used_idx;
/* Barrier C (for pairing) */
smp_mb();
--
2.7.4
next reply other threads:[~2016-09-19 11:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-19 11:38 Paolo Bonzini [this message]
2016-10-03 22:48 ` [PATCH] ringtest: Look at next descriptor before setting up event index Paolo Bonzini
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=1474285139-11612-1-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
/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).