diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2017-10-25 21:48:01 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2018-01-30 18:47:35 -0500 |
commit | f229a55c31a7e12a15c7b4dcf9a97a9bf7a72ce8 (patch) | |
tree | d1a66cb14384c15dceaf6c291a34e6e4d288086d /tools | |
parent | 31919140ff8c88c236f697baa28a6305df45e4ea (diff) |
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 <mst@redhat.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/virtio/ringtest/ring.c | 24 |
1 files 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() | |||
188 | 188 | ||
189 | void kick_available(void) | 189 | void kick_available(void) |
190 | { | 190 | { |
191 | bool need; | ||
192 | |||
191 | /* Flush in previous flags write */ | 193 | /* Flush in previous flags write */ |
192 | /* Barrier C (for pairing) */ | 194 | /* Barrier C (for pairing) */ |
193 | smp_mb(); | 195 | smp_mb(); |
194 | if (!need_event(event->kick_index, | 196 | need = need_event(event->kick_index, |
195 | guest.avail_idx, | 197 | guest.avail_idx, |
196 | guest.kicked_avail_idx)) | 198 | guest.kicked_avail_idx); |
197 | return; | ||
198 | 199 | ||
199 | guest.kicked_avail_idx = guest.avail_idx; | 200 | guest.kicked_avail_idx = guest.avail_idx; |
200 | kick(); | 201 | if (need) |
202 | kick(); | ||
201 | } | 203 | } |
202 | 204 | ||
203 | /* host side */ | 205 | /* host side */ |
@@ -253,14 +255,18 @@ bool use_buf(unsigned *lenp, void **bufp) | |||
253 | 255 | ||
254 | void call_used(void) | 256 | void call_used(void) |
255 | { | 257 | { |
258 | bool need; | ||
259 | |||
256 | /* Flush in previous flags write */ | 260 | /* Flush in previous flags write */ |
257 | /* Barrier D (for pairing) */ | 261 | /* Barrier D (for pairing) */ |
258 | smp_mb(); | 262 | smp_mb(); |
259 | if (!need_event(event->call_index, | 263 | |
264 | need = need_event(event->call_index, | ||
260 | host.used_idx, | 265 | host.used_idx, |
261 | host.called_used_idx)) | 266 | host.called_used_idx); |
262 | return; | ||
263 | 267 | ||
264 | host.called_used_idx = host.used_idx; | 268 | host.called_used_idx = host.used_idx; |
265 | call(); | 269 | |
270 | if (need) | ||
271 | call(); | ||
266 | } | 272 | } |