Michael S. Tsirkin
2017-Oct-27 13:11 UTC
[PATCH] virtio/ringtest: virtio_ring: 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. Reported-by: Cornelia Huck <cohuck at redhat.com> Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- tools/virtio/ringtest/virtio_ring_0_9.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tools/virtio/ringtest/virtio_ring_0_9.c b/tools/virtio/ringtest/virtio_ring_0_9.c index bbc3043..5fd3fbc 100644 --- a/tools/virtio/ringtest/virtio_ring_0_9.c +++ b/tools/virtio/ringtest/virtio_ring_0_9.c @@ -225,16 +225,18 @@ bool enable_call() void kick_available(void) { + bool need; + /* Flush in previous flags write */ /* Barrier C (for pairing) */ smp_mb(); - if (!vring_need_event(vring_avail_event(&ring), - guest.avail_idx, - guest.kicked_avail_idx)) - return; + need = vring_need_event(vring_avail_event(&ring), + guest.avail_idx, + guest.kicked_avail_idx); guest.kicked_avail_idx = guest.avail_idx; - kick(); + if (need) + kick(); } /* host side */ @@ -316,14 +318,16 @@ 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 (!vring_need_event(vring_used_event(&ring), - host.used_idx, - host.called_used_idx)) - return; + need = vring_need_event(vring_used_event(&ring), + host.used_idx, + host.called_used_idx); host.called_used_idx = host.used_idx; - call(); + if (need) + call(); } -- MST
Jens Freimann
2017-Oct-30 13:00 UTC
[PATCH] virtio/ringtest: virtio_ring: fix up need_event math
On Fri, Oct 27, 2017 at 01:11:13PM +0000, Michael S. Tsirkin wrote:>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. > >Reported-by: Cornelia Huck <cohuck at redhat.com> >Signed-off-by: Michael S. Tsirkin <mst at redhat.com> >--- > tools/virtio/ringtest/virtio_ring_0_9.c | 24 ++++++++++++++---------- > 1 file changed, 14 insertions(+), 10 deletions(-) >Reviewed-by: Jens Freimann <jfreimann at redhat.com>
Apparently Analagous Threads
- [PATCH] virtio/ringtest: virtio_ring: fix up need_event math
- [PATCH] virtio/ringtest: fix up need_event math
- [PATCH] virtio/ringtest: fix up need_event math
- [PATCH v2] virtio/ringtest: fix up need_event math
- [PATCH v2] virtio/ringtest: fix up need_event math