engines/io_uring: move sqe clear out of hot path
authorJens Axboe <axboe@kernel.dk>
Thu, 3 Sep 2020 14:23:21 +0000 (08:23 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 3 Sep 2020 14:23:21 +0000 (08:23 -0600)
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 <axboe@kernel.dk>
engines/io_uring.c

index ec8cb18a354ee9f7ea6a29d31744a9a71836b24a..44b3c533e288e7e8c3a5bf91f59bbc1b19818c44 100644 (file)
@@ -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) {