aboutsummaryrefslogtreecommitdiff
path: root/util/aio-posix.h
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2020-03-05 17:08:04 +0000
committerStefan Hajnoczi <stefanha@redhat.com>2020-03-09 16:41:31 +0000
commit73fd282e7b6dd4e4ea1c3bbb3d302c8db51e4ccf (patch)
tree1338ebeba78a352f20904f9118f694c459599179 /util/aio-posix.h
parentb321051cf48ccc2d3d832af111d688f2282f089b (diff)
downloadqemu-73fd282e7b6dd4e4ea1c3bbb3d302c8db51e4ccf.zip
qemu-73fd282e7b6dd4e4ea1c3bbb3d302c8db51e4ccf.tar.gz
qemu-73fd282e7b6dd4e4ea1c3bbb3d302c8db51e4ccf.tar.bz2
aio-posix: add io_uring fd monitoring implementation
The recent Linux io_uring API has several advantages over ppoll(2) and epoll(2). Details are given in the source code. Add an io_uring implementation and make it the default on Linux. Performance is the same as with epoll(7) but later patches add optimizations that take advantage of io_uring. It is necessary to change how aio_set_fd_handler() deals with deleting AioHandlers since removing monitored file descriptors is asynchronous in io_uring. fdmon_io_uring_remove() marks the AioHandler deleted and aio_set_fd_handler() will let it handle deletion in that case. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Link: https://lore.kernel.org/r/20200305170806.1313245-6-stefanha@redhat.com Message-Id: <20200305170806.1313245-6-stefanha@redhat.com>
Diffstat (limited to 'util/aio-posix.h')
-rw-r--r--util/aio-posix.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/util/aio-posix.h b/util/aio-posix.h
index 97899d0..55fc771 100644
--- a/util/aio-posix.h
+++ b/util/aio-posix.h
@@ -27,10 +27,14 @@ struct AioHandler {
IOHandler *io_poll_begin;
IOHandler *io_poll_end;
void *opaque;
- bool is_external;
QLIST_ENTRY(AioHandler) node;
QLIST_ENTRY(AioHandler) node_ready; /* only used during aio_poll() */
QLIST_ENTRY(AioHandler) node_deleted;
+#ifdef CONFIG_LINUX_IO_URING
+ QSLIST_ENTRY(AioHandler) node_submitted;
+ unsigned flags; /* see fdmon-io_uring.c */
+#endif
+ bool is_external;
};
/* Add a handler to a ready list */
@@ -58,4 +62,18 @@ static inline void fdmon_epoll_disable(AioContext *ctx)
}
#endif /* !CONFIG_EPOLL_CREATE1 */
+#ifdef CONFIG_LINUX_IO_URING
+bool fdmon_io_uring_setup(AioContext *ctx);
+void fdmon_io_uring_destroy(AioContext *ctx);
+#else
+static inline bool fdmon_io_uring_setup(AioContext *ctx)
+{
+ return false;
+}
+
+static inline void fdmon_io_uring_destroy(AioContext *ctx)
+{
+}
+#endif /* !CONFIG_LINUX_IO_URING */
+
#endif /* AIO_POSIX_H */