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)
commitff9b6876955e3d4c8f95a168197eb9301924140f
tree69a3e8dfc8337f0c5053823ec0115ff9d87f8ec4
parent87b69ef2a2e6c9d4810cd0b13be1807d074e71c9
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 <niklas.cassel@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/io_uring.c