Skip to content

Commit 7272fd8

Browse files
committed
t/io_uring: use IORING_SETUP_NO_SQARRAY if available
The SQEs array indirection is not necessary for this test app. Use IORING_SETUP_NO_SQARRAY if it's available. Signed-off-by: Jens Axboe <[email protected]>
1 parent 0936137 commit 7272fd8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

t/io_uring.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ static int io_uring_setup(unsigned entries, struct io_uring_params *p)
439439
p->flags |= IORING_SETUP_COOP_TASKRUN;
440440
p->flags |= IORING_SETUP_SINGLE_ISSUER;
441441
p->flags |= IORING_SETUP_DEFER_TASKRUN;
442+
p->flags |= IORING_SETUP_NO_SQARRAY;
442443
retry:
443444
ret = syscall(__NR_io_uring_setup, entries, p);
444445
if (!ret)
@@ -456,6 +457,10 @@ static int io_uring_setup(unsigned entries, struct io_uring_params *p)
456457
p->flags &= ~IORING_SETUP_DEFER_TASKRUN;
457458
goto retry;
458459
}
460+
if (errno == EINVAL && p->flags & IORING_SETUP_NO_SQARRAY) {
461+
p->flags &= ~IORING_SETUP_NO_SQARRAY;
462+
goto retry;
463+
}
459464

460465
return ret;
461466
}
@@ -941,9 +946,14 @@ static int setup_ring(struct submitter *s)
941946
sring->ring_mask = ptr + p.sq_off.ring_mask;
942947
sring->ring_entries = ptr + p.sq_off.ring_entries;
943948
sring->flags = ptr + p.sq_off.flags;
944-
sring->array = ptr + p.sq_off.array;
945949
sq_ring_mask = *sring->ring_mask;
946950

951+
if (!(p.flags & IORING_SETUP_NO_SQARRAY)) {
952+
sring->array = ptr + p.sq_off.array;
953+
for (i = 0; i < p.sq_entries; i++)
954+
sring->array[i] = i;
955+
}
956+
947957
if (p.flags & IORING_SETUP_SQE128)
948958
len = 2 * p.sq_entries * sizeof(struct io_uring_sqe);
949959
else
@@ -969,9 +979,6 @@ static int setup_ring(struct submitter *s)
969979
cring->cqes = ptr + p.cq_off.cqes;
970980
cq_ring_mask = *cring->ring_mask;
971981

972-
for (i = 0; i < p.sq_entries; i++)
973-
sring->array[i] = i;
974-
975982
s->per_file_depth = INT_MAX;
976983
if (s->nr_files)
977984
s->per_file_depth = (depth + s->nr_files - 1) / s->nr_files;

0 commit comments

Comments
 (0)