mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 14:53:54 -06:00
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>
This commit is contained in:
parent
73fd282e7b
commit
aa38e19f05
5 changed files with 35 additions and 3 deletions
|
@ -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;
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue