virtio/ringtest: fix up need_event math

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/f229a55c31a7e12a15c7b4dcf9a97a9bf7a72ce8
Commit:     f229a55c31a7e12a15c7b4dcf9a97a9bf7a72ce8
Parent:     31919140ff8c88c236f697baa28a6305df45e4ea
Refname:    refs/heads/master
Author:     Michael S. Tsirkin <[email protected]>
AuthorDate: Thu Oct 26 04:48:01 2017 +0300
Committer:  Michael S. Tsirkin <[email protected]>
CommitDate: Wed Jan 31 01:47:35 2018 +0200

    virtio/ringtest: fix up need_event math
    
    last kicked event index must be updated unconditionally:
    even if we don't need to kick, we do not want to re-check
    the same entry for events.
    
    Signed-off-by: Michael S. Tsirkin <[email protected]>
    Acked-by: Cornelia Huck <[email protected]>
    Acked-by: Jason Wang <[email protected]>
---
 tools/virtio/ringtest/ring.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/tools/virtio/ringtest/ring.c b/tools/virtio/ringtest/ring.c
index 747c5dd47be8..2b9859beea65 100644
--- a/tools/virtio/ringtest/ring.c
+++ b/tools/virtio/ringtest/ring.c
@@ -188,16 +188,18 @@ bool enable_call()
 
 void kick_available(void)
 {
+	bool need;
+
 	/* Flush in previous flags write */
 	/* Barrier C (for pairing) */
 	smp_mb();
-	if (!need_event(event->kick_index,
-			guest.avail_idx,
-			guest.kicked_avail_idx))
-		return;
+	need = need_event(event->kick_index,
+			   guest.avail_idx,
+			   guest.kicked_avail_idx);
 
 	guest.kicked_avail_idx = guest.avail_idx;
-	kick();
+	if (need)
+		kick();
 }
 
 /* host side */
@@ -253,14 +255,18 @@ bool use_buf(unsigned *lenp, void **bufp)
 
 void call_used(void)
 {
+	bool need;
+
 	/* Flush in previous flags write */
 	/* Barrier D (for pairing) */
 	smp_mb();
-	if (!need_event(event->call_index,
+
+	need = need_event(event->call_index,
 			host.used_idx,
-			host.called_used_idx))
-		return;
+			host.called_used_idx);
 
 	host.called_used_idx = host.used_idx;
-	call();
+
+	if (need)
+		call();
 }
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.