diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2020-03-05 17:08:05 +0000 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2020-03-09 16:41:31 +0000 |
commit | aa38e19f05c3a5ae64dff84f44e1aa31281a5b14 (patch) | |
tree | 511a1cbddc11aee4e8b4ff22469189136cc125d9 /include/block/aio.h | |
parent | 73fd282e7b6dd4e4ea1c3bbb3d302c8db51e4ccf (diff) | |
download | qemu-aa38e19f05c3a5ae64dff84f44e1aa31281a5b14.zip qemu-aa38e19f05c3a5ae64dff84f44e1aa31281a5b14.tar.gz qemu-aa38e19f05c3a5ae64dff84f44e1aa31281a5b14.tar.bz2 |
aio-posix: support userspace polling of fd monitoring
Unlike ppoll(2) and epoll(7), Linux io_uring completions can be polled
from userspace. Previously userspace polling was only allowed when all
AioHandler's had an ->io_poll() callback. This prevented starvation of
fds by userspace pollable handlers.
Add the FDMonOps->need_wait() callback that enables userspace polling
even when some AioHandlers lack ->io_poll().
For example, it's now possible to do userspace polling when a TCP/IP
socket is monitored thanks to Linux io_uring.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Link: https://lore.kernel.org/r/20200305170806.1313245-7-stefanha@redhat.com
Message-Id: <20200305170806.1313245-7-stefanha@redhat.com>
Diffstat (limited to 'include/block/aio.h')
-rw-r--r-- | include/block/aio.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/block/aio.h b/include/block/aio.h index 83fc9b8..f07ebb7 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -55,6 +55,9 @@ struct ThreadPool; struct LinuxAioState; struct LuringState; +/* Is polling disabled? */ +bool aio_poll_disabled(AioContext *ctx); + /* Callbacks for file descriptor monitoring implementations */ typedef struct { /* @@ -84,6 +87,22 @@ typedef struct { * Returns: number of ready file descriptors. */ int (*wait)(AioContext *ctx, AioHandlerList *ready_list, int64_t timeout); + + /* + * need_wait: + * @ctx: the AioContext + * + * Tell aio_poll() when to stop userspace polling early because ->wait() + * has fds ready. + * + * File descriptor monitoring implementations that cannot poll fd readiness + * from userspace should use aio_poll_disabled() here. This ensures that + * file descriptors are not starved by handlers that frequently make + * progress via userspace polling. + * + * Returns: true if ->wait() should be called, false otherwise. + */ + bool (*need_wait)(AioContext *ctx); } FDMonOps; /* |