Skip to content

Commit 80d72cb

Browse files
lreeze123axboe
authored andcommitted
t/io_uring: Vectored fixed buffer test support for nvme passthrough path
The current kernel NVMe passthrough path already supports vectored IO when using fixed buffers, but fio has not yet adapted it. This patch aims to add a corresponding test interface in fio. Test results: taskset -c 1 t/io_uring -b512 -d64 -c2 -s2 -p1 -F1 -B1 -O0 -n1 -V1 -u1 -r4 /dev/ng1n1 submitter=0, tid=6179, file=/dev/ng1n1, nfiles=1, node=-1 polled=1, fixedbufs=1, register_files=1, buffered=1, QD=64 Engine=io_uring, sq_ring=64, cq_ring=64 IOPS=289.78K, BW=141MiB/s, IOS/call=1/1 IOPS=294.68K, BW=143MiB/s, IOS/call=1/1 IOPS=295.26K, BW=144MiB/s, IOS/call=1/1 Exiting on timeout Maximum IOPS=295.26K taskset -c 1 t/io_uring -b512 -d64 -c2 -s2 -p1 -F1 -B1 -O0 -n1 -V0 -u1 -r4 /dev/ng1n1 submitter=0, tid=6183, file=/dev/ng1n1, nfiles=1, node=-1 polled=1, fixedbufs=1, register_files=1, buffered=1, QD=64 Engine=io_uring, sq_ring=64, cq_ring=64 IOPS=292.31K, BW=142MiB/s, IOS/call=1/1 IOPS=295.79K, BW=144MiB/s, IOS/call=1/1 IOPS=290.78K, BW=141MiB/s, IOS/call=1/1 Exiting on timeout Maximum IOPS=295.79K Signed-off-by: Xiaobing Li <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 2c573a3 commit 80d72cb

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

t/io_uring.c

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,13 @@ static int random_io = 1; /* random or sequential IO */
146146
static int register_ring = 1; /* register ring */
147147
static int use_sync = 0; /* use preadv2 */
148148
static int numa_placement = 0; /* set to node of device */
149+
static int vectored = 0; /* use vectored IO */
149150
static int pt = 0; /* passthrough I/O or not */
150151

151152
static unsigned long tsc_rate;
152153

153154
#define TSC_RATE_FILE "tsc-rate"
154155

155-
static int vectored = 1;
156-
157156
static float plist[] = { 1.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0,
158157
80.0, 90.0, 95.0, 99.0, 99.5, 99.9, 99.95, 99.99 };
159158
static int plist_len = 17;
@@ -461,28 +460,6 @@ static int io_uring_setup(unsigned entries, struct io_uring_params *p)
461460
return ret;
462461
}
463462

464-
static void io_uring_probe(int fd)
465-
{
466-
struct io_uring_probe *p;
467-
int ret;
468-
469-
p = calloc(1, sizeof(*p) + 256 * sizeof(struct io_uring_probe_op));
470-
if (!p)
471-
return;
472-
473-
ret = syscall(__NR_io_uring_register, fd, IORING_REGISTER_PROBE, p, 256);
474-
if (ret < 0)
475-
goto out;
476-
477-
if (IORING_OP_READ > p->ops_len)
478-
goto out;
479-
480-
if ((p->ops[IORING_OP_READ].flags & IO_URING_OP_SUPPORTED))
481-
vectored = 0;
482-
out:
483-
free(p);
484-
}
485-
486463
static int io_uring_enter(struct submitter *s, unsigned int to_submit,
487464
unsigned int min_complete, unsigned int flags)
488465
{
@@ -630,6 +607,12 @@ static void init_io_pt(struct submitter *s, unsigned index)
630607
sqe->uring_cmd_flags = IORING_URING_CMD_FIXED;
631608
sqe->buf_index = 0;
632609
}
610+
if (vectored) {
611+
sqe->cmd_op = NVME_URING_CMD_IO_VEC;
612+
cmd->addr = (unsigned long) &s->iovecs[index];
613+
cmd->data_len = 1;
614+
sqe->buf_index = 0;
615+
}
633616
cmd->nsid = f->nsid;
634617
cmd->opcode = 2;
635618
}
@@ -927,8 +910,6 @@ static int setup_ring(struct submitter *s)
927910
}
928911
s->ring_fd = s->enter_ring_fd = fd;
929912

930-
io_uring_probe(fd);
931-
932913
if (fixedbufs) {
933914
struct rlimit rlim;
934915

@@ -1521,11 +1502,12 @@ static void usage(char *argv, int status)
15211502
" -S <bool> : Use sync IO (preadv2), default %d\n"
15221503
" -X <bool> : Use registered ring %d\n"
15231504
" -P <bool> : Automatically place on device home node %d\n"
1505+
" -V <bool> : Vectored IO, default %d\n"
15241506
" -u <bool> : Use nvme-passthrough I/O, default %d\n",
15251507
argv, DEPTH, BATCH_SUBMIT, BATCH_COMPLETE, BS, polled,
15261508
fixedbufs, register_files, nthreads, !buffered, do_nop,
15271509
stats, runtime == 0 ? "unlimited" : runtime_str, random_io, aio,
1528-
use_sync, register_ring, numa_placement, pt);
1510+
use_sync, register_ring, numa_placement, vectored, pt);
15291511
exit(status);
15301512
}
15311513

@@ -1584,7 +1566,7 @@ int main(int argc, char *argv[])
15841566
if (!do_nop && argc < 2)
15851567
usage(argv[0], 1);
15861568

1587-
while ((opt = getopt(argc, argv, "d:s:c:b:p:B:F:n:N:O:t:T:a:r:D:R:X:S:P:u:h?")) != -1) {
1569+
while ((opt = getopt(argc, argv, "d:s:c:b:p:B:F:n:N:O:t:T:a:r:D:R:X:S:P:V:u:h?")) != -1) {
15881570
switch (opt) {
15891571
case 'a':
15901572
aio = !!atoi(optarg);
@@ -1662,6 +1644,9 @@ int main(int argc, char *argv[])
16621644
case 'P':
16631645
numa_placement = !!atoi(optarg);
16641646
break;
1647+
case 'V':
1648+
vectored = !!atoi(optarg);
1649+
break;
16651650
case 'u':
16661651
pt = !!atoi(optarg);
16671652
break;

0 commit comments

Comments
 (0)