Skip to contentSkip to conversation

rsrc tests and fixes

PATCH Applied Pavel Begunkov 2 participants 6 messages May 7, 2021 io_uring

lore
Share & tools
lore
#0 lore raw

cover rsrc tests and fixes

1-2: rsrc tagging, buffer update, rsrc register, etc. tests 3-4: small tests fixes

Pavel Begunkov (4):
sync io_uring.h API file with Linux 5.13
tests: add rsrc tags tests
tests: fix timeout-new for old kernels
tests: fix minor connect flaws

 src/include/liburing/io_uring.h |  41 ++-
 test/Makefile                   |   2 +
 test/connect.c                  |   8 +-
 test/rsrc_tags.c                | 431 ++++++++++++++++++++++++++++++++
 test/timeout-new.c              |   2 +-
 5 files changed, 471 insertions(+), 13 deletions(-)
 create mode 100644 test/rsrc_tags.c
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/4 sync io_uring.h API file with Linux 5.13

Add resource tagging and registation and multi-polling definitions, and align space/tabs with the kernel.

---
 src/include/liburing/io_uring.h | 41 ++++++++++++++++++++++++++-------
 1 file changed, 33 insertions(+), 8 deletions(-)
src/include/liburing/io_uring.h +33 -8
index eed991d..5a3cb90 100644
@@ -168,16 +168,16 @@ enum {
  * POLL_ADD flags. Note that since sqe->poll_events is the flag space, the
  * command flags for POLL_ADD are stored in sqe->len.
  *
- * IORING_POLL_ADD_MULTI        Multishot poll. Sets IORING_CQE_F_MORE if
- *                              the poll handler will continue to report
- *                              CQEs on behalf of the same SQE.
+ * IORING_POLL_ADD_MULTI	Multishot poll. Sets IORING_CQE_F_MORE if
+ *				the poll handler will continue to report
+ *				CQEs on behalf of the same SQE.
  *
- * IORING_POLL_UPDATE           Update existing poll request, matching
- *                              sqe->addr as the old user_data field.
+ * IORING_POLL_UPDATE		Update existing poll request, matching
+ *				sqe->addr as the old user_data field.
  */
-#define IORING_POLL_ADD_MULTI   (1U << 0)
-#define IORING_POLL_UPDATE_EVENTS       (1U << 1)
-#define IORING_POLL_UPDATE_USER_DATA    (1U << 2)
+#define IORING_POLL_ADD_MULTI	(1U << 0)
+#define IORING_POLL_UPDATE_EVENTS	(1U << 1)
+#define IORING_POLL_UPDATE_USER_DATA	(1U << 2)
 
 /*
  * IO completion data structure (Completion Queue Entry)
@@ -192,8 +192,10 @@ struct io_uring_cqe {
  * cqe->flags
  *
  * IORING_CQE_F_BUFFER	If set, the upper 16 bits are the buffer ID
+ * IORING_CQE_F_MORE	If set, parent SQE will generate more CQE entries
  */
 #define IORING_CQE_F_BUFFER		(1U << 0)
+#define IORING_CQE_F_MORE		(1U << 1)
 
 enum {
 	IORING_CQE_BUFFER_SHIFT		= 16,
@@ -301,6 +303,8 @@ enum {
 	IORING_UNREGISTER_PERSONALITY		= 10,
 	IORING_REGISTER_RESTRICTIONS		= 11,
 	IORING_REGISTER_ENABLE_RINGS		= 12,
+	IORING_REGISTER_RSRC			= 13,
+	IORING_REGISTER_RSRC_UPDATE		= 14,
 
 	/* this goes last */
 	IORING_REGISTER_LAST
@@ -313,12 +317,33 @@ struct io_uring_files_update {
 	__aligned_u64 /* __s32 * */ fds;
 };
 
+enum {
+	IORING_RSRC_FILE		= 0,
+	IORING_RSRC_BUFFER		= 1,
+};
+
+struct io_uring_rsrc_register {
+	__u32 type;
+	__u32 nr;
+	__aligned_u64 data;
+	__aligned_u64 tags;
+};
+
 struct io_uring_rsrc_update {
 	__u32 offset;
 	__u32 resv;
 	__aligned_u64 data;
 };
 
+struct io_uring_rsrc_update2 {
+	__u32 offset;
+	__u32 resv;
+	__aligned_u64 data;
+	__aligned_u64 tags;
+	__u32 type;
+	__u32 nr;
+};
+
 /* Skip updating fd indexes set to this value in the fd table */
 #define IORING_REGISTER_FILES_SKIP	(-2)
 
Signature · 1 line
2.31.1
#2 lore raw

PATCH 2/4 tests: add rsrc tags tests

In reply to Pavel Begunkov

Test rsrc tagging, updates, new registration opcodes for buffers and files.

---
 test/Makefile    |   2 +
 test/rsrc_tags.c | 431 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 433 insertions(+)
 create mode 100644 test/rsrc_tags.c
test/Makefile +2 -0
index 2a1985b..a312409 100644
@@ -115,6 +115,7 @@ test_targets += \
 	unlink \
 	wakeup-hang \
 	sendmsg_fs_cve \
+	rsrc_tags \
 	# EOL
 
 all_targets += $(test_targets)
@@ -253,6 +254,7 @@ test_srcs := \
 	unlink.c \
 	wakeup-hang.c \
 	sendmsg_fs_cve.c \
+	rsrc_tags.c \
 	# EOL
 
 test_objs := $(patsubst %.c,%.ol,$(patsubst %.cc,%.ol,$(test_srcs)))
test/rsrc_tags.c new file +431 -0

431 lines not on this page · raw message

Signature · 1 line
2.31.1
#3 lore raw

PATCH 3/4 tests: fix timeout-new for old kernels

In reply to Pavel Begunkov

Users report timeout-new fails. Don't return an error for older kernels not supporting IORING_FEAT_EXT_ARG, just skip it.

---
 test/timeout-new.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/timeout-new.c +1 -1
index 45b9a14..b0bb5ee 100644
@@ -203,7 +203,7 @@ int main(int argc, char *argv[])
 	}
 	if (!(ring_normal.features & IORING_FEAT_EXT_ARG)) {
 		fprintf(stderr, "feature IORING_FEAT_EXT_ARG not supported.\n");
-		return 1;
+		return 0;
 	}
 
 	ret = test_return_before_timeout(&ring_normal);
Signature · 1 line
2.31.1
#4 lore raw

PATCH 4/4 tests: fix minor connect flaws

In reply to Pavel Begunkov

Use inet_aton() to set address, otherwise can lead to problems depending on endianness.

Also, set user_data only after io_uring_prep_link_timeout(), otherwise will be rewritten.

---
 test/connect.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
test/connect.c +4 -4
index ab81bb8..91b5578 100644
@@ -14,6 +14,7 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
+#include <arpa/inet.h>
 
 #include "liburing.h"
 
@@ -125,9 +126,8 @@ static int configure_connect(int fd, struct sockaddr_in* addr)
 	memset(addr, 0, sizeof(*addr));
 	addr->sin_family = AF_INET;
 	addr->sin_port = use_port;
-	addr->sin_addr.s_addr = 0x0100007fU;
-
-	return 0;
+	ret = inet_aton("127.0.0.1", &addr->sin_addr);
+	return ret;
 }
 
 static int connect_socket(struct io_uring *ring, int fd, int *code)
@@ -292,9 +292,9 @@ static int test_connect_timeout(struct io_uring *ring)
 		fprintf(stderr, "unable to get sqe\n");
 		goto err;
 	}
+	io_uring_prep_link_timeout(sqe, &ts, 0);
 	sqe->user_data = 2;
 
-	io_uring_prep_link_timeout(sqe, &ts, 0);
 	ret = io_uring_submit(ring);
 	if (ret != 2) {
 		fprintf(stderr, "submitted %d\n", ret);
Signature · 1 line
2.31.1
maintainer Applied
#5 lore raw
In reply to Pavel Begunkov
Quoted 9 lines · Pavel Begunkov

1-2: rsrc tagging, buffer update, rsrc register, etc. tests 3-4: small tests fixes

Pavel Begunkov (4):
sync io_uring.h API file with Linux 5.13
tests: add rsrc tags tests
tests: fix timeout-new for old kernels
tests: fix minor connect flaws

Quoted 7 lines
 src/include/liburing/io_uring.h |  41 ++-
 test/Makefile                   |   2 +
 test/connect.c                  |   8 +-
 test/rsrc_tags.c                | 431 ++++++++++++++++++++++++++++++++
 test/timeout-new.c              |   2 +-
 5 files changed, 471 insertions(+), 13 deletions(-)
 create mode 100644 test/rsrc_tags.c

Applied, thanks.

Signature · 1 line
Jens Axboe