Skip to contentSkip to conversation

6.0 updates

PATCH Superseded Dylan Yudaken 2 participants 4 messages Sep 26, 2022 io_uring

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover 6.0 updates

Two liburing updates for 6.0:

Patch 1 updates to account for the single issuer ring being assigned at ring creation time.

Patch 2 updates man pages from 5.20 -> 6.0

Dylan Yudaken (2):
handle single issuer task registration at ring creation update documentation to reflect no 5.20 kernel

 man/io_uring_prep_recv.3    |  2 +-
 man/io_uring_prep_recvmsg.3 |  2 +-
 man/io_uring_setup.2        |  8 ++++----
 test/defer-taskrun.c        | 12 ++++--------
 test/single-issuer.c        | 14 +++++++-------
 5 files changed, 17 insertions(+), 21 deletions(-)

base-commit: 1cba5d6c9e41e2f55ac4c3f93f5e05f9b5082a3e

Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 handle single issuer task registration at ring creation

IORING_SETUP_SINGLE_ISSUER now registers the task at ring creation, so update the tests and documentation to reflect this.

---
 man/io_uring_setup.2 |  8 ++++----
 test/defer-taskrun.c | 12 ++++--------
 test/single-issuer.c | 14 +++++++-------
 3 files changed, 15 insertions(+), 19 deletions(-)
man/io_uring_setup.2 +4 -4
index fb1f90dc2ebc..afeee858c458 100644
@@ -241,14 +241,14 @@ only the
 passthrough command for NVMe passthrough needs this. Available since 5.19.
 .TP
 .B IORING_SETUP_SINGLE_ISSUER
-A hint to the kernel that only a single task can submit requests, which is used
-for internal optimisations. The kernel enforces the rule, which only affects
+A hint to the kernel that only a single task (or thread) will submit requests, which is
+used for internal optimisations. This task must be the one that created the ring, and
+the kernel enforces this rule. This only affects
 .I
 io_uring_enter(2)
 calls submitting requests and will fail them with
 .B -EEXIST
 if the restriction is violated.
-The submitter task may differ from the task that created the ring.
 Note that when
 .B IORING_SETUP_SQPOLL
 is set it is considered that the polling task is doing all submissions
@@ -256,7 +256,7 @@ on behalf of the userspace and so it always complies with the rule disregarding
 how many userspace tasks do
 .I
 io_uring_enter(2).
-Available since 5.20.
+Available since 6.0.
 .TP
 .B IORING_SETUP_DEFER_TASKRUN
 By default, io_uring will process all outstanding work at the end of any system
test/defer-taskrun.c +4 -8
index c6e0ea0d6c99..2c4ed6df37d3 100644
@@ -123,6 +123,9 @@ void *thread(void *t)
 {
 	struct thread_data *td = t;
 
+	assert(io_uring_queue_init(8, &td->ring, IORING_SETUP_SINGLE_ISSUER |
+					IORING_SETUP_DEFER_TASKRUN) == 0);
+
 	io_uring_prep_read(io_uring_get_sqe(&td->ring), td->efd, td->buff, sizeof(td->buff), 0);
 	io_uring_submit(&td->ring);
 
@@ -132,23 +135,16 @@ void *thread(void *t)
 static int test_thread_shutdown(void)
 {
 	pthread_t t1;
-	int ret;
 	struct thread_data td;
 	struct io_uring_cqe *cqe;
 	uint64_t val = 1;
 
-	ret = io_uring_queue_init(8, &td.ring, IORING_SETUP_SINGLE_ISSUER |
-					       IORING_SETUP_DEFER_TASKRUN);
-	if (ret)
-		return ret;
-
-	CHECK(io_uring_get_events(&td.ring) == -EEXIST);
-
 	td.efd = eventfd(0, 0);
 	CHECK(td.efd >= 0);
 
 	CHECK(pthread_create(&t1, NULL, thread, &td) == 0);
 	CHECK(pthread_join(t1, NULL) == 0);
+	CHECK(io_uring_get_events(&td.ring) == -EEXIST);
 
 	CHECK(write(td.efd, &val, sizeof(val)) == sizeof(val));
 	CHECK(io_uring_wait_cqe(&td.ring, &cqe) == -EEXIST);
test/single-issuer.c +7 -7
index 29830f1af998..55af98f300aa 100644
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
 	if (!fork_t()) {
 		ret = try_submit(&ring);
 		if (ret != -EEXIST)
-			fprintf(stderr, "not owner child could submit %i\n", ret);
+			fprintf(stderr, "1: not owner child could submit %i\n", ret);
 		return ret != -EEXIST;
 	}
 	wait_child_t();
@@ -109,9 +109,9 @@ int main(int argc, char *argv[])
 
 	if (!fork_t()) {
 		ret = try_submit(&ring);
-		if (ret)
-			fprintf(stderr, "not owner child could submit %i\n", ret);
-		return !!ret;
+		if (ret != -EEXIST)
+			fprintf(stderr, "2: not owner child could submit %i\n", ret);
+		return ret != -EEXIST;
 	}
 	wait_child_t();
 	io_uring_queue_exit(&ring);
@@ -143,9 +143,9 @@ int main(int argc, char *argv[])
 
 	if (!fork_t()) {
 		ret = try_submit(&ring);
-		if (ret)
-			fprintf(stderr, "not owner child could submit %i\n", ret);
-		return !!ret;
+		if (ret != -EEXIST)
+			fprintf(stderr, "3: not owner child could submit %i\n", ret);
+		return ret != -EEXIST;
 	}
 	wait_child_t();
 	io_uring_queue_exit(&ring);
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/2 update documentation to reflect no 5.20 kernel

In reply to Dylan Yudaken

The documentation referenced the wrong kernel version.

---
 man/io_uring_prep_recv.3    | 2 +-
 man/io_uring_prep_recvmsg.3 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
man/io_uring_prep_recv.3 +1 -1
index 60a77fc241b5..b3862369affa 100644
@@ -55,7 +55,7 @@ If a posted CQE does not have the
 .B IORING_CQE_F_MORE
 flag set then the multishot receive will be done and the application should issue a
 new request.
-Multishot variants are available since kernel 5.20.
+Multishot variants are available since kernel 6.0.
 
 
 After calling this function, additional io_uring internal modifier flags
man/io_uring_prep_recvmsg.3 +1 -1
index 07096ee4826c..65f324dfef9b 100644
@@ -65,7 +65,7 @@ submitted with the request. See
 .B io_uring_recvmsg_out (3)
 for more information on accessing the data.
 
-Multishot variants are available since kernel 5.20.
+Multishot variants are available since kernel 6.0.
 
 After calling this function, additional io_uring internal modifier flags
 may be set in the SQE
Signature · 1 line
2.30.2
maintainer
#3 lore raw
In reply to Dylan Yudaken
Quoted 6 lines · Dylan Yudaken

Two liburing updates for 6.0:

Patch 1 updates to account for the single issuer ring being assigned at ring creation time.

Patch 2 updates man pages from 5.20 -> 6.0

I'll wait for a v2 of this one as well, as at least the documentation will need updating for v2 of the kernel side.

Signature · 1 line
Jens Axboe