Skip to content

Commit

Permalink
Update ring resizing for DEFER_TASKRUN
Browse files Browse the repository at this point in the history
For now, the kernel side is limited to only supporting DEFER_TASKRUN
for ring resizing. Reflect that in the man page, and in the test case
as well.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Dec 19, 2024
1 parent 6aeac20 commit 69e0bc2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 11 additions & 0 deletions man/io_uring_resize_rings.3
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ Currently doesn't support resizing rings setup with
.B IORING_SETUP_NO_MMAP .
This is purely a liburing limitation, the kernel does support it.

Also note that ring resizing is currently only supported on rings setup
with
.B IORING_SETUP_DEFER_TASKRUN .
Attempting to resize differently configured rings will result in an
.BR -EINVAL
error.

Valid flags in
.IR flags :
.TP
Expand Down Expand Up @@ -98,6 +105,10 @@ was unsuccessful.
.B -EINVAL
Invalid flags were specified for the operation
.TP
.B -EINVAL
Attempt to resize a ring not setup with
.BR IORING_SETUP_DEFER_TASKRUN .
.TP
.B -EOVERFLOW
The values specified for SQ or CQ entries would cause an overflow.

Expand Down
16 changes: 15 additions & 1 deletion test/resize-rings.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "liburing.h"
#include "helpers.h"

static bool only_defer, no_defer;

#define NVECS 128

#define min(a, b) ((a) < (b) ? (a) : (b))
Expand Down Expand Up @@ -548,6 +550,11 @@ static int test(int flags, int fd, int async)
struct io_uring ring;
int ret;

if (no_defer)
return T_EXIT_SKIP;
if (!(flags & IORING_SETUP_DEFER_TASKRUN) && only_defer)
return T_EXIT_SKIP;

ret = io_uring_queue_init_params(8, &ring, &p);
if (ret < 0) {
fprintf(stderr, "ring setup failed: %d\n", ret);
Expand All @@ -556,6 +563,12 @@ static int test(int flags, int fd, int async)

ret = test_basic(&ring, async);
if (ret == T_EXIT_SKIP) {
if (!(flags & IORING_SETUP_DEFER_TASKRUN)) {
io_uring_queue_exit(&ring);
only_defer = true;
} else {
no_defer = true;
}
return T_EXIT_SKIP;
} else if (ret == T_EXIT_FAIL) {
fprintf(stderr, "test_basic %x failed\n", flags);
Expand Down Expand Up @@ -615,7 +628,7 @@ int main(int argc, char *argv[])

ret = test(0, fd, 0);
if (ret == T_EXIT_SKIP)
return T_EXIT_SKIP;
goto try_defer;
else if (ret == T_EXIT_FAIL)
return T_EXIT_FAIL;

Expand All @@ -631,6 +644,7 @@ int main(int argc, char *argv[])
if (ret == T_EXIT_FAIL)
return T_EXIT_FAIL;

try_defer:
ret = test(IORING_SETUP_SINGLE_ISSUER | IORING_SETUP_DEFER_TASKRUN, fd, 0);
if (ret == T_EXIT_FAIL)
return T_EXIT_FAIL;
Expand Down

0 comments on commit 69e0bc2

Please sign in to comment.