[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1474285139-11612-1-git-send-email-pbonzini@redhat.com>
Date: Mon, 19 Sep 2016 13:38:59 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Cc: mst@...hat.com
Subject: [PATCH] ringtest: Look at next descriptor before setting up event index
This avoids an expensive memory barrier if the next descriptor
is already there. The benefit is around 10%.
Signed-off-by: Paolo Bonzini <pbonzini@...hat.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
Powered by blists - more mailing lists