Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1486398 > unrolled thread

[PATCH] ringtest: Look at next descriptor before setting up event index

Started byPaolo Bonzini <pbonzini@redhat.com>
First post2016-09-19 13:40 +0200
Last post2016-09-19 13:40 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] ringtest: Look at next descriptor before setting up event index Paolo Bonzini <pbonzini@redhat.com> - 2016-09-19 13:40 +0200

#1486398 — [PATCH] ringtest: Look at next descriptor before setting up event index

FromPaolo Bonzini <pbonzini@redhat.com>
Date2016-09-19 13:40 +0200
Subject[PATCH] ringtest: Look at next descriptor before setting up event index
Message-ID<sj55w-4R9-21@gated-at.bofh.it>
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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web