Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/io_uring: support NO_SQARRAY in miniliburing

Add support for IORING_SETUP_NO_SQARRAY in miniliburing.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
145e0074 73061dbe

+27 -7
+27 -7
tools/include/io_uring/mini_liburing.h
··· 6 6 #include <stdio.h> 7 7 #include <string.h> 8 8 #include <unistd.h> 9 + #include <sys/uio.h> 9 10 10 11 struct io_sq_ring { 11 12 unsigned int *head; ··· 56 55 struct io_uring_sq sq; 57 56 struct io_uring_cq cq; 58 57 int ring_fd; 58 + unsigned flags; 59 59 }; 60 60 61 61 #if defined(__x86_64) || defined(__i386__) ··· 74 72 void *ptr; 75 73 int ret; 76 74 77 - sq->ring_sz = p->sq_off.array + p->sq_entries * sizeof(unsigned int); 75 + if (p->flags & IORING_SETUP_NO_SQARRAY) { 76 + sq->ring_sz = p->cq_off.cqes; 77 + sq->ring_sz += p->cq_entries * sizeof(struct io_uring_cqe); 78 + } else { 79 + sq->ring_sz = p->sq_off.array; 80 + sq->ring_sz += p->sq_entries * sizeof(unsigned int); 81 + } 82 + 78 83 ptr = mmap(0, sq->ring_sz, PROT_READ | PROT_WRITE, 79 84 MAP_SHARED | MAP_POPULATE, fd, IORING_OFF_SQ_RING); 80 85 if (ptr == MAP_FAILED) ··· 92 83 sq->kring_entries = ptr + p->sq_off.ring_entries; 93 84 sq->kflags = ptr + p->sq_off.flags; 94 85 sq->kdropped = ptr + p->sq_off.dropped; 95 - sq->array = ptr + p->sq_off.array; 86 + if (!(p->flags & IORING_SETUP_NO_SQARRAY)) 87 + sq->array = ptr + p->sq_off.array; 96 88 97 89 size = p->sq_entries * sizeof(struct io_uring_sqe); 98 90 sq->sqes = mmap(0, size, PROT_READ | PROT_WRITE, ··· 148 138 if (fd < 0) 149 139 return fd; 150 140 ret = io_uring_mmap(fd, p, &ring->sq, &ring->cq); 151 - if (!ret) 141 + if (!ret) { 152 142 ring->ring_fd = fd; 153 - else 143 + ring->flags = p->flags; 144 + } else { 154 145 close(fd); 146 + } 155 147 return ret; 156 148 } 157 149 ··· 220 208 221 209 ktail = *sq->ktail; 222 210 to_submit = sq->sqe_tail - sq->sqe_head; 223 - for (submitted = 0; submitted < to_submit; submitted++) { 224 - read_barrier(); 225 - sq->array[ktail++ & mask] = sq->sqe_head++ & mask; 211 + 212 + if (!(ring->flags & IORING_SETUP_NO_SQARRAY)) { 213 + for (submitted = 0; submitted < to_submit; submitted++) { 214 + read_barrier(); 215 + sq->array[ktail++ & mask] = sq->sqe_head++ & mask; 216 + } 217 + } else { 218 + ktail += to_submit; 219 + sq->sqe_head += to_submit; 220 + submitted = to_submit; 226 221 } 222 + 227 223 if (!submitted) 228 224 return 0; 229 225