All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] aio-posix: fix io_uring with external events
@ 2020-03-19 16:35 Stefan Hajnoczi
  2020-03-20  9:28 ` Stefano Garzarella
  2020-03-23 11:05 ` Stefan Hajnoczi
  0 siblings, 2 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2020-03-19 16:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Paolo Bonzini, Julia Suvorova, qemu-block, Stefan Hajnoczi

When external event sources are disabled fdmon-io_uring falls back to
fdmon-poll.  The ->need_wait() callback needs to watch for this so it
can return true when external event sources are disabled.

It is also necessary to call ->wait() when AioHandlers have changed
because io_uring is asynchronous and we must submit new sqes.

Both of these changes to ->need_wait() together fix tests/test-aio -p
/aio/external-client, which failed with:

  test-aio: tests/test-aio.c:404: test_aio_external_client: Assertion `aio_poll(ctx, false)' failed.

Reported-by: Julia Suvorova <jusual@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 util/fdmon-io_uring.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
index 893b79b622..7e143ef515 100644
--- a/util/fdmon-io_uring.c
+++ b/util/fdmon-io_uring.c
@@ -290,7 +290,18 @@ static int fdmon_io_uring_wait(AioContext *ctx, AioHandlerList *ready_list,
 
 static bool fdmon_io_uring_need_wait(AioContext *ctx)
 {
-    return io_uring_cq_ready(&ctx->fdmon_io_uring);
+    /* Have io_uring events completed? */
+    if (io_uring_cq_ready(&ctx->fdmon_io_uring)) {
+        return true;
+    }
+
+    /* Do we need to submit new io_uring sqes? */
+    if (!QSLIST_EMPTY_RCU(&ctx->submit_list)) {
+        return true;
+    }
+
+    /* Are we falling back to fdmon-poll? */
+    return atomic_read(&ctx->external_disable_cnt);
 }
 
 static const FDMonOps fdmon_io_uring_ops = {
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] aio-posix: fix io_uring with external events
  2020-03-19 16:35 [PATCH] aio-posix: fix io_uring with external events Stefan Hajnoczi
@ 2020-03-20  9:28 ` Stefano Garzarella
  2020-03-23 11:05 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Garzarella @ 2020-03-20  9:28 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Fam Zheng, Paolo Bonzini, Julia Suvorova, qemu-devel, qemu-block

On Thu, Mar 19, 2020 at 04:35:59PM +0000, Stefan Hajnoczi wrote:
> When external event sources are disabled fdmon-io_uring falls back to
> fdmon-poll.  The ->need_wait() callback needs to watch for this so it
> can return true when external event sources are disabled.
> 
> It is also necessary to call ->wait() when AioHandlers have changed
> because io_uring is asynchronous and we must submit new sqes.
> 
> Both of these changes to ->need_wait() together fix tests/test-aio -p
> /aio/external-client, which failed with:
> 
>   test-aio: tests/test-aio.c:404: test_aio_external_client: Assertion `aio_poll(ctx, false)' failed.
> 
> Reported-by: Julia Suvorova <jusual@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  util/fdmon-io_uring.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
> index 893b79b622..7e143ef515 100644
> --- a/util/fdmon-io_uring.c
> +++ b/util/fdmon-io_uring.c
> @@ -290,7 +290,18 @@ static int fdmon_io_uring_wait(AioContext *ctx, AioHandlerList *ready_list,
>  
>  static bool fdmon_io_uring_need_wait(AioContext *ctx)
>  {
> -    return io_uring_cq_ready(&ctx->fdmon_io_uring);
> +    /* Have io_uring events completed? */
> +    if (io_uring_cq_ready(&ctx->fdmon_io_uring)) {
> +        return true;
> +    }
> +
> +    /* Do we need to submit new io_uring sqes? */
> +    if (!QSLIST_EMPTY_RCU(&ctx->submit_list)) {
> +        return true;
> +    }
> +
> +    /* Are we falling back to fdmon-poll? */
> +    return atomic_read(&ctx->external_disable_cnt);
>  }
>  
>  static const FDMonOps fdmon_io_uring_ops = {
> -- 
> 2.24.1
> 

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] aio-posix: fix io_uring with external events
  2020-03-19 16:35 [PATCH] aio-posix: fix io_uring with external events Stefan Hajnoczi
  2020-03-20  9:28 ` Stefano Garzarella
@ 2020-03-23 11:05 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2020-03-23 11:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Fam Zheng, Paolo Bonzini, Julia Suvorova, qemu-block

[-- Attachment #1: Type: text/plain, Size: 952 bytes --]

On Thu, Mar 19, 2020 at 04:35:59PM +0000, Stefan Hajnoczi wrote:
> When external event sources are disabled fdmon-io_uring falls back to
> fdmon-poll.  The ->need_wait() callback needs to watch for this so it
> can return true when external event sources are disabled.
> 
> It is also necessary to call ->wait() when AioHandlers have changed
> because io_uring is asynchronous and we must submit new sqes.
> 
> Both of these changes to ->need_wait() together fix tests/test-aio -p
> /aio/external-client, which failed with:
> 
>   test-aio: tests/test-aio.c:404: test_aio_external_client: Assertion `aio_poll(ctx, false)' failed.
> 
> Reported-by: Julia Suvorova <jusual@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  util/fdmon-io_uring.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-23 11:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 16:35 [PATCH] aio-posix: fix io_uring with external events Stefan Hajnoczi
2020-03-20  9:28 ` Stefano Garzarella
2020-03-23 11:05 ` Stefan Hajnoczi

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.