Skip to contentSkip to conversation

Export io_uring syscall functions

RFC PATCH Superseded Ammar Faizi 2 participants 9 messages Aug 29, 2022 io_uring

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Export io_uring syscall functions

From: Ammar Faizi <[email protected]>

Hi Jens,

The background story of this series comes from the recent conversation with Caleb Sander at:

https://github.com/axboe/liburing/pull/646#issuecomment-1229639532

What do you think of this series?

There are 4 patches in this series.

1) syscall: Add io_uring syscall functions

We have:

man 2 io_uring_setup;
man 2 io_uring_enter;
man 2 io_uring_register;

Those entries say that io_uring syscall functions are declared in <linux/io_uring.h>. But they don't actually exist and never existed. This is causing confusion for people who read the manpage. Let's just implement them in liburing so they exist.

This also allows the user to invoke io_uring syscalls directly instead of using the full liburing provided setup.

2) Clarify "man 2" entry for io_uring.

io_uring_enter(), io_uring_register(), io_uring_setup() are not declared in <linux/io_uring.h> and never were. Plus, these functions don't intentionally set the errno variable. Reflect this fact in the manpage.

Side note: On architectures other than x86, x86-64, and aarch64, those functions _do_ set the errno, this is because the syscall is done via libc as we don't yet have nolibc support for the mentioned archs. Users should not rely on this behavior.

3) man: Alias io_uring_enter2() to io_uring_enter().

We have a new function io_uring_enter2(), add the man page entry for it by aliasing it to io_uring_enter(). This aliased man entry has already explained it.

4) test/io_uring_{enter,setup,register}: Use the exported syscall functions.

These tests use the internal definition of __sys_io_uring* functions. A previous commit exported new functions that do the same thing with those __sys_io_uring* functions. Test the exported functions instead of the internal functions.

No functional change is intended.

---

Ammar Faizi (4):
syscall: Add io_uring syscall functions
man: Clarify "man 2" entry for io_uring syscalls
man: Alias io_uring_enter2() to io_uring_enter() test/io_uring_{enter,setup,register}: Use the exported syscall functions

 man/io_uring_enter.2     |  9 ++++-----
 man/io_uring_enter2.2    |  1 +
 man/io_uring_register.2  |  9 ++++-----
 man/io_uring_setup.2     |  8 +++-----
 src/Makefile             |  2 +-
 src/include/liburing.h   |  8 ++++++++
 src/liburing.map         |  4 ++++
 src/syscall.c            | 30 ++++++++++++++++++++++++++++++
 test/io_uring_enter.c    | 10 +++++-----
 test/io_uring_register.c | 34 ++++++++++++++++------------------
 test/io_uring_setup.c    |  4 ++--
 11 files changed, 78 insertions(+), 41 deletions(-)
 create mode 120000 man/io_uring_enter2.2
 create mode 100644 src/syscall.c

base-commit: bf248850dc2ae45d29d4fdde688e90d24f3dd6d2

Signature · 1 line
Ammar Faizi
#1 lore raw

RFC PATCH 1/4 syscall: Add io_uring syscall functions

From: Ammar Faizi <[email protected]>

We have:

man 2 io_uring_setup;
man 2 io_uring_enter;
man 2 io_uring_register;

Those entries say that io_uring syscall functions are declared in <linux/io_uring.h>. But they don't actually exist and never existed. This is causing confusion for people who read the manpage. Let's just implement them in liburing so they exist.

This also allows the user to invoke io_uring syscalls directly instead of using the full liburing provided setup.

---
 src/Makefile           |  2 +-
 src/include/liburing.h |  8 ++++++++
 src/liburing.map       |  4 ++++
 src/syscall.c          | 30 ++++++++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 src/syscall.c
src/Makefile +1 -1
index dad379d..73a98ba 100644
@@ -32,7 +32,7 @@ endif
 
 all: $(all_targets)
 
-liburing_srcs := setup.c queue.c register.c
+liburing_srcs := setup.c queue.c register.c syscall.c
 
 ifeq ($(CONFIG_NOLIBC),y)
 	liburing_srcs += nolibc.c
src/include/liburing.h +8 -0
index 66c5095..7db1ea9 100644
@@ -202,6 +202,14 @@ int io_uring_register_file_alloc_range(struct io_uring *ring,
 int io_uring_register_notifications(struct io_uring *ring, unsigned nr,
 				    struct io_uring_notification_slot *slots);
 int io_uring_unregister_notifications(struct io_uring *ring);
+int io_uring_enter(unsigned int fd, unsigned int to_submit,
+		   unsigned int min_complete, unsigned int flags,
+		   sigset_t *sig);
+int io_uring_enter2(int fd, unsigned to_submit, unsigned min_complete,
+		    unsigned flags, sigset_t *sig, int sz);
+int io_uring_setup(unsigned entries, struct io_uring_params *p);
+int io_uring_register(int fd, unsigned opcode, const void *arg,
+		      unsigned nr_args);
 
 /*
  * Helper for the peek/wait single cqe functions. Exported because of that,
src/liburing.map +4 -0
index 7d8f143..8573dfc 100644
@@ -62,4 +62,8 @@ LIBURING_2.3 {
 		io_uring_register_file_alloc_range;
 		io_uring_register_notifications;
 		io_uring_unregister_notifications;
+		io_uring_enter;
+		io_uring_enter2;
+		io_uring_setup;
+		io_uring_register;
 } LIBURING_2.2;
src/syscall.c new file +30 -0
new file mode 100644
index 0000000..fcc6808
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: MIT */
+
+#include "lib.h"
+#include "syscall.h"
+#include <liburing.h>
+
+int io_uring_enter(unsigned int fd, unsigned int to_submit,
+		   unsigned int min_complete, unsigned int flags,
+		   sigset_t *sig)
+{
+	return __sys_io_uring_enter(fd, to_submit, min_complete, flags, sig);
+}
+
+int io_uring_enter2(int fd, unsigned to_submit, unsigned min_complete,
+		    unsigned flags, sigset_t *sig, int sz)
+{
+	return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
+				     sz);
+}
+
+int io_uring_setup(unsigned entries, struct io_uring_params *p)
+{
+	return __sys_io_uring_setup(entries, p);
+}
+
+int io_uring_register(int fd, unsigned opcode, const void *arg,
+		      unsigned nr_args)
+{
+	return __sys_io_uring_register(fd, opcode, arg, nr_args);
+}
Signature · 1 line
Ammar Faizi
Reviewed-by on v1 1/4
#2 lore raw

Re: [RFC PATCH liburing v1 1/4] syscall: Add io_uring syscall functions

Quoted 5 lines · Ammar Faizi
src/include/liburing.h +0 -0
@@ -202,6 +202,14 @@ int io_uring_register_file_alloc_range(struct io_uring *ring,
 int io_uring_register_notifications(struct io_uring *ring, unsigned nr,

src/include/liburing.h int io_uring_register_file_alloc_range(struct io_uring *ring, · line 212

Quoted 10 lines
src/include/liburing.h +8 -0
                                    struct io_uring_notification_slot *slots);
 int io_uring_unregister_notifications(struct io_uring *ring);
+int io_uring_enter(unsigned int fd, unsigned int to_submit,
+                  unsigned int min_complete, unsigned int flags,
+                  sigset_t *sig);
+int io_uring_enter2(int fd, unsigned to_submit, unsigned min_complete,
+                   unsigned flags, sigset_t *sig, int sz);
+int io_uring_setup(unsigned entries, struct io_uring_params *p);
+int io_uring_register(int fd, unsigned opcode, const void *arg,
+                     unsigned nr_args);

Can we be consistent about using "int fd"? And either standardize on "unsigned" or "unsigned int"? Looks like syscalls should maybe be separated by an empty line from the register/unregister functions in the header file.

src/syscall.c line 3

Quoted 6 lines
src/syscall.c new file +3 -0
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: MIT */
+
+#include "lib.h"

Looks like this include is unused?

Other than that,

#3 lore raw

Re: [RFC PATCH liburing v1 1/4] syscall: Add io_uring syscall functions

In reply to Ammar Faizi

src/include/liburing.h int io_uring_register_file_alloc_range(struct io_uring *ring, · line 209

Quoted 12 lines · Ammar Faizi
src/include/liburing.h +5 -0
@@ -202,6 +202,14 @@ int io_uring_register_file_alloc_range(struct io_uring *ring,
 int io_uring_register_notifications(struct io_uring *ring, unsigned nr,
                                    struct io_uring_notification_slot *slots);
 int io_uring_unregister_notifications(struct io_uring *ring);
+int io_uring_enter(unsigned int fd, unsigned int to_submit,
+                  unsigned int min_complete, unsigned int flags,
+                  sigset_t *sig);
+int io_uring_enter2(int fd, unsigned to_submit, unsigned min_complete,
+                   unsigned flags, sigset_t *sig, int sz);

Also, from the io_uring_enter() man page, it appears that "void *" would be a more appropriate type for the pointer argument in io_uring_enter2(). And "size_t" for sz.

--Caleb

#4 lore raw

RFC PATCH 2/4 man: Clarify "man 2" entry for io_uring syscalls

In reply to Ammar Faizi

From: Ammar Faizi <[email protected]>

io_uring_enter(), io_uring_register(), io_uring_setup() are not declared in <linux/io_uring.h> and never were. Plus, these functions don't intentionally set the errno variable. Reflect this fact in the manpage.

Side note: On architectures other than x86, x86-64, and aarch64, those functions _do_ set the errno, this is because the syscall is done via libc as we don't yet have nolibc support for the mentioned archs. Users should not rely on this behavior.

---
 man/io_uring_enter.2    | 9 ++++-----
 man/io_uring_register.2 | 9 ++++-----
 man/io_uring_setup.2    | 8 +++-----
 3 files changed, 11 insertions(+), 15 deletions(-)
man/io_uring_enter.2 +4 -5
index 6bfe9c9..05f9f72 100644
@@ -8,7 +8,7 @@
 io_uring_enter \- initiate and/or complete asynchronous I/O
 .SH SYNOPSIS
 .nf
-.BR "#include <linux/io_uring.h>"
+.BR "#include <liburing.h>"
 .PP
 .BI "int io_uring_enter(unsigned int " fd ", unsigned int " to_submit ,
 .BI "                   unsigned int " min_complete ", unsigned int " flags ,
@@ -1299,11 +1299,10 @@ completion queue entry (see section
 rather than through the system call itself.
 
 Errors that occur not on behalf of a submission queue entry are returned via the
-system call directly. On such an error,
-.B -1
-is returned and
+system call directly. On such an error, a negative error code is returned. The
+caller should not rely on
 .I errno
-is set appropriately.
+variable.
 .PP
 .SH ERRORS
 These are the errors returned by
man/io_uring_register.2 +4 -5
index 6c440b9..6791375 100644
@@ -8,7 +8,7 @@
 io_uring_register \- register files or user buffers for asynchronous I/O 
 .SH SYNOPSIS
 .nf
-.BR "#include <linux/io_uring.h>"
+.BR "#include <liburing.h>"
 .PP
 .BI "int io_uring_register(unsigned int " fd ", unsigned int " opcode ,
 .BI "                      void *" arg ", unsigned int " nr_args );
@@ -583,11 +583,10 @@ Available since 5.18.
 
 On success,
 .BR io_uring_register ()
-returns 0.  On error,
-.B -1
-is returned, and
+returns 0.  On error, a negative error code is returned. The caller should not
+rely on
 .I errno
-is set accordingly.
+variable.
 
 .SH ERRORS
 .TP
man/io_uring_setup.2 +3 -5
index 0a5fa92..32a9e2e 100644
@@ -9,7 +9,7 @@
 io_uring_setup \- setup a context for performing asynchronous I/O
 .SH SYNOPSIS
 .nf
-.BR "#include <linux/io_uring.h>"
+.BR "#include <liburing.h>"
 .PP
 .BI "int io_uring_setup(u32 " entries ", struct io_uring_params *" p );
 .fi
@@ -566,11 +566,9 @@ or
 .BR io_uring_enter (2)
 system calls.
 
-On error,
-.B -1
-is returned and
+On error, a negative error code is returned. The caller should not rely on
 .I errno
-is set appropriately.
+variable.
 .PP
 .SH ERRORS
 .TP
Signature · 1 line
Ammar Faizi
#5 lore raw

RFC PATCH 3/4 man: Alias `io_uring_enter2()` to `io_uring_enter()`

In reply to Ammar Faizi

From: Ammar Faizi <[email protected]>

We have a new function io_uring_enter2(), add the man page entry for it by aliasing it to io_uring_enter(). This aliased man entry has already explained it.

---
 man/io_uring_enter2.2 | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 man/io_uring_enter2.2
man/io_uring_enter2.2 new file +1 -0
new file mode 120000
index 0000000..5566c09
@@ -0,0 +1 @@
+io_uring_enter.2
\ No newline at end of file
Signature · 1 line
Ammar Faizi
#6 lore raw

Re: [RFC PATCH liburing v1 3/4] man: Alias `io_uring_enter2()` to `io_uring_enter()`

There is no reference to "io_uring_enter2()" in this man page, only to the updated signature of "io_uring_enter()". Can we make it clearer that this is "io_uring_enter2()"? I would suggest adding the signature for io_uring_enter2() to the top of the man page and renaming "io_uring_enter()" to "io_uring_enter2()" in the "Since kernel 5.11" section.

Quoted 25 lines · Ammar Faizi

From: Ammar Faizi <[email protected]>

We have a new function io_uring_enter2(), add the man page entry for it by aliasing it to io_uring_enter(). This aliased man entry has already explained it.

---
 man/io_uring_enter2.2 | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 man/io_uring_enter2.2
man/io_uring_enter2.2 new file +1 -1
new file mode 120000
index 0000000..5566c09
@@ -0,0 +1 @@
+io_uring_enter.2
\ No newline at end of file
--

Ammar Faizi

#7 lore raw

RFC PATCH 4/4 test/io_uring_{enter,setup,register}: Use the exported syscall functions

In reply to Ammar Faizi

From: Ammar Faizi <[email protected]>

These tests use the internal definition of __sys_io_uring* functions. A previous commit exported new functions that do the same thing with those __sys_io_uring* functions. Test the exported functions instead of the internal functions.

No functional change is intended.

---
 test/io_uring_enter.c    | 10 +++++-----
 test/io_uring_register.c | 34 ++++++++++++++++------------------
 test/io_uring_setup.c    |  4 ++--
 3 files changed, 23 insertions(+), 25 deletions(-)
test/io_uring_enter.c +5 -5
index 67cc8c5..ecd54ff 100644
@@ -38,7 +38,7 @@ static int expect_fail(int fd, unsigned int to_submit,
 {
 	int ret;
 
-	ret = __sys_io_uring_enter(fd, to_submit, min_complete, flags, sig);
+	ret = io_uring_enter(fd, to_submit, min_complete, flags, sig);
 	if (ret >= 0) {
 		fprintf(stderr, "expected %s, but call succeeded\n", strerror(-error));
 		return 1;
@@ -62,7 +62,7 @@ static int try_io_uring_enter(int fd, unsigned int to_submit,
 		return expect_fail(fd, to_submit, min_complete, flags, sig,
 				   expect);
 
-	ret = __sys_io_uring_enter(fd, to_submit, min_complete, flags, sig);
+	ret = io_uring_enter(fd, to_submit, min_complete, flags, sig);
 	if (ret != expect) {
 		fprintf(stderr, "Expected %d, got %d\n", expect, ret);
 		return 1;
@@ -211,8 +211,8 @@ int main(int argc, char **argv)
 	/* fill the sq ring */
 	sq_entries = ring.sq.ring_entries;
 	submit_io(&ring, sq_entries);
-	ret = __sys_io_uring_enter(ring.ring_fd, 0, sq_entries,
-					IORING_ENTER_GETEVENTS, NULL);
+	ret = io_uring_enter(ring.ring_fd, 0, sq_entries,
+			     IORING_ENTER_GETEVENTS, NULL);
 	if (ret < 0) {
 		fprintf(stderr, "io_uring_enter: %s\n", strerror(-ret));
 		status = 1;
@@ -246,7 +246,7 @@ int main(int argc, char **argv)
 	 */
 	io_uring_smp_store_release(sq->ktail, ktail);
 
-	ret = __sys_io_uring_enter(ring.ring_fd, 1, 0, 0, NULL);
+	ret = io_uring_enter(ring.ring_fd, 1, 0, 0, NULL);
 	/* now check to see if our sqe was dropped */
 	if (*sq->kdropped == dropped) {
 		fprintf(stderr, "dropped counter did not increase\n");
test/io_uring_register.c +16 -18
index 4609354..dd4af7c 100644
@@ -36,17 +36,17 @@ static int expect_fail(int fd, unsigned int opcode, void *arg,
 {
 	int ret;
 
-	ret = __sys_io_uring_register(fd, opcode, arg, nr_args);
+	ret = io_uring_register(fd, opcode, arg, nr_args);
 	if (ret >= 0) {
 		int ret2 = 0;
 
 		fprintf(stderr, "expected %s, but call succeeded\n", strerror(error));
 		if (opcode == IORING_REGISTER_BUFFERS) {
-			ret2 = __sys_io_uring_register(fd,
-					IORING_UNREGISTER_BUFFERS, 0, 0);
+			ret2 = io_uring_register(fd, IORING_UNREGISTER_BUFFERS,
+						 0, 0);
 		} else if (opcode == IORING_REGISTER_FILES) {
-			ret2 = __sys_io_uring_register(fd,
-					IORING_UNREGISTER_FILES, 0, 0);
+			ret2 = io_uring_register(fd, IORING_UNREGISTER_FILES, 0,
+						 0);
 		}
 		if (ret2) {
 			fprintf(stderr, "internal error: failed to unregister\n");
@@ -66,7 +66,7 @@ static int new_io_uring(int entries, struct io_uring_params *p)
 {
 	int fd;
 
-	fd = __sys_io_uring_setup(entries, p);
+	fd = io_uring_setup(entries, p);
 	if (fd < 0) {
 		perror("io_uring_setup");
 		exit(1);
@@ -186,15 +186,14 @@ static int test_max_fds(int uring_fd)
 	 */
 	nr_fds = UINT_MAX;
 	while (nr_fds) {
-		ret = __sys_io_uring_register(uring_fd, IORING_REGISTER_FILES,
-						fd_as, nr_fds);
+		ret = io_uring_register(uring_fd, IORING_REGISTER_FILES, fd_as,
+					nr_fds);
 		if (ret != 0) {
 			nr_fds /= 2;
 			continue;
 		}
 		status = 0;
-		ret = __sys_io_uring_register(uring_fd, IORING_UNREGISTER_FILES,
-						0, 0);
+		ret = io_uring_register(uring_fd, IORING_UNREGISTER_FILES, 0, 0);
 		if (ret < 0) {
 			ret = errno;
 			errno = ret;
@@ -230,7 +229,7 @@ static int test_memlock_exceeded(int fd)
 	iov.iov_base = buf;
 
 	while (iov.iov_len) {
-		ret = __sys_io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
+		ret = io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
 		if (ret < 0) {
 			if (errno == ENOMEM) {
 				iov.iov_len /= 2;
@@ -244,8 +243,7 @@ static int test_memlock_exceeded(int fd)
 			free(buf);
 			return 1;
 		}
-		ret = __sys_io_uring_register(fd, IORING_UNREGISTER_BUFFERS,
-						NULL, 0);
+		ret = io_uring_register(fd, IORING_UNREGISTER_BUFFERS, NULL, 0);
 		if (ret != 0) {
 			fprintf(stderr, "error: unregister failed with %d\n", errno);
 			free(buf);
@@ -283,14 +281,14 @@ static int test_iovec_nr(int fd)
 
 	/* reduce to UIO_MAXIOV */
 	nr = UIO_MAXIOV;
-	ret = __sys_io_uring_register(fd, IORING_REGISTER_BUFFERS, iovs, nr);
+	ret = io_uring_register(fd, IORING_REGISTER_BUFFERS, iovs, nr);
 	if (ret && (errno == ENOMEM || errno == EPERM) && geteuid()) {
 		fprintf(stderr, "can't register large iovec for regular users, skip\n");
 	} else if (ret != 0) {
 		fprintf(stderr, "expected success, got %d\n", errno);
 		status = 1;
 	} else {
-		__sys_io_uring_register(fd, IORING_UNREGISTER_BUFFERS, 0, 0);
+		io_uring_register(fd, IORING_UNREGISTER_BUFFERS, 0, 0);
 	}
 	free(buf);
 	free(iovs);
@@ -344,7 +342,7 @@ static int test_iovec_size(int fd)
 		 */
 		iov.iov_base = buf;
 		iov.iov_len = 2*1024*1024;
-		ret = __sys_io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
+		ret = io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
 		if (ret < 0) {
 			if (ret == -ENOMEM)
 				printf("Unable to test registering of a huge "
@@ -356,8 +354,8 @@ static int test_iovec_size(int fd)
 				status = 1;
 			}
 		} else {
-			ret = __sys_io_uring_register(fd,
-					IORING_UNREGISTER_BUFFERS, 0, 0);
+			ret = io_uring_register(fd, IORING_UNREGISTER_BUFFERS,
+						0, 0);
 			if (ret < 0) {
 				fprintf(stderr, "io_uring_unregister: %s\n",
 					strerror(-ret));
test/io_uring_setup.c +2 -2
index 67d5f4f..d945421 100644
@@ -102,7 +102,7 @@ try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect)
 {
 	int ret;
 
-	ret = __sys_io_uring_setup(entries, p);
+	ret = io_uring_setup(entries, p);
 	if (ret != expect) {
 		fprintf(stderr, "expected %d, got %d\n", expect, ret);
 		/* if we got a valid uring, close it */
@@ -164,7 +164,7 @@ main(int argc, char **argv)
 
 	/* read/write on io_uring_fd */
 	memset(&p, 0, sizeof(p));
-	fd = __sys_io_uring_setup(1, &p);
+	fd = io_uring_setup(1, &p);
 	if (fd < 0) {
 		fprintf(stderr, "io_uring_setup failed with %d, expected success\n",
 		       -fd);
Signature · 1 line
Ammar Faizi
Reviewed-by on v1 4/4
#8 lore raw

Re: [RFC PATCH liburing v1 4/4] test/io_uring_{enter,setup,register}: Use the exported syscall functions

Quoted 196 lines · Ammar Faizi

From: Ammar Faizi <[email protected]>

These tests use the internal definition of __sys_io_uring* functions. A previous commit exported new functions that do the same thing with those __sys_io_uring* functions. Test the exported functions instead of the internal functions.

No functional change is intended.

---
 test/io_uring_enter.c    | 10 +++++-----
 test/io_uring_register.c | 34 ++++++++++++++++------------------
 test/io_uring_setup.c    |  4 ++--
 3 files changed, 23 insertions(+), 25 deletions(-)
test/io_uring_enter.c +5 -5
index 67cc8c5..ecd54ff 100644
@@ -38,7 +38,7 @@ static int expect_fail(int fd, unsigned int to_submit,
 {
        int ret;
 
-       ret = __sys_io_uring_enter(fd, to_submit, min_complete, flags, sig);
+       ret = io_uring_enter(fd, to_submit, min_complete, flags, sig);
        if (ret >= 0) {
                fprintf(stderr, "expected %s, but call succeeded\n", strerror(-error));
                return 1;
@@ -62,7 +62,7 @@ static int try_io_uring_enter(int fd, unsigned int to_submit,
                return expect_fail(fd, to_submit, min_complete, flags, sig,
                                   expect);
 
-       ret = __sys_io_uring_enter(fd, to_submit, min_complete, flags, sig);
+       ret = io_uring_enter(fd, to_submit, min_complete, flags, sig);
        if (ret != expect) {
                fprintf(stderr, "Expected %d, got %d\n", expect, ret);
                return 1;
@@ -211,8 +211,8 @@ int main(int argc, char **argv)
        /* fill the sq ring */
        sq_entries = ring.sq.ring_entries;
        submit_io(&ring, sq_entries);
-       ret = __sys_io_uring_enter(ring.ring_fd, 0, sq_entries,
-                                       IORING_ENTER_GETEVENTS, NULL);
+       ret = io_uring_enter(ring.ring_fd, 0, sq_entries,
+                            IORING_ENTER_GETEVENTS, NULL);
        if (ret < 0) {
                fprintf(stderr, "io_uring_enter: %s\n", strerror(-ret));
                status = 1;
@@ -246,7 +246,7 @@ int main(int argc, char **argv)
         */
        io_uring_smp_store_release(sq->ktail, ktail);
 
-       ret = __sys_io_uring_enter(ring.ring_fd, 1, 0, 0, NULL);
+       ret = io_uring_enter(ring.ring_fd, 1, 0, 0, NULL);
        /* now check to see if our sqe was dropped */
        if (*sq->kdropped == dropped) {
                fprintf(stderr, "dropped counter did not increase\n");
test/io_uring_register.c +16 -18
index 4609354..dd4af7c 100644
@@ -36,17 +36,17 @@ static int expect_fail(int fd, unsigned int opcode, void *arg,
 {
        int ret;
 
-       ret = __sys_io_uring_register(fd, opcode, arg, nr_args);
+       ret = io_uring_register(fd, opcode, arg, nr_args);
        if (ret >= 0) {
                int ret2 = 0;
 
                fprintf(stderr, "expected %s, but call succeeded\n", strerror(error));
                if (opcode == IORING_REGISTER_BUFFERS) {
-                       ret2 = __sys_io_uring_register(fd,
-                                       IORING_UNREGISTER_BUFFERS, 0, 0);
+                       ret2 = io_uring_register(fd, IORING_UNREGISTER_BUFFERS,
+                                                0, 0);
                } else if (opcode == IORING_REGISTER_FILES) {
-                       ret2 = __sys_io_uring_register(fd,
-                                       IORING_UNREGISTER_FILES, 0, 0);
+                       ret2 = io_uring_register(fd, IORING_UNREGISTER_FILES, 0,
+                                                0);
                }
                if (ret2) {
                        fprintf(stderr, "internal error: failed to unregister\n");
@@ -66,7 +66,7 @@ static int new_io_uring(int entries, struct io_uring_params *p)
 {
        int fd;
 
-       fd = __sys_io_uring_setup(entries, p);
+       fd = io_uring_setup(entries, p);
        if (fd < 0) {
                perror("io_uring_setup");
                exit(1);
@@ -186,15 +186,14 @@ static int test_max_fds(int uring_fd)
         */
        nr_fds = UINT_MAX;
        while (nr_fds) {
-               ret = __sys_io_uring_register(uring_fd, IORING_REGISTER_FILES,
-                                               fd_as, nr_fds);
+               ret = io_uring_register(uring_fd, IORING_REGISTER_FILES, fd_as,
+                                       nr_fds);
                if (ret != 0) {
                        nr_fds /= 2;
                        continue;
                }
                status = 0;
-               ret = __sys_io_uring_register(uring_fd, IORING_UNREGISTER_FILES,
-                                               0, 0);
+               ret = io_uring_register(uring_fd, IORING_UNREGISTER_FILES, 0, 0);
                if (ret < 0) {
                        ret = errno;
                        errno = ret;
@@ -230,7 +229,7 @@ static int test_memlock_exceeded(int fd)
        iov.iov_base = buf;
 
        while (iov.iov_len) {
-               ret = __sys_io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
+               ret = io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
                if (ret < 0) {
                        if (errno == ENOMEM) {
                                iov.iov_len /= 2;
@@ -244,8 +243,7 @@ static int test_memlock_exceeded(int fd)
                        free(buf);
                        return 1;
                }
-               ret = __sys_io_uring_register(fd, IORING_UNREGISTER_BUFFERS,
-                                               NULL, 0);
+               ret = io_uring_register(fd, IORING_UNREGISTER_BUFFERS, NULL, 0);
                if (ret != 0) {
                        fprintf(stderr, "error: unregister failed with %d\n", errno);
                        free(buf);
@@ -283,14 +281,14 @@ static int test_iovec_nr(int fd)
 
        /* reduce to UIO_MAXIOV */
        nr = UIO_MAXIOV;
-       ret = __sys_io_uring_register(fd, IORING_REGISTER_BUFFERS, iovs, nr);
+       ret = io_uring_register(fd, IORING_REGISTER_BUFFERS, iovs, nr);
        if (ret && (errno == ENOMEM || errno == EPERM) && geteuid()) {
                fprintf(stderr, "can't register large iovec for regular users, skip\n");
        } else if (ret != 0) {
                fprintf(stderr, "expected success, got %d\n", errno);
                status = 1;
        } else {
-               __sys_io_uring_register(fd, IORING_UNREGISTER_BUFFERS, 0, 0);
+               io_uring_register(fd, IORING_UNREGISTER_BUFFERS, 0, 0);
        }
        free(buf);
        free(iovs);
@@ -344,7 +342,7 @@ static int test_iovec_size(int fd)
                 */
                iov.iov_base = buf;
                iov.iov_len = 2*1024*1024;
-               ret = __sys_io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
+               ret = io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
                if (ret < 0) {
                        if (ret == -ENOMEM)
                                printf("Unable to test registering of a huge "
@@ -356,8 +354,8 @@ static int test_iovec_size(int fd)
                                status = 1;
                        }
                } else {
-                       ret = __sys_io_uring_register(fd,
-                                       IORING_UNREGISTER_BUFFERS, 0, 0);
+                       ret = io_uring_register(fd, IORING_UNREGISTER_BUFFERS,
+                                               0, 0);
                        if (ret < 0) {
                                fprintf(stderr, "io_uring_unregister: %s\n",
                                        strerror(-ret));
test/io_uring_setup.c +2 -3
index 67d5f4f..d945421 100644
@@ -102,7 +102,7 @@ try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect)
 {
        int ret;
 
-       ret = __sys_io_uring_setup(entries, p);
+       ret = io_uring_setup(entries, p);
        if (ret != expect) {
                fprintf(stderr, "expected %d, got %d\n", expect, ret);
                /* if we got a valid uring, close it */
@@ -164,7 +164,7 @@ main(int argc, char **argv)
 
        /* read/write on io_uring_fd */
        memset(&p, 0, sizeof(p));
-       fd = __sys_io_uring_setup(1, &p);
+       fd = io_uring_setup(1, &p);
        if (fd < 0) {
                fprintf(stderr, "io_uring_setup failed with %d, expected success\n",
                       -fd);
--

Ammar Faizi