From ff9b6876955e3d4c8f95a168197eb9301924140f Mon Sep 17 00:00:00 2001 From: Niklas Cassel Date: Thu, 26 Aug 2021 16:45:05 +0000 Subject: [PATCH] io_uring: fix misbehaving cmdprio_percentage option 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 Signed-off-by: Jens Axboe --- engines/io_uring.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/io_uring.c b/engines/io_uring.c index 269e501f..600fba66 100644 --- a/engines/io_uring.c +++ b/engines/io_uring.c @@ -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; } -- 2.25.1