X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Fio_uring.c;h=b962e8041b6f8d113669b4b2a31224a68d19aa0f;hb=6b8cadb66c62394420a39b46af1a2967b916c829;hp=44b3c533e288e7e8c3a5bf91f59bbc1b19818c44;hpb=7c70f506e4382b49e97c9623cf04d645ee1cec25;p=fio.git diff --git a/engines/io_uring.c b/engines/io_uring.c index 44b3c533..b962e804 100644 --- a/engines/io_uring.c +++ b/engines/io_uring.c @@ -66,6 +66,7 @@ struct ioring_data { unsigned iodepth; bool ioprio_class_set; bool ioprio_set; + int prepped; struct ioring_mmap mmap[3]; }; @@ -82,6 +83,7 @@ struct ioring_options { unsigned int nonvectored; unsigned int uncached; unsigned int nowait; + unsigned int force_async; }; static const int ddir_to_op[2][2] = { @@ -197,6 +199,15 @@ static struct fio_option options[] = { .category = FIO_OPT_C_ENGINE, .group = FIO_OPT_G_IOURING, }, + { + .name = "force_async", + .lname = "Force async", + .type = FIO_OPT_INT, + .off1 = offsetof(struct ioring_options, force_async), + .help = "Set IOSQE_ASYNC every N requests", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_IOURING, + }, { .name = NULL, }, @@ -277,6 +288,11 @@ static int fio_ioring_prep(struct thread_data *td, struct io_u *io_u) } } + if (o->force_async && ++ld->prepped == o->force_async) { + ld->prepped = 0; + sqe->flags |= IOSQE_ASYNC; + } + sqe->user_data = (unsigned long) io_u; return 0; } @@ -446,9 +462,10 @@ static int fio_ioring_commit(struct thread_data *td) */ if (o->sqpoll_thread) { struct io_sq_ring *ring = &ld->sq_ring; + unsigned flags; - read_barrier(); - if (*ring->flags & IORING_SQ_NEED_WAKEUP) + flags = atomic_load_acquire(ring->flags); + if (flags & IORING_SQ_NEED_WAKEUP) io_uring_enter(ld, ld->queued, 0, IORING_ENTER_SQ_WAKEUP); ld->queued = 0; @@ -490,7 +507,7 @@ static void fio_ioring_unmap(struct ioring_data *ld) { int i; - for (i = 0; i < ARRAY_SIZE(ld->mmap); i++) + for (i = 0; i < FIO_ARRAY_SIZE(ld->mmap); i++) munmap(ld->mmap[i].ptr, ld->mmap[i].len); close(ld->ring_fd); } @@ -679,7 +696,11 @@ static int fio_ioring_post_init(struct thread_data *td) err = fio_ioring_queue_init(td); if (err) { - td_verror(td, errno, "io_queue_init"); + int init_err = errno; + + if (init_err == ENOSYS) + log_err("fio: your kernel doesn't support io_uring\n"); + td_verror(td, init_err, "io_queue_init"); return 1; } @@ -707,6 +728,12 @@ static int fio_ioring_init(struct thread_data *td) struct ioring_data *ld; struct thread_options *to = &td->o; + if (to->io_submit_mode == IO_MODE_OFFLOAD) { + log_err("fio: io_submit_mode=offload is not compatible (or " + "useful) with io_uring\n"); + return 1; + } + /* sqthread submission requires registered files */ if (o->sqpoll_thread) o->registerfiles = 1; @@ -783,7 +810,7 @@ static int fio_ioring_close_file(struct thread_data *td, struct fio_file *f) static struct ioengine_ops ioengine = { .name = "io_uring", .version = FIO_IOOPS_VERSION, - .flags = FIO_ASYNCIO_SYNC_TRIM, + .flags = FIO_ASYNCIO_SYNC_TRIM | FIO_NO_OFFLOAD, .init = fio_ioring_init, .post_init = fio_ioring_post_init, .io_u_init = fio_ioring_io_u_init,