From 7c70f506e4382b49e97c9623cf04d645ee1cec25 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 3 Sep 2020 08:23:21 -0600 Subject: [PATCH] engines/io_uring: move sqe clear out of hot path We just need to ensure we set the stuff we need, then we can avoid a full memset of the sqe in the hot path. Signed-off-by: Jens Axboe --- engines/io_uring.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/engines/io_uring.c b/engines/io_uring.c index ec8cb18a..44b3c533 100644 --- a/engines/io_uring.c +++ b/engines/io_uring.c @@ -218,9 +218,6 @@ static int fio_ioring_prep(struct thread_data *td, struct io_u *io_u) sqe = &ld->sqes[io_u->index]; - /* zero out fields not used in this submission */ - memset(sqe, 0, sizeof(*sqe)); - if (o->registerfiles) { sqe->fd = f->engine_pos; sqe->flags = IOSQE_FIXED_FILE; @@ -262,13 +259,18 @@ static int fio_ioring_prep(struct thread_data *td, struct io_u *io_u) if (ld->ioprio_set) sqe->ioprio |= td->o.ioprio; sqe->off = io_u->offset; + sqe->rw_flags = 0; } else if (ddir_sync(io_u->ddir)) { + sqe->ioprio = 0; if (io_u->ddir == DDIR_SYNC_FILE_RANGE) { sqe->off = f->first_write; sqe->len = f->last_write - f->first_write; sqe->sync_range_flags = td->o.sync_file_range; sqe->opcode = IORING_OP_SYNC_FILE_RANGE; } else { + sqe->off = 0; + sqe->addr = 0; + sqe->len = 0; if (io_u->ddir == DDIR_DATASYNC) sqe->fsync_flags |= IORING_FSYNC_DATASYNC; sqe->opcode = IORING_OP_FSYNC; @@ -681,6 +683,13 @@ static int fio_ioring_post_init(struct thread_data *td) return 1; } + for (i = 0; i < td->o.iodepth; i++) { + struct io_uring_sqe *sqe; + + sqe = &ld->sqes[i]; + memset(sqe, 0, sizeof(*sqe)); + } + if (o->registerfiles) { err = fio_ioring_register_files(td); if (err) { -- 2.25.1