engines/io_uring: don't mess with non power-of-2 queue depth io_uring-depth
authorJens Axboe <axboe@kernel.dk>
Mon, 14 Oct 2024 16:00:36 +0000 (10:00 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 14 Oct 2024 16:00:36 +0000 (10:00 -0600)
io_uring needs the rings to be a power-of-2 in sizing, but it does not
need to be messing with the queue depth driven to the device. Rather
than round everything up, only round up the API parts.

Reported-by: Riley Thomasson <riley@purestorage.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/io_uring.c

index 1b6a4346a3e37ec9591d5cf7a3f61fd3f03121ae..ea1790ec6baa4f78a9afaf378512ff725b447413 100644 (file)
@@ -759,7 +759,8 @@ static enum fio_q_status fio_ioring_queue(struct thread_data *td,
 
        fio_ro_check(td, io_u);
 
-       if (ld->queued == ld->iodepth)
+       /* should not hit... */
+       if (ld->queued == td->o.iodepth)
                return FIO_Q_BUSY;
 
        /* if async trim has been tried and failed, punt to sync */
@@ -995,7 +996,7 @@ static int fio_ioring_queue_init(struct thread_data *td)
 {
        struct ioring_data *ld = td->io_ops_data;
        struct ioring_options *o = td->eo;
-       int depth = td->o.iodepth;
+       int depth = ld->iodepth;
        struct io_uring_params p;
        int ret;
 
@@ -1075,7 +1076,7 @@ static int fio_ioring_cmd_queue_init(struct thread_data *td)
 {
        struct ioring_data *ld = td->io_ops_data;
        struct ioring_options *o = td->eo;
-       int depth = td->o.iodepth;
+       int depth = ld->iodepth;
        struct io_uring_params p;
        int ret;
 
@@ -1220,7 +1221,7 @@ static int fio_ioring_post_init(struct thread_data *td)
                return 1;
        }
 
-       for (i = 0; i < td->o.iodepth; i++) {
+       for (i = 0; i < ld->iodepth; i++) {
                struct io_uring_sqe *sqe;
 
                sqe = &ld->sqes[i];
@@ -1261,7 +1262,7 @@ static int fio_ioring_cmd_post_init(struct thread_data *td)
                return 1;
        }
 
-       for (i = 0; i < td->o.iodepth; i++) {
+       for (i = 0; i < ld->iodepth; i++) {
                struct io_uring_sqe *sqe;
 
                if (o->cmd_type == FIO_URING_CMD_NVME) {
@@ -1319,9 +1320,13 @@ static int fio_ioring_init(struct thread_data *td)
 
        ld = calloc(1, sizeof(*ld));
 
-       /* ring depth must be a power-of-2 */
-       ld->iodepth = td->o.iodepth;
-       td->o.iodepth = roundup_pow2(td->o.iodepth);
+       /*
+        * The internal io_uring queue depth must be a power-of-2, as that's
+        * how the ring interface works. So round that up, in case the user
+        * set iodepth isn't a power-of-2. Leave the fio depth the same, as
+        * not to be driving too much of an iodepth, if we did round up.
+        */
+       ld->iodepth = roundup_pow2(td->o.iodepth);
 
        /* io_u index */
        ld->io_u_index = calloc(td->o.iodepth, sizeof(struct io_u *));
@@ -1351,7 +1356,7 @@ static int fio_ioring_init(struct thread_data *td)
        }
        parse_prchk_flags(o);
 
-       ld->iovecs = calloc(td->o.iodepth, sizeof(struct iovec));
+       ld->iovecs = calloc(ld->iodepth, sizeof(struct iovec));
 
        td->io_ops_data = ld;