Recent changes (master)
The following changes since commit d836624b3a7eb3433bdf8f7193b44daacd5ba6d1:
engines/io_uring: don't attempt to set RLIMITs (2020-08-21 16:22:43 -0600)
are available in the Git repository at:
git://git.kernel.dk/fio.git master
for you to fetch changes up to 84106576cefbbd9f5dfa5ee33b245f77938d0269:
t/io_uring: cleanup vectored vs non-vectored (2020-08-22 11:26:39 -0600)
----------------------------------------------------------------
Jens Axboe (3):
engines/io_uring: use non-vectored read/write if available t/io_uring: use non-vectored reads if available t/io_uring: cleanup vectored vs non-vectored
engines/io_uring.c | 37 +++++++++++++++ os/linux/io_uring.h | 131 +++++++++++++++++++++++++++++++++++++++++++++++----- t/io_uring.c | 32 +++++++++++++ 3 files changed, 188 insertions(+), 12 deletions(-)
---
Diff of recent changes:
engines/io_uring.c +37 -0
@@ -174,6 +174,7 @@ static struct fio_option options[] = { .lname = "Non-vectored", .type = FIO_OPT_INT, .off1 = offsetof(struct ioring_options, nonvectored), + .def = "-1", .help = "Use non-vectored read/write commands", .category = FIO_OPT_C_ENGINE, .group = FIO_OPT_G_IOURING,
@@ -547,6 +548,40 @@ static int fio_ioring_mmap(struct ioring_data *ld, struct io_uring_params *p)return 0 ; } +static void fio_ioring_probe (struct thread_data *td) +{ +struct ioring_data *ld = td->io_ops_data; +struct ioring_options *o = td->eo; +struct io_uring_probe *p; +int ret; + +/* already set by user, don't touch */ +if (o->nonvectored !=-1 ) +return ; + +/* default to off, as that's always safe */ + o->nonvectored =0 ; + + p =malloc (sizeof (*p) +256 *sizeof (struct io_uring_probe_op )); +if (!p) +return ; + +memset (p,0 ,sizeof (*p) +256 *sizeof (struct io_uring_probe_op )); + ret =syscall (__NR_io_uring_register, ld->ring_fd, +IORING_REGISTER_PROBE , p,256 ); +if (ret <0 ) + goto out; + +if (IORING_OP_WRITE > p->ops_len) + goto out; + +if ((p->ops[IORING_OP_READ ].flags &IO_URING_OP_SUPPORTED ) && + (p->ops[IORING_OP_WRITE ].flags &IO_URING_OP_SUPPORTED )) + o->nonvectored =1 ; +out: +free (p); +} +static int fio_ioring_queue_init (struct thread_data *td) {struct ioring_data *ld = td->io_ops_data;
@@ -573,6 +608,8 @@ static int fio_ioring_queue_init(struct thread_data *td) ld->ring_fd = ret; +fio_ioring_probe (td); +if (o->fixedbufs) { ret =syscall (__NR_io_uring_register, ld->ring_fd,IORING_REGISTER_BUFFERS , ld->iovecs, depth);
os/linux/io_uring.h +119 -12
225 lines not on this page · raw message
t/io_uring.c +32 -0
@@ -94,6 +94,8 @@ static int sq_thread_poll = 0; /* use kernel submission/poller thread */static int sq_thread_cpu =-1 ;/* pin above thread to this CPU */ static int do_nop =0 ;/* no-op SQ ring commands */ +static int vectored =1 ; +static int io_uring_register_buffers (struct submitter *s) {if (do_nop)
@@ -125,6 +127,29 @@ static int io_uring_setup(unsigned entries, struct io_uring_params *p)return syscall (__NR_io_uring_setup, entries, p); } +static void io_uring_probe (int fd) +{ +struct io_uring_probe *p; +int ret; + + p =malloc (sizeof (*p) +256 *sizeof (struct io_uring_probe_op )); +if (!p) +return ; + +memset (p,0 ,sizeof (*p) +256 *sizeof (struct io_uring_probe_op )); + ret =syscall (__NR_io_uring_register, fd,IORING_REGISTER_PROBE , p,256 ); +if (ret <0 ) + goto out; + +if (IORING_OP_READ > p->ops_len) + goto out; + +if ((p->ops[IORING_OP_READ ].flags &IO_URING_OP_SUPPORTED )) + vectored =0 ; +out: +free (p); +} +static int io_uring_enter (struct submitter *s,unsigned int to_submit,unsigned int min_complete,unsigned int flags) {
@@ -184,6 +209,11 @@ static void init_io(struct submitter *s, unsigned index) sqe->addr = (unsigned long ) s->iovecs[index].iov_base; sqe->len = bs; sqe->buf_index = index; + }else if (!vectored) { + sqe->opcode =IORING_OP_READ ; + sqe->addr = (unsigned long ) s->iovecs[index].iov_base; + sqe->len = bs; + sqe->buf_index =0 ; }else { sqe->opcode =IORING_OP_READV ; sqe->addr = (unsigned long ) &s->iovecs[index];
@@ -414,6 +444,8 @@ static int setup_ring(struct submitter *s) } s->ring_fd = fd; +io_uring_probe (fd); +if (fixedbufs) { ret =io_uring_register_buffers (s);if (ret <0 ) {