Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
virtio/ringtest: virtio_ring: fix up need_event math
Browse files Browse the repository at this point in the history
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@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Jens Freimann <jfreimann@redhat.com>
  • Loading branch information
mstsirkin committed Jan 30, 2018
1 parent f229a55 commit a311650
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tools/virtio/ringtest/virtio_ring_0_9.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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();
}

0 comments on commit a311650

Please sign in to comment.