* [PATCH] virtio/ringtest: fix up need_event math
@ 2017-10-26 1:48 Michael S. Tsirkin
2017-10-26 8:36 ` Cornelia Huck
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2017-10-26 1:48 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, virtualization
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>
---
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 6b70c4e..d044a88 100644
--- a/tools/virtio/ringtest/ring.c
+++ b/tools/virtio/ringtest/ring.c
@@ -196,16 +196,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 */
@@ -265,14 +267,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();
}
--
MST
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] virtio/ringtest: fix up need_event math
2017-10-26 1:48 [PATCH] virtio/ringtest: fix up need_event math Michael S. Tsirkin
2017-10-26 8:36 ` Cornelia Huck
@ 2017-10-26 8:36 ` Cornelia Huck
2017-10-27 13:16 ` Michael S. Tsirkin
2017-10-26 12:28 ` Jason Wang
2017-10-26 12:28 ` Jason Wang
3 siblings, 1 reply; 7+ messages in thread
From: Cornelia Huck @ 2017-10-26 8:36 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: linux-kernel, virtualization
On Thu, 26 Oct 2017 04:48:01 +0300
"Michael S. Tsirkin" <mst@redhat.com> 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.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> tools/virtio/ringtest/ring.c | 24 +++++++++++++++---------
> 1 file changed, 15 insertions(+), 9 deletions(-)
Acked-by: Cornelia Huck <cohuck@redhat.com>
I think virtio_ring_0_9 has the same issue?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] virtio/ringtest: fix up need_event math
2017-10-26 1:48 [PATCH] virtio/ringtest: fix up need_event math Michael S. Tsirkin
@ 2017-10-26 8:36 ` Cornelia Huck
2017-10-26 8:36 ` Cornelia Huck
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Cornelia Huck @ 2017-10-26 8:36 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: linux-kernel, virtualization
On Thu, 26 Oct 2017 04:48:01 +0300
"Michael S. Tsirkin" <mst@redhat.com> 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.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> tools/virtio/ringtest/ring.c | 24 +++++++++++++++---------
> 1 file changed, 15 insertions(+), 9 deletions(-)
Acked-by: Cornelia Huck <cohuck@redhat.com>
I think virtio_ring_0_9 has the same issue?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] virtio/ringtest: fix up need_event math
2017-10-26 1:48 [PATCH] virtio/ringtest: fix up need_event math Michael S. Tsirkin
` (2 preceding siblings ...)
2017-10-26 12:28 ` Jason Wang
@ 2017-10-26 12:28 ` Jason Wang
3 siblings, 0 replies; 7+ messages in thread
From: Jason Wang @ 2017-10-26 12:28 UTC (permalink / raw)
To: Michael S. Tsirkin, linux-kernel; +Cc: virtualization
On 2017年10月26日 09:48, 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.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 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 6b70c4e..d044a88 100644
> --- a/tools/virtio/ringtest/ring.c
> +++ b/tools/virtio/ringtest/ring.c
> @@ -196,16 +196,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 */
> @@ -265,14 +267,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();
> }
Acked-by: Jason Wang <jasowang@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] virtio/ringtest: fix up need_event math
2017-10-26 1:48 [PATCH] virtio/ringtest: fix up need_event math Michael S. Tsirkin
2017-10-26 8:36 ` Cornelia Huck
2017-10-26 8:36 ` Cornelia Huck
@ 2017-10-26 12:28 ` Jason Wang
2017-10-26 12:28 ` Jason Wang
3 siblings, 0 replies; 7+ messages in thread
From: Jason Wang @ 2017-10-26 12:28 UTC (permalink / raw)
To: Michael S. Tsirkin, linux-kernel; +Cc: virtualization
On 2017年10月26日 09:48, 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.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 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 6b70c4e..d044a88 100644
> --- a/tools/virtio/ringtest/ring.c
> +++ b/tools/virtio/ringtest/ring.c
> @@ -196,16 +196,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 */
> @@ -265,14 +267,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();
> }
Acked-by: Jason Wang <jasowang@redhat.com>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] virtio/ringtest: fix up need_event math
2017-10-26 8:36 ` Cornelia Huck
@ 2017-10-27 13:16 ` Michael S. Tsirkin
0 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2017-10-27 13:16 UTC (permalink / raw)
To: Cornelia Huck; +Cc: linux-kernel, virtualization
On Thu, Oct 26, 2017 at 10:36:47AM +0200, Cornelia Huck wrote:
> On Thu, 26 Oct 2017 04:48:01 +0300
> "Michael S. Tsirkin" <mst@redhat.com> 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.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> > tools/virtio/ringtest/ring.c | 24 +++++++++++++++---------
> > 1 file changed, 15 insertions(+), 9 deletions(-)
>
> Acked-by: Cornelia Huck <cohuck@redhat.com>
Actually it seems to sometimes trigger stalls when host and guest
are on the same physical core. To trigger:
./ring --sleep --host-affinity 0 --guest-affinity 0
This worries me since it's similar to what vhost does.
Still debugging - anyone see anything suspicious?
> I think virtio_ring_0_9 has the same issue?
I think it does, posted a patch.
--
MST
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] virtio/ringtest: fix up need_event math
@ 2017-10-26 1:48 Michael S. Tsirkin
0 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2017-10-26 1:48 UTC (permalink / raw)
To: linux-kernel; +Cc: virtualization
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>
---
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 6b70c4e..d044a88 100644
--- a/tools/virtio/ringtest/ring.c
+++ b/tools/virtio/ringtest/ring.c
@@ -196,16 +196,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 */
@@ -265,14 +267,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();
}
--
MST
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-10-27 13:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-26 1:48 [PATCH] virtio/ringtest: fix up need_event math Michael S. Tsirkin
2017-10-26 8:36 ` Cornelia Huck
2017-10-26 8:36 ` Cornelia Huck
2017-10-27 13:16 ` Michael S. Tsirkin
2017-10-26 12:28 ` Jason Wang
2017-10-26 12:28 ` Jason Wang
-- strict thread matches above, loose matches on Subject: below --
2017-10-26 1:48 Michael S. Tsirkin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.