diff mbox series

[for-5.0] aio-posix: fix test-aio /aio/event/wait with fdmon-io_uring

Message ID 20200402145434.99349-1-stefanha@redhat.com (mailing list archive)
State New, archived
Headers show
Series [for-5.0] aio-posix: fix test-aio /aio/event/wait with fdmon-io_uring | expand

Commit Message

Stefan Hajnoczi April 2, 2020, 2:54 p.m. UTC
When a file descriptor becomes ready we must re-arm POLL_ADD.  This is
done by adding an sqe to the io_uring sq ring.  The ->need_wait()
function wasn't taking pending sqes into account and therefore
io_uring_submit_and_wait() was not being called.  Polling for cqes
failed to detect fd readiness since we hadn't submitted the sqe to
io_uring.

This patch fixes the following tests/test-aio -p /aio/event/wait
failure:

  ok 11 /aio/event/wait
  **
  ERROR:tests/test-aio.c:374:test_flush_event_notifier: assertion failed: (aio_poll(ctx, false))

Reported-by: Cole Robinson <crobinso@redhat.com>
Fixes: 73fd282e7b6dd4e4ea1c3bbb3d302c8db51e4ccf
       ("aio-posix: add io_uring fd monitoring implementation")
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 util/fdmon-io_uring.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Cole Robinson April 2, 2020, 5:30 p.m. UTC | #1
On 4/2/20 10:54 AM, Stefan Hajnoczi wrote:
> When a file descriptor becomes ready we must re-arm POLL_ADD.  This is
> done by adding an sqe to the io_uring sq ring.  The ->need_wait()
> function wasn't taking pending sqes into account and therefore
> io_uring_submit_and_wait() was not being called.  Polling for cqes
> failed to detect fd readiness since we hadn't submitted the sqe to
> io_uring.
> 
> This patch fixes the following tests/test-aio -p /aio/event/wait
> failure:
> 
>   ok 11 /aio/event/wait
>   **
>   ERROR:tests/test-aio.c:374:test_flush_event_notifier: assertion failed: (aio_poll(ctx, false))
> 
> Reported-by: Cole Robinson <crobinso@redhat.com>
> Fixes: 73fd282e7b6dd4e4ea1c3bbb3d302c8db51e4ccf
>        ("aio-posix: add io_uring fd monitoring implementation")
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Fixes the crash for me, thanks!

Tested-by: Cole Robinson <crobinso@redhat.com>

- Cole
Stefano Garzarella April 3, 2020, 7:26 a.m. UTC | #2
On Thu, Apr 02, 2020 at 03:54:34PM +0100, Stefan Hajnoczi wrote:
> When a file descriptor becomes ready we must re-arm POLL_ADD.  This is
> done by adding an sqe to the io_uring sq ring.  The ->need_wait()
> function wasn't taking pending sqes into account and therefore
> io_uring_submit_and_wait() was not being called.  Polling for cqes
> failed to detect fd readiness since we hadn't submitted the sqe to
> io_uring.
> 
> This patch fixes the following tests/test-aio -p /aio/event/wait
> failure:
> 
>   ok 11 /aio/event/wait
>   **
>   ERROR:tests/test-aio.c:374:test_flush_event_notifier: assertion failed: (aio_poll(ctx, false))
> 
> Reported-by: Cole Robinson <crobinso@redhat.com>
> Fixes: 73fd282e7b6dd4e4ea1c3bbb3d302c8db51e4ccf
>        ("aio-posix: add io_uring fd monitoring implementation")
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  util/fdmon-io_uring.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

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

Thanks,
Stefano

> 
> diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
> index 7e143ef515..b4d6109f20 100644
> --- a/util/fdmon-io_uring.c
> +++ b/util/fdmon-io_uring.c
> @@ -295,7 +295,12 @@ static bool fdmon_io_uring_need_wait(AioContext *ctx)
>          return true;
>      }
>  
> -    /* Do we need to submit new io_uring sqes? */
> +    /* Are there pending sqes to submit? */
> +    if (io_uring_sq_ready(&ctx->fdmon_io_uring)) {
> +        return true;
> +    }
> +
> +    /* Do we need to process AioHandlers for io_uring changes? */
>      if (!QSLIST_EMPTY_RCU(&ctx->submit_list)) {
>          return true;
>      }
> -- 
> 2.25.1
>
Stefan Hajnoczi April 3, 2020, 11:52 a.m. UTC | #3
On Thu, Apr 02, 2020 at 03:54:34PM +0100, Stefan Hajnoczi wrote:
> When a file descriptor becomes ready we must re-arm POLL_ADD.  This is
> done by adding an sqe to the io_uring sq ring.  The ->need_wait()
> function wasn't taking pending sqes into account and therefore
> io_uring_submit_and_wait() was not being called.  Polling for cqes
> failed to detect fd readiness since we hadn't submitted the sqe to
> io_uring.
> 
> This patch fixes the following tests/test-aio -p /aio/event/wait
> failure:
> 
>   ok 11 /aio/event/wait
>   **
>   ERROR:tests/test-aio.c:374:test_flush_event_notifier: assertion failed: (aio_poll(ctx, false))
> 
> Reported-by: Cole Robinson <crobinso@redhat.com>
> Fixes: 73fd282e7b6dd4e4ea1c3bbb3d302c8db51e4ccf
>        ("aio-posix: add io_uring fd monitoring implementation")
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  util/fdmon-io_uring.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

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

Stefan
diff mbox series

Patch

diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
index 7e143ef515..b4d6109f20 100644
--- a/util/fdmon-io_uring.c
+++ b/util/fdmon-io_uring.c
@@ -295,7 +295,12 @@  static bool fdmon_io_uring_need_wait(AioContext *ctx)
         return true;
     }
 
-    /* Do we need to submit new io_uring sqes? */
+    /* Are there pending sqes to submit? */
+    if (io_uring_sq_ready(&ctx->fdmon_io_uring)) {
+        return true;
+    }
+
+    /* Do we need to process AioHandlers for io_uring changes? */
     if (!QSLIST_EMPTY_RCU(&ctx->submit_list)) {
         return true;
     }