io_uring: fix misbehaving cmdprio_percentage option
authorNiklas Cassel <niklas.cassel@wdc.com>
Thu, 26 Aug 2021 16:45:05 +0000 (16:45 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 26 Aug 2021 16:50:03 +0000 (10:50 -0600)
Commit 7c70f506e438 ("engines/io_uring: move sqe clear out of hot path")
removed the memset of sqe from fio_ioring_prep().

Before this commit, fio_ioring_prio_prep() behaved properly, because
sqe->ioprio was always cleared by the memset in fio_ioring_prep().

cmdprio_percentage=20 is supposed to set the highest priority class for
20% of the total I/Os, however, because sqes got reused without clearing
the ioprio field, this meant that the number of I/Os sent with the highest
priority became 95% already after 10 seconds. Quite far off from the
intended 20%.

Fix this by explicitly clearing the priority in fio_ioring_prio_prep().
Note that prio/prioclass cannot be used together with cmdprio_percentage,
so we do not need to do an additional clear in fio_ioring_prep().

engines/libaio.c doesn't explicitly clear the ioprio, nor does it memset
the descriptor entry, this is because io_prep_pread()/io_prep_pwrite() in
libaio itself performs a memset.

Fixes: 7c70f506e438 ("engines/io_uring: move sqe clear out of hot path")
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/io_uring.c

index 269e501f5dd0007c9566ee71bf0bf27b66e80359..600fba66f6f0a9e97301bb94851c391b7bb823c5 100644 (file)
@@ -384,6 +384,8 @@ static void fio_ioring_prio_prep(struct thread_data *td, struct io_u *io_u)
        if (rand_between(&td->prio_state, 0, 99) < o->cmdprio_percentage) {
                ld->sqes[io_u->index].ioprio = IOPRIO_CLASS_RT << IOPRIO_CLASS_SHIFT;
                io_u->flags |= IO_U_F_PRIORITY;
+       } else {
+               ld->sqes[io_u->index].ioprio = 0;
        }
        return;
 }