All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH liburing v2 0/7] Export io_uring syscall functions
@ 2022-08-30  0:56 Ammar Faizi
  2022-08-30  0:56 ` [PATCH liburing v2 1/7] syscall: Make io_uring syscall arguments consistent Ammar Faizi
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Ammar Faizi @ 2022-08-30  0:56 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Caleb Sander, Muhammad Rizki, Kanna Scarlet,
	io-uring Mailing List, Linux Kernel Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

Hi Jens,

This series adds io_uring syscall functions and exports them. There
are 7 patches in this series:

1) Make the arguments of io_uring syscalls consistent with what is
   said in the manpage. These change are in header files. No
   functional change is intended.

2) 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.

3) man: Clarify "man 2" entry for io_uring syscalls.

   io_uring_enter(), io_uring_register(), and io_uring_setup() are not
   declared in `<linux/io_uring.h>` (and never were). A previous
   commit adds the implementation of these functions in liburing.
   Change the include header to `<liburing.h>`. Then clarify that
   those functions don't intentionally set the `errno` variable.
   Instead they return a negative error code when the syscall fails.

4) Add `io_uring_enter2()` function signature.

   Since kernel 5.11, liburing has io_uring_enter2() wrapper which
   behaves just like the io_uring_enter(), but with an extra argument
   for `IORING_ENTER_EXT_ARG` case. Add this function signature to the
   synopsis part.

5) 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(). The aliased man entry
   has already explained it.

6) 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.

7) Just a trivial typo fix.


## Changelog revision

 RFC v1 -> v2:

  - Make io_uring syscall arguments consistent with the manpage.
  - Separate syscall declarations in liburing.h with a blank line.
  - Remove unused include in syscall.c.
  - Add io_uring_enter2() function signature to manpage.
  - Append Reviewed-by tags from Caleb Sander.
  - Fix typo introduced by an old commit, 1dbc9974486cbc.


Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---

Ammar Faizi (7):
  syscall: Make io_uring syscall arguments consistent
  syscall: Add io_uring syscall functions
  man: Clarify "man 2" entry for io_uring syscalls
  man: Add `io_uring_enter2()` function signature
  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: Fix typo "which is behaves" -> "which behaves"

 man/io_uring_enter.2       | 21 ++++++++++++---------
 man/io_uring_enter2.2      |  1 +
 man/io_uring_register.2    |  9 ++++-----
 man/io_uring_setup.2       |  8 +++-----
 src/Makefile               |  2 +-
 src/arch/generic/syscall.h | 19 ++++++++++---------
 src/arch/syscall-defs.h    | 19 ++++++++++---------
 src/include/liburing.h     | 12 ++++++++++++
 src/liburing.map           |  4 ++++
 src/syscall.c              | 29 +++++++++++++++++++++++++++++
 test/io_uring_enter.c      | 10 +++++-----
 test/io_uring_register.c   | 34 ++++++++++++++++------------------
 test/io_uring_setup.c      |  4 ++--
 13 files changed, 109 insertions(+), 63 deletions(-)
 create mode 120000 man/io_uring_enter2.2
 create mode 100644 src/syscall.c


base-commit: 243477691678af27dafe378f1e19be5df61e9daf
-- 
Ammar Faizi


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH liburing v2 1/7] syscall: Make io_uring syscall arguments consistent
  2022-08-30  0:56 [PATCH liburing v2 0/7] Export io_uring syscall functions Ammar Faizi
@ 2022-08-30  0:56 ` Ammar Faizi
  2022-08-30  0:56 ` [PATCH liburing v2 2/7] syscall: Add io_uring syscall functions Ammar Faizi
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ammar Faizi @ 2022-08-30  0:56 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Caleb Sander, Muhammad Rizki, Kanna Scarlet,
	io-uring Mailing List, Linux Kernel Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

Make the arguments of io_uring syscalls consistent with what is said in
the manpage. No functional change is intended.

Link: https://lore.kernel.org/io-uring/CADUfDZpE_gPyfN=dLKB6nu-++ZKyebpWTvYGNOmdP1-c_BLZZA@mail.gmail.com
Link: https://lore.kernel.org/io-uring/CADUfDZr0mPn_REb24aEPa477T+CYeoV5hcbURqX9kazCUqRp4A@mail.gmail.com
Suggested-by: Caleb Sander <csander@purestorage.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 src/arch/generic/syscall.h | 19 ++++++++++---------
 src/arch/syscall-defs.h    | 19 ++++++++++---------
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/src/arch/generic/syscall.h b/src/arch/generic/syscall.h
index 5a172e1..00730e0 100644
--- a/src/arch/generic/syscall.h
+++ b/src/arch/generic/syscall.h
@@ -5,15 +5,15 @@
 
 #include <fcntl.h>
 
-static inline int __sys_io_uring_register(int fd, unsigned opcode,
-					  const void *arg, unsigned nr_args)
+static inline int __sys_io_uring_register(unsigned int fd, unsigned int opcode,
+					  const void *arg, unsigned int nr_args)
 {
 	int ret;
 	ret = syscall(__NR_io_uring_register, fd, opcode, arg, nr_args);
 	return (ret < 0) ? -errno : ret;
 }
 
-static inline int __sys_io_uring_setup(unsigned entries,
+static inline int __sys_io_uring_setup(unsigned int entries,
 				       struct io_uring_params *p)
 {
 	int ret;
@@ -21,9 +21,10 @@ static inline int __sys_io_uring_setup(unsigned entries,
 	return (ret < 0) ? -errno : ret;
 }
 
-static inline int __sys_io_uring_enter2(int fd, unsigned to_submit,
-					unsigned min_complete, unsigned flags,
-					sigset_t *sig, int sz)
+static inline int __sys_io_uring_enter2(unsigned int fd, unsigned int to_submit,
+					unsigned int min_complete,
+					unsigned int flags, sigset_t *sig,
+					size_t sz)
 {
 	int ret;
 	ret = syscall(__NR_io_uring_enter, fd, to_submit, min_complete, flags,
@@ -31,9 +32,9 @@ static inline int __sys_io_uring_enter2(int fd, unsigned to_submit,
 	return (ret < 0) ? -errno : ret;
 }
 
-static inline int __sys_io_uring_enter(int fd, unsigned to_submit,
-				       unsigned min_complete, unsigned flags,
-				       sigset_t *sig)
+static inline int __sys_io_uring_enter(unsigned int fd, unsigned int to_submit,
+				       unsigned int min_complete,
+				       unsigned int flags, sigset_t *sig)
 {
 	return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
 				     _NSIG / 8);
diff --git a/src/arch/syscall-defs.h b/src/arch/syscall-defs.h
index 374aa0d..4afb2af 100644
--- a/src/arch/syscall-defs.h
+++ b/src/arch/syscall-defs.h
@@ -61,30 +61,31 @@ static inline int __sys_close(int fd)
 	return (int) __do_syscall1(__NR_close, fd);
 }
 
-static inline int __sys_io_uring_register(int fd, unsigned opcode,
-					  const void *arg, unsigned nr_args)
+static inline int __sys_io_uring_register(unsigned int fd, unsigned int opcode,
+					  const void *arg, unsigned int nr_args)
 {
 	return (int) __do_syscall4(__NR_io_uring_register, fd, opcode, arg,
 				   nr_args);
 }
 
-static inline int __sys_io_uring_setup(unsigned entries,
+static inline int __sys_io_uring_setup(unsigned int entries,
 				       struct io_uring_params *p)
 {
 	return (int) __do_syscall2(__NR_io_uring_setup, entries, p);
 }
 
-static inline int __sys_io_uring_enter2(int fd, unsigned to_submit,
-					unsigned min_complete, unsigned flags,
-					sigset_t *sig, int sz)
+static inline int __sys_io_uring_enter2(unsigned int fd, unsigned int to_submit,
+					unsigned int min_complete,
+					unsigned int flags, sigset_t *sig,
+					size_t sz)
 {
 	return (int) __do_syscall6(__NR_io_uring_enter, fd, to_submit,
 				   min_complete, flags, sig, sz);
 }
 
-static inline int __sys_io_uring_enter(int fd, unsigned to_submit,
-				       unsigned min_complete, unsigned flags,
-				       sigset_t *sig)
+static inline int __sys_io_uring_enter(unsigned int fd, unsigned int to_submit,
+				       unsigned int min_complete,
+				       unsigned int flags, sigset_t *sig)
 {
 	return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
 				     _NSIG / 8);
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH liburing v2 2/7] syscall: Add io_uring syscall functions
  2022-08-30  0:56 [PATCH liburing v2 0/7] Export io_uring syscall functions Ammar Faizi
  2022-08-30  0:56 ` [PATCH liburing v2 1/7] syscall: Make io_uring syscall arguments consistent Ammar Faizi
@ 2022-08-30  0:56 ` Ammar Faizi
  2022-08-30  0:56 ` [PATCH liburing v2 3/7] man: Clarify "man 2" entry for io_uring syscalls Ammar Faizi
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ammar Faizi @ 2022-08-30  0:56 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Caleb Sander, Muhammad Rizki, Kanna Scarlet,
	io-uring Mailing List, Linux Kernel Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

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.

v2:
  - Use consistent argument types.
  - Separate syscall declarations in liburing.h with a blank line.
  - Remove unused include in syscall.c.

Link: https://github.com/axboe/liburing/pull/646#issuecomment-1229639532
Reviewed-by: Caleb Sander <csander@purestorage.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 src/Makefile           |  2 +-
 src/include/liburing.h | 12 ++++++++++++
 src/liburing.map       |  4 ++++
 src/syscall.c          | 29 +++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 src/syscall.c

diff --git a/src/Makefile b/src/Makefile
index dad379d..73a98ba 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -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
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 66c5095..6e86847 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -203,6 +203,18 @@ 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);
 
+/*
+ * io_uring syscalls.
+ */
+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(unsigned int fd, unsigned int to_submit,
+		    unsigned int min_complete, unsigned int flags,
+		    sigset_t *sig, size_t sz);
+int io_uring_setup(unsigned int entries, struct io_uring_params *p);
+int io_uring_register(unsigned int fd, unsigned int opcode, const void *arg,
+		      unsigned int nr_args);
+
 /*
  * Helper for the peek/wait single cqe functions. Exported because of that,
  * but probably shouldn't be used directly in an application.
diff --git a/src/liburing.map b/src/liburing.map
index 7d8f143..8573dfc 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -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;
diff --git a/src/syscall.c b/src/syscall.c
new file mode 100644
index 0000000..2054d17
--- /dev/null
+++ b/src/syscall.c
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT */
+
+#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(unsigned int fd, unsigned int to_submit,
+		    unsigned int min_complete, unsigned int flags,
+		    sigset_t *sig, size_t sz)
+{
+	return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
+				     sz);
+}
+
+int io_uring_setup(unsigned int entries, struct io_uring_params *p)
+{
+	return __sys_io_uring_setup(entries, p);
+}
+
+int io_uring_register(unsigned int fd, unsigned int opcode, const void *arg,
+		      unsigned int nr_args)
+{
+	return __sys_io_uring_register(fd, opcode, arg, nr_args);
+}
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH liburing v2 3/7] man: Clarify "man 2" entry for io_uring syscalls
  2022-08-30  0:56 [PATCH liburing v2 0/7] Export io_uring syscall functions Ammar Faizi
  2022-08-30  0:56 ` [PATCH liburing v2 1/7] syscall: Make io_uring syscall arguments consistent Ammar Faizi
  2022-08-30  0:56 ` [PATCH liburing v2 2/7] syscall: Add io_uring syscall functions Ammar Faizi
@ 2022-08-30  0:56 ` Ammar Faizi
  2022-08-30  0:56 ` [PATCH liburing v2 4/7] man: Add `io_uring_enter2()` function signature Ammar Faizi
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ammar Faizi @ 2022-08-30  0:56 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Caleb Sander, Muhammad Rizki, Kanna Scarlet,
	io-uring Mailing List, Linux Kernel Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

io_uring_enter(), io_uring_register(), and io_uring_setup() are not
declared in `<linux/io_uring.h>` (and never were). A previous commit
adds the implementation of these functions in liburing. Change the
include header to `<liburing.h>`. Then clarify that those functions
don't intentionally set the `errno` variable. Instead they return
a negative error code when the syscall fails.

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. Users should not rely on this behavior as it may change in the
future when nolibc support is expanded to other architectures.

Cc: Caleb Sander <csander@purestorage.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 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(-)

diff --git a/man/io_uring_enter.2 b/man/io_uring_enter.2
index 6bfe9c9..05f9f72 100644
--- a/man/io_uring_enter.2
+++ b/man/io_uring_enter.2
@@ -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
diff --git a/man/io_uring_register.2 b/man/io_uring_register.2
index 6c440b9..6791375 100644
--- a/man/io_uring_register.2
+++ b/man/io_uring_register.2
@@ -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
diff --git a/man/io_uring_setup.2 b/man/io_uring_setup.2
index 0a5fa92..32a9e2e 100644
--- a/man/io_uring_setup.2
+++ b/man/io_uring_setup.2
@@ -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
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH liburing v2 4/7] man: Add `io_uring_enter2()` function signature
  2022-08-30  0:56 [PATCH liburing v2 0/7] Export io_uring syscall functions Ammar Faizi
                   ` (2 preceding siblings ...)
  2022-08-30  0:56 ` [PATCH liburing v2 3/7] man: Clarify "man 2" entry for io_uring syscalls Ammar Faizi
@ 2022-08-30  0:56 ` Ammar Faizi
  2022-08-30  0:56 ` [PATCH liburing v2 5/7] man: Alias `io_uring_enter2()` to `io_uring_enter()` Ammar Faizi
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ammar Faizi @ 2022-08-30  0:56 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Caleb Sander, Muhammad Rizki, Kanna Scarlet,
	io-uring Mailing List, Linux Kernel Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

Since kernel 5.11, liburing has io_uring_enter2() wrapper which behaves
just like the io_uring_enter(), but with an extra argument for
`IORING_ENTER_EXT_ARG` case. Add this function signature to the
synopsis part. Also, change the function name in "kernel 5.11" part to
io_uring_enter2().

Suggested-by: Caleb Sander <csander@purestorage.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 man/io_uring_enter.2 | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/man/io_uring_enter.2 b/man/io_uring_enter.2
index 05f9f72..85e582c 100644
--- a/man/io_uring_enter.2
+++ b/man/io_uring_enter.2
@@ -13,6 +13,10 @@ io_uring_enter \- initiate and/or complete asynchronous I/O
 .BI "int io_uring_enter(unsigned int " fd ", unsigned int " to_submit ,
 .BI "                   unsigned int " min_complete ", unsigned int " flags ,
 .BI "                   sigset_t *" sig );
+.PP
+.BI "int io_uring_enter2(unsigned int " fd ", unsigned int " to_submit ,
+.BI "                    unsigned int " min_complete ", unsigned int " flags ,
+.BI "                    sigset_t *" sig ", size_t " sz );
 .fi
 .PP
 .SH DESCRIPTION
@@ -61,9 +65,9 @@ Since kernel 5.11, the system calls arguments have been modified to look like
 the following:
 
 .nf
-.BI "int io_uring_enter(unsigned int " fd ", unsigned int " to_submit ,
-.BI "                   unsigned int " min_complete ", unsigned int " flags ,
-.BI "                   const void *" arg ", size_t " argsz );
+.BI "int io_uring_enter2(unsigned int " fd ", unsigned int " to_submit ,
+.BI "                    unsigned int " min_complete ", unsigned int " flags ,
+.BI "                    const void *" arg ", size_t " argsz );
 .fi
 
 which is behaves just like the original definition by default. However, if
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH liburing v2 5/7] man: Alias `io_uring_enter2()` to `io_uring_enter()`
  2022-08-30  0:56 [PATCH liburing v2 0/7] Export io_uring syscall functions Ammar Faizi
                   ` (3 preceding siblings ...)
  2022-08-30  0:56 ` [PATCH liburing v2 4/7] man: Add `io_uring_enter2()` function signature Ammar Faizi
@ 2022-08-30  0:56 ` Ammar Faizi
  2022-08-30  0:56 ` [PATCH liburing v2 6/7] test/io_uring_{enter,setup,register}: Use the exported syscall functions Ammar Faizi
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ammar Faizi @ 2022-08-30  0:56 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Caleb Sander, Muhammad Rizki, Kanna Scarlet,
	io-uring Mailing List, Linux Kernel Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

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

Cc: Caleb Sander <csander@purestorage.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 man/io_uring_enter2.2 | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 man/io_uring_enter2.2

diff --git a/man/io_uring_enter2.2 b/man/io_uring_enter2.2
new file mode 120000
index 0000000..5566c09
--- /dev/null
+++ b/man/io_uring_enter2.2
@@ -0,0 +1 @@
+io_uring_enter.2
\ No newline at end of file
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH liburing v2 6/7] test/io_uring_{enter,setup,register}: Use the exported syscall functions
  2022-08-30  0:56 [PATCH liburing v2 0/7] Export io_uring syscall functions Ammar Faizi
                   ` (4 preceding siblings ...)
  2022-08-30  0:56 ` [PATCH liburing v2 5/7] man: Alias `io_uring_enter2()` to `io_uring_enter()` Ammar Faizi
@ 2022-08-30  0:56 ` Ammar Faizi
  2022-08-30  0:56 ` [PATCH liburing v2 7/7] man/io_uring_enter.2: Fix typo "which is behaves" -> "which behaves" Ammar Faizi
  2022-08-30 14:14 ` [PATCH liburing v2 0/7] Export io_uring syscall functions Jens Axboe
  7 siblings, 0 replies; 9+ messages in thread
From: Ammar Faizi @ 2022-08-30  0:56 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Caleb Sander, Muhammad Rizki, Kanna Scarlet,
	io-uring Mailing List, Linux Kernel Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

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.

Reviewed-by: Caleb Sander <csander@purestorage.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 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(-)

diff --git a/test/io_uring_enter.c b/test/io_uring_enter.c
index 67cc8c5..ecd54ff 100644
--- a/test/io_uring_enter.c
+++ b/test/io_uring_enter.c
@@ -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");
diff --git a/test/io_uring_register.c b/test/io_uring_register.c
index 4609354..dd4af7c 100644
--- a/test/io_uring_register.c
+++ b/test/io_uring_register.c
@@ -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));
diff --git a/test/io_uring_setup.c b/test/io_uring_setup.c
index 67d5f4f..d945421 100644
--- a/test/io_uring_setup.c
+++ b/test/io_uring_setup.c
@@ -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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH liburing v2 7/7] man/io_uring_enter.2: Fix typo "which is behaves" -> "which behaves"
  2022-08-30  0:56 [PATCH liburing v2 0/7] Export io_uring syscall functions Ammar Faizi
                   ` (5 preceding siblings ...)
  2022-08-30  0:56 ` [PATCH liburing v2 6/7] test/io_uring_{enter,setup,register}: Use the exported syscall functions Ammar Faizi
@ 2022-08-30  0:56 ` Ammar Faizi
  2022-08-30 14:14 ` [PATCH liburing v2 0/7] Export io_uring syscall functions Jens Axboe
  7 siblings, 0 replies; 9+ messages in thread
From: Ammar Faizi @ 2022-08-30  0:56 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Caleb Sander, Muhammad Rizki, Kanna Scarlet,
	io-uring Mailing List, Linux Kernel Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

Just a trivial grammatical error fix.

Fixes: 1dbc9974486cbc5f60eeeca092fd434c40d3a484 ("man/io_uring_enter.2: document IORING_ENTER_EXT_ARG")
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 man/io_uring_enter.2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man/io_uring_enter.2 b/man/io_uring_enter.2
index 85e582c..1a9311e 100644
--- a/man/io_uring_enter.2
+++ b/man/io_uring_enter.2
@@ -70,7 +70,7 @@ the following:
 .BI "                    const void *" arg ", size_t " argsz );
 .fi
 
-which is behaves just like the original definition by default. However, if
+which behaves just like the original definition by default. However, if
 .B IORING_ENTER_EXT_ARG
 is set, then instead of a
 .I sigset_t
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH liburing v2 0/7] Export io_uring syscall functions
  2022-08-30  0:56 [PATCH liburing v2 0/7] Export io_uring syscall functions Ammar Faizi
                   ` (6 preceding siblings ...)
  2022-08-30  0:56 ` [PATCH liburing v2 7/7] man/io_uring_enter.2: Fix typo "which is behaves" -> "which behaves" Ammar Faizi
@ 2022-08-30 14:14 ` Jens Axboe
  7 siblings, 0 replies; 9+ messages in thread
From: Jens Axboe @ 2022-08-30 14:14 UTC (permalink / raw)
  To: Ammar Faizi
  Cc: Linux Kernel Mailing List, Kanna Scarlet, Caleb Sander,
	GNU/Weeb Mailing List, Muhammad Rizki, io-uring Mailing List

On Tue, 30 Aug 2022 07:56:36 +0700, Ammar Faizi wrote:
> From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
> 
> Hi Jens,
> 
> This series adds io_uring syscall functions and exports them. There
> are 7 patches in this series:
> 
> [...]

Applied, thanks!

[1/7] syscall: Make io_uring syscall arguments consistent
      commit: 09164272d3aa5f4727fdf2181284d29e88194201
[2/7] syscall: Add io_uring syscall functions
      commit: f0b43c84cb3d1a4af4f1a32193bcad66fe458488
[3/7] man: Clarify "man 2" entry for io_uring syscalls
      commit: 9a8512f6dbd259a52b3f98fb5e6324a9b2841c3c
[4/7] man: Add `io_uring_enter2()` function signature
      commit: 584b9ed0ceef30934e747435fe0b535528495de6
[5/7] man: Alias `io_uring_enter2()` to `io_uring_enter()`
      commit: 8251e2778b0a1a897337aa011cb59ec85de599e0
[6/7] test/io_uring_{enter,setup,register}: Use the exported syscall functions
      commit: 64208a184c155580bfde12ced79ff09d9bcc52a8
[7/7] man/io_uring_enter.2: Fix typo "which is behaves" -> "which behaves"
      commit: 1ef00fc157cd0fa96d4da355ee86c977b6e4169e

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-08-30 14:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-30  0:56 [PATCH liburing v2 0/7] Export io_uring syscall functions Ammar Faizi
2022-08-30  0:56 ` [PATCH liburing v2 1/7] syscall: Make io_uring syscall arguments consistent Ammar Faizi
2022-08-30  0:56 ` [PATCH liburing v2 2/7] syscall: Add io_uring syscall functions Ammar Faizi
2022-08-30  0:56 ` [PATCH liburing v2 3/7] man: Clarify "man 2" entry for io_uring syscalls Ammar Faizi
2022-08-30  0:56 ` [PATCH liburing v2 4/7] man: Add `io_uring_enter2()` function signature Ammar Faizi
2022-08-30  0:56 ` [PATCH liburing v2 5/7] man: Alias `io_uring_enter2()` to `io_uring_enter()` Ammar Faizi
2022-08-30  0:56 ` [PATCH liburing v2 6/7] test/io_uring_{enter,setup,register}: Use the exported syscall functions Ammar Faizi
2022-08-30  0:56 ` [PATCH liburing v2 7/7] man/io_uring_enter.2: Fix typo "which is behaves" -> "which behaves" Ammar Faizi
2022-08-30 14:14 ` [PATCH liburing v2 0/7] Export io_uring syscall functions Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.