[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4] Use io_uring_register_ring_fd() to skip fd operations
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH v4] Use io_uring_register_ring_fd() to skip fd operations |
Date: |
Fri, 22 Apr 2022 16:10:00 +0100 |
On Fri, Apr 22, 2022 at 12:36:49AM +0800, Sam Li wrote:
> Linux recently added a new io_uring(7) optimization API that QEMU
> doesn't take advantage of yet. The liburing library that QEMU uses
> has added a corresponding new API calling io_uring_register_ring_fd().
> When this API is called after creating the ring, the io_uring_submit()
> library function passes a flag to the io_uring_enter(2) syscall
> allowing it to skip the ring file descriptor fdget()/fdput()
> operations. This saves some CPU cycles.
>
> Signed-off-by: Sam Li <faithilikerun@gmail.com>
> ---
> block/io_uring.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/block/io_uring.c b/block/io_uring.c
> index 782afdb433..5247fb79e2 100644
> --- a/block/io_uring.c
> +++ b/block/io_uring.c
> @@ -435,8 +435,16 @@ LuringState *luring_init(Error **errp)
> }
>
> ioq_init(&s->io_q);
> - return s;
> + if (io_uring_register_ring_fd(&s->ring) < 0) {
What happens when QEMU is built against an older version of liburing
that lacks the io_uring_register_ring_fd() API?
I guess there will be a compiler error because the function prototype is
missing in <liburing.h>.
This can be addressed by checking for the presence of the function in
meson.build:
+config_host_data.set('CONFIG_LIBURING_REGISTER_RING_FD',
cc.has_function('io_uring_register_ring_fd', prefix: '#include <liburing.h>'))
Then block/io_uring.c can call the function only when available:
+#ifdef CONFIG_LIBURING_REGISTER_RING_FD
+ io_uring_register_ring_fd(&s->ring);
+#endif
(I haven't tested this code but it should be close.)
Stefan
signature.asc
Description: PGP signature
Re: [PATCH v4] Use io_uring_register_ring_fd() to skip fd operations,
Stefan Hajnoczi <=