From bccc636bbfac38583d4ad99d3267ed8e64cb1fd9 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 4 Dec 2024 14:03:23 -0500 Subject: ioq: Refactor ioq_ring_probe_flags() --- src/ioq.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/ioq.c b/src/ioq.c index b845a2c..ced9864 100644 --- a/src/ioq.c +++ b/src/ioq.c @@ -982,20 +982,22 @@ static void *ioq_work(void *ptr) { #if BFS_WITH_LIBURING /** Test whether some io_uring setup flags are supported. */ -static bool ioq_ring_probe_flags(unsigned int *flags, unsigned int new_flags) { - struct io_uring ring; +static bool ioq_ring_probe_flags(struct io_uring_params *params, unsigned int flags) { + unsigned int saved = params->flags; + params->flags |= flags; - int ret = io_uring_queue_init(2, &ring, *flags | new_flags); + struct io_uring ring; + int ret = io_uring_queue_init_params(2, &ring, params); if (ret == 0) { io_uring_queue_exit(&ring); } - if (ret != -EINVAL) { - *flags |= new_flags; - return true; + if (ret == -EINVAL) { + params->flags = saved; + return false; } - return false; + return true; } #endif @@ -1021,19 +1023,19 @@ static int ioq_ring_init(struct ioq *ioq, struct ioq_thread *thread) { } else { #ifdef IORING_SETUP_SUBMIT_ALL // Don't abort submission just because an inline request fails - ioq_ring_probe_flags(¶ms.flags, IORING_SETUP_SUBMIT_ALL); + ioq_ring_probe_flags(¶ms, IORING_SETUP_SUBMIT_ALL); #endif #ifdef IORING_SETUP_R_DISABLED // Don't enable the ring yet (needed for SINGLE_ISSUER) - if (ioq_ring_probe_flags(¶ms.flags, IORING_SETUP_R_DISABLED)) { + if (ioq_ring_probe_flags(¶ms, IORING_SETUP_R_DISABLED)) { # ifdef IORING_SETUP_SINGLE_ISSUER // Allow optimizations assuming only one task submits SQEs - ioq_ring_probe_flags(¶ms.flags, IORING_SETUP_SINGLE_ISSUER); + ioq_ring_probe_flags(¶ms, IORING_SETUP_SINGLE_ISSUER); # endif # ifdef IORING_SETUP_DEFER_TASKRUN // Don't interrupt us aggresively with completion events - ioq_ring_probe_flags(¶ms.flags, IORING_SETUP_DEFER_TASKRUN); + ioq_ring_probe_flags(¶ms, IORING_SETUP_DEFER_TASKRUN); # endif } #endif -- cgit v1.2.3