Skip to contentSkip to conversation

Delete `src/syscall.c` and get back to use `__sys_io_uring*` functions

PATCH Applied Ammar Faizi 2 participants 6 messages Jul 21, 2022 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Delete `src/syscall.c` and get back to use `__sys_io_uring*` functions

Back when I was adding nolibc support for liburing, I added new wrapper functions for io_uring system calls. They are ____sys_io_uring* functions (with 4 underscores), all defined as an inline function.

I left __sys_uring* functions (with 2 underscores) live in syscall.c because I thought it might break the user if we delete them. But it turned out that I was wrong, no user should use these functions because we don't export them. This situation is reflected in liburing.map and liburing.h which don't have those functions.

Do these:

1) Delete src/syscall.c.
2) Rename ____sys_io_uring* to __sys_io_uring*.
3) Fix tests that still depend on libc errno for checking __sys_io_uring* functions error code.

to:

1) Reduce the burden of maintaining syscall.c.
2) Simplify the Makefile, no need extra branch to compile syscall.c with a specific condition.
3) Simplify function naming and kill the confusion of deciding using __sys_uring* or ____sys_io_uring* when adding a new test that directly calls them. Because now we always use __sys_io_uring*. ____sys_io_uring* functions no longer exist.

After this patch, __sys_io_uring* functions now return -errno instead of -1 when fails.

---

=======================================================================

Test files that use __sys_io_uring* functions:

  ammarfaizi2@integral2:~/app/liburing/test$ grep -r __sys_io_uring | cut -d ':' -f 1 | sort | uniq
  35fa71a030ca.c
  917257daa0fe.c
  a0908ae19763.c
  a4c0b3decb33.c
  accept-reuse.c
  b19062a56726.c
  double-poll-crash.c
  empty-eownerdead.c
  fc2a85cb02ef.c
  iopoll.c
  io_uring_enter.c
  io_uring_register.c
  io_uring_setup.c
  ring-leak2.c
  ring-leak.c
  rsrc_tags.c
  sqpoll-cancel-hang.c
  sqpoll-disable-exit.c
  timeout.c

those are 19 files.

By manual checking of those 19 files, *only* the following files use errno to check for __sys_io_uring* error:

empty-eownerdead.c
io_uring_enter.c
io_uring_register.c
io_uring_setup.c
rsrc_tags.c

All are fixed and no longer rely on errno for checking __sys_io_uring*. Tested on Linux 5.19-rc7 x86-64, all tests are fixed except: read-write.t and poll-mshot-overflow.t that I reported recently.

 src/Makefile             |   2 -
 src/arch/syscall-defs.h  |  24 +++----
 src/queue.c              |  14 ++---
 src/register.c           | 133 +++++++++++++++++++--------------------
 src/setup.c              |   2 +-
 src/syscall.c            |  47 --------------
 src/syscall.h            |  13 ----
 test/Makefile            |  14 +----
 test/io_uring_enter.c    |  28 ++++-----
 test/io_uring_register.c |  33 +++++-----
 test/io_uring_setup.c    |  26 ++++----
 test/rsrc_tags.c         |  13 ++--
 12 files changed, 135 insertions(+), 214 deletions(-)
 delete mode 100644 src/syscall.c
src/Makefile +0 -2
index 1fec779..dad379d 100644
@@ -39,8 +39,6 @@ ifeq ($(CONFIG_NOLIBC),y)
 	override CFLAGS += -nostdlib -nodefaultlibs -ffreestanding
 	override CPPFLAGS += -nostdlib -nodefaultlibs -ffreestanding
 	override LINK_FLAGS += -nostdlib -nodefaultlibs
-else
-	liburing_srcs += syscall.c
 endif
 
 override CPPFLAGS += -MT "$@" -MMD -MP -MF "[email protected]"
src/arch/syscall-defs.h +12 -12
index df90e0d..9ddac45 100644
@@ -61,33 +61,33 @@ 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(int fd, unsigned opcode,
+					  const void *arg, unsigned nr_args)
 {
 	return (int) __do_syscall4(__NR_io_uring_register, fd, opcode, arg,
 				   nr_args);
 }
 
-static inline int ____sys_io_uring_setup(unsigned entries,
-					 struct io_uring_params *p)
+static inline int __sys_io_uring_setup(unsigned 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(int fd, unsigned to_submit,
+					unsigned min_complete, unsigned flags,
+					sigset_t *sig, int 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(int fd, unsigned to_submit,
+				       unsigned min_complete, unsigned flags,
+				       sigset_t *sig)
 {
-	return ____sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
-				       _NSIG / 8);
+	return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
+				     _NSIG / 8);
 }
 
 #endif
src/queue.c +7 -7
index ce0ecf6..72cc77b 100644
@@ -92,9 +92,9 @@ static int _io_uring_get_cqe(struct io_uring *ring,
 
 		if (ring->int_flags & INT_FLAG_REG_RING)
 			flags |= IORING_ENTER_REGISTERED_RING;
-		ret = ____sys_io_uring_enter2(ring->enter_ring_fd, data->submit,
-					      data->wait_nr, flags, data->arg,
-					      data->sz);
+		ret = __sys_io_uring_enter2(ring->enter_ring_fd, data->submit,
+					    data->wait_nr, flags, data->arg,
+					    data->sz);
 		if (ret < 0) {
 			err = ret;
 			break;
@@ -162,7 +162,7 @@ again:
 
 		if (ring->int_flags & INT_FLAG_REG_RING)
 			flags |= IORING_ENTER_REGISTERED_RING;
-		____sys_io_uring_enter(ring->enter_ring_fd, 0, 0, flags, NULL);
+		__sys_io_uring_enter(ring->enter_ring_fd, 0, 0, flags, NULL);
 		overflow_checked = true;
 		goto again;
 	}
@@ -360,8 +360,8 @@ static int __io_uring_submit(struct io_uring *ring, unsigned submitted,
 		if (ring->int_flags & INT_FLAG_REG_RING)
 			flags |= IORING_ENTER_REGISTERED_RING;
 
-		ret = ____sys_io_uring_enter(ring->enter_ring_fd, submitted,
-						wait_nr, flags, NULL);
+		ret = __sys_io_uring_enter(ring->enter_ring_fd, submitted,
+					   wait_nr, flags, NULL);
 	} else
 		ret = submitted;
 
@@ -407,5 +407,5 @@ int __io_uring_sqring_wait(struct io_uring *ring)
 	if (ring->int_flags & INT_FLAG_REG_RING)
 		flags |= IORING_ENTER_REGISTERED_RING;
 
-	return  ____sys_io_uring_enter(ring->enter_ring_fd, 0, 0, flags, NULL);
+	return __sys_io_uring_enter(ring->enter_ring_fd, 0, 0, flags, NULL);
 }
src/register.c +65 -68

289 lines not on this page · raw message

src/setup.c +1 -1
index 2badcc1..dec55d9 100644
@@ -144,7 +144,7 @@ __cold int io_uring_queue_init_params(unsigned entries, struct io_uring *ring,
 {
 	int fd, ret;
 
-	fd = ____sys_io_uring_setup(entries, p);
+	fd = __sys_io_uring_setup(entries, p);
 	if (fd < 0)
 		return fd;
 
src/syscall.c deleted +0 -47

47 lines not on this page · raw message

src/syscall.h +0 -13
index 73b04b4..ba008ea 100644
@@ -85,17 +85,4 @@ static inline bool IS_ERR(const void *ptr)
 /* libc syscall wrappers. */
 #include "arch/generic/syscall.h"
 #endif
-
-/*
- * For backward compatibility.
- * (these __sys* functions always use libc, see syscall.c)
- */
-int __sys_io_uring_setup(unsigned entries, struct io_uring_params *p);
-int __sys_io_uring_enter(int fd, unsigned to_submit, unsigned min_complete,
-			 unsigned flags, sigset_t *sig);
-int __sys_io_uring_enter2(int fd, unsigned to_submit, unsigned min_complete,
-			  unsigned flags, sigset_t *sig, int sz);
-int __sys_io_uring_register(int fd, unsigned int opcode, const void *arg,
-			    unsigned int nr_args);
-
 #endif
test/Makefile +1 -13
index 45674c3..e958a35 100644
@@ -197,22 +197,10 @@ test_targets := $(patsubst %.cc,%,$(test_targets))
 run_test_targets := $(patsubst %,%.run_test,$(test_targets))
 test_targets := $(patsubst %,%.t,$(test_targets))
 all_targets += $(test_targets)
-
-#
-# Build ../src/syscall.c manually from test's Makefile to support
-# liburing nolibc.
-#
-# Functions in ../src/syscall.c require libc to work with, if we
-# build liburing without libc, we don't have those functions
-# in liburing.a. So build it manually here.
-#
-helpers = helpers.o ../src/syscall.o
+helpers = helpers.o
 
 all: $(test_targets)
 
-../src/syscall.o: ../src/syscall.c
-	$(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
-
 helpers.o: helpers.c
 	$(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
 
test/io_uring_enter.c +14 -14
index 941c5b7..429f6ef 100644
@@ -39,13 +39,13 @@ static int expect_fail(int fd, unsigned int to_submit,
 	int ret;
 
 	ret = __sys_io_uring_enter(fd, to_submit, min_complete, flags, sig);
-	if (ret != -1) {
-		fprintf(stderr, "expected %s, but call succeeded\n", strerror(error));
+	if (ret >= 0) {
+		fprintf(stderr, "expected %s, but call succeeded\n", strerror(-error));
 		return 1;
 	}
 
-	if (errno != error) {
-		fprintf(stderr, "expected %d, got %d\n", error, errno);
+	if (ret != error) {
+		fprintf(stderr, "expected %d, got %d\n", error, ret);
 		return 1;
 	}
 
@@ -54,17 +54,17 @@ static int expect_fail(int fd, unsigned int to_submit,
 
 static int try_io_uring_enter(int fd, unsigned int to_submit,
 			      unsigned int min_complete, unsigned int flags,
-			      sigset_t *sig, int expect, int error)
+			      sigset_t *sig, int expect)
 {
 	int ret;
 
-	if (expect == -1)
-		return expect_fail(fd, to_submit, min_complete,
-				   flags, sig, error);
+	if (expect < 0)
+		return expect_fail(fd, to_submit, min_complete, flags, sig,
+				   expect);
 
 	ret = __sys_io_uring_enter(fd, to_submit, min_complete, flags, sig);
 	if (ret != expect) {
-		fprintf(stderr, "Expected %d, got %d\n", expect, errno);
+		fprintf(stderr, "Expected %d, got %d\n", expect, ret);
 		return 1;
 	}
 
@@ -197,16 +197,16 @@ int main(int argc, char **argv)
 	mask = *sq->kring_mask;
 
 	/* invalid flags */
-	status |= try_io_uring_enter(ring.ring_fd, 1, 0, ~0U, NULL, -1, EINVAL);
+	status |= try_io_uring_enter(ring.ring_fd, 1, 0, ~0U, NULL, -EINVAL);
 
 	/* invalid fd, EBADF */
-	status |= try_io_uring_enter(-1, 0, 0, 0, NULL, -1, EBADF);
+	status |= try_io_uring_enter(-1, 0, 0, 0, NULL, -EBADF);
 
 	/* valid, non-ring fd, EOPNOTSUPP */
-	status |= try_io_uring_enter(0, 0, 0, 0, NULL, -1, EOPNOTSUPP);
+	status |= try_io_uring_enter(0, 0, 0, 0, NULL, -EOPNOTSUPP);
 
 	/* to_submit: 0, flags: 0;  should get back 0. */
-	status |= try_io_uring_enter(ring.ring_fd, 0, 0, 0, NULL, 0, 0);
+	status |= try_io_uring_enter(ring.ring_fd, 0, 0, 0, NULL, 0);
 
 	/* fill the sq ring */
 	sq_entries = *ring.sq.kring_entries;
@@ -214,7 +214,7 @@ int main(int argc, char **argv)
 	ret = __sys_io_uring_enter(ring.ring_fd, 0, sq_entries,
 					IORING_ENTER_GETEVENTS, NULL);
 	if (ret < 0) {
-		perror("io_uring_enter");
+		fprintf(stderr, "io_uring_enter: %s\n", strerror(-ret));
 		status = 1;
 	} else {
 		/*
test/io_uring_register.c +17 -16
index 311bfdf..4609354 100644
@@ -37,7 +37,7 @@ static int expect_fail(int fd, unsigned int opcode, void *arg,
 	int ret;
 
 	ret = __sys_io_uring_register(fd, opcode, arg, nr_args);
-	if (ret != -1) {
+	if (ret >= 0) {
 		int ret2 = 0;
 
 		fprintf(stderr, "expected %s, but call succeeded\n", strerror(error));
@@ -55,8 +55,8 @@ static int expect_fail(int fd, unsigned int opcode, void *arg,
 		return 1;
 	}
 
-	if (errno != error) {
-		fprintf(stderr, "expected %d, got %d\n", error, errno);
+	if (ret != error) {
+		fprintf(stderr, "expected %d, got %d\n", error, ret);
 		return 1;
 	}
 	return 0;
@@ -279,7 +279,7 @@ static int test_iovec_nr(int fd)
 		iovs[i].iov_len = pagesize;
 	}
 
-	status |= expect_fail(fd, IORING_REGISTER_BUFFERS, iovs, nr, EINVAL);
+	status |= expect_fail(fd, IORING_REGISTER_BUFFERS, iovs, nr, -EINVAL);
 
 	/* reduce to UIO_MAXIOV */
 	nr = UIO_MAXIOV;
@@ -310,12 +310,12 @@ static int test_iovec_size(int fd)
 	/* NULL pointer for base */
 	iov.iov_base = 0;
 	iov.iov_len = 4096;
-	status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, EFAULT);
+	status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, -EFAULT);
 
 	/* valid base, 0 length */
 	iov.iov_base = &buf;
 	iov.iov_len = 0;
-	status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, EFAULT);
+	status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, -EFAULT);
 
 	/* valid base, length exceeds size */
 	/* this requires an unampped page directly after buf */
@@ -326,7 +326,7 @@ static int test_iovec_size(int fd)
 	assert(ret == 0);
 	iov.iov_base = buf;
 	iov.iov_len = 2 * pagesize;
-	status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, EFAULT);
+	status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, -EFAULT);
 	munmap(buf, pagesize);
 
 	/* huge page */
@@ -346,20 +346,21 @@ static int test_iovec_size(int fd)
 		iov.iov_len = 2*1024*1024;
 		ret = __sys_io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
 		if (ret < 0) {
-			if (errno == ENOMEM)
+			if (ret == -ENOMEM)
 				printf("Unable to test registering of a huge "
 				       "page.  Try increasing the "
 				       "RLIMIT_MEMLOCK resource limit by at "
 				       "least 2MB.");
 			else {
-				fprintf(stderr, "expected success, got %d\n", errno);
+				fprintf(stderr, "expected success, got %d\n", ret);
 				status = 1;
 			}
 		} else {
 			ret = __sys_io_uring_register(fd,
 					IORING_UNREGISTER_BUFFERS, 0, 0);
 			if (ret < 0) {
-				perror("io_uring_unregister");
+				fprintf(stderr, "io_uring_unregister: %s\n",
+					strerror(-ret));
 				status = 1;
 			}
 		}
@@ -373,7 +374,7 @@ static int test_iovec_size(int fd)
 		status = 1;
 	iov.iov_base = buf;
 	iov.iov_len = 2*1024*1024;
-	status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, EOPNOTSUPP);
+	status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, -EOPNOTSUPP);
 	munmap(buf, 2*1024*1024);
 
 	/* bump up against the soft limit and make sure we get EFAULT
@@ -401,7 +402,7 @@ static int ioring_poll(struct io_uring *ring, int fd, int fixed)
 
 	ret = io_uring_submit(ring);
 	if (ret != 1) {
-		fprintf(stderr, "failed to submit poll sqe: %d.\n", errno);
+		fprintf(stderr, "failed to submit poll sqe: %d.\n", ret);
 		return 1;
 	}
 
@@ -443,7 +444,7 @@ static int test_poll_ringfd(void)
 	 * fail, because the kernel does not allow registering of the
 	 * ring_fd.
 	 */
-	status |= expect_fail(fd, IORING_REGISTER_FILES, &fd, 1, EBADF);
+	status |= expect_fail(fd, IORING_REGISTER_FILES, &fd, 1, -EBADF);
 
 	/* tear down queue */
 	io_uring_queue_exit(&ring);
@@ -476,14 +477,14 @@ int main(int argc, char **argv)
 	}
 
 	/* invalid fd */
-	status |= expect_fail(-1, 0, NULL, 0, EBADF);
+	status |= expect_fail(-1, 0, NULL, 0, -EBADF);
 	/* valid fd that is not an io_uring fd */
-	status |= expect_fail(devnull, 0, NULL, 0, EOPNOTSUPP);
+	status |= expect_fail(devnull, 0, NULL, 0, -EOPNOTSUPP);
 
 	/* invalid opcode */
 	memset(&p, 0, sizeof(p));
 	fd = new_io_uring(1, &p);
-	ret = expect_fail(fd, ~0U, NULL, 0, EINVAL);
+	ret = expect_fail(fd, ~0U, NULL, 0, -EINVAL);
 	if (ret) {
 		/* if this succeeds, tear down the io_uring instance
 		 * and start clean for the next test. */
test/io_uring_setup.c +13 -13
index 3c50e2a..67d5f4f 100644
@@ -98,9 +98,9 @@ dump_resv(struct io_uring_params *p)
 /* bogus: setup returns a valid fd on success... expect can't predict the
    fd we'll get, so this really only takes 1 parameter: error */
 int
-try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect, int error)
+try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect)
 {
-	int ret, err;
+	int ret;
 
 	ret = __sys_io_uring_setup(entries, p);
 	if (ret != expect) {
@@ -110,13 +110,13 @@ try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect, int
 			close(ret);
 		return 1;
 	}
-	err = errno;
-	if (expect == -1 && error != err) {
-		if (err == EPERM && geteuid() != 0) {
+
+	if (expect < 0 && expect != ret) {
+		if (ret == -EPERM && geteuid() != 0) {
 			printf("Needs root, not flagging as an error\n");
 			return 0;
 		}
-		fprintf(stderr, "expected errno %d, got %d\n", error, err);
+		fprintf(stderr, "expected errno %d, got %d\n", expect, ret);
 		return 1;
 	}
 
@@ -134,29 +134,29 @@ main(int argc, char **argv)
 		return T_EXIT_SKIP;
 
 	memset(&p, 0, sizeof(p));
-	status |= try_io_uring_setup(0, &p, -1, EINVAL);
-	status |= try_io_uring_setup(1, NULL, -1, EFAULT);
+	status |= try_io_uring_setup(0, &p, -EINVAL);
+	status |= try_io_uring_setup(1, NULL, -EFAULT);
 
 	/* resv array is non-zero */
 	memset(&p, 0, sizeof(p));
 	p.resv[0] = p.resv[1] = p.resv[2] = 1;
-	status |= try_io_uring_setup(1, &p, -1, EINVAL);
+	status |= try_io_uring_setup(1, &p, -EINVAL);
 
 	/* invalid flags */
 	memset(&p, 0, sizeof(p));
 	p.flags = ~0U;
-	status |= try_io_uring_setup(1, &p, -1, EINVAL);
+	status |= try_io_uring_setup(1, &p, -EINVAL);
 
 	/* IORING_SETUP_SQ_AFF set but not IORING_SETUP_SQPOLL */
 	memset(&p, 0, sizeof(p));
 	p.flags = IORING_SETUP_SQ_AFF;
-	status |= try_io_uring_setup(1, &p, -1, EINVAL);
+	status |= try_io_uring_setup(1, &p, -EINVAL);
 
 	/* attempt to bind to invalid cpu */
 	memset(&p, 0, sizeof(p));
 	p.flags = IORING_SETUP_SQPOLL | IORING_SETUP_SQ_AFF;
 	p.sq_thread_cpu = get_nprocs_conf();
-	status |= try_io_uring_setup(1, &p, -1, EINVAL);
+	status |= try_io_uring_setup(1, &p, -EINVAL);
 
 	/* I think we can limit a process to a set of cpus.  I assume
 	 * we shouldn't be able to setup a kernel thread outside of that.
@@ -167,7 +167,7 @@ main(int argc, char **argv)
 	fd = __sys_io_uring_setup(1, &p);
 	if (fd < 0) {
 		fprintf(stderr, "io_uring_setup failed with %d, expected success\n",
-		       errno);
+		       -fd);
 		status = 1;
 	} else {
 		char buf[4096];
test/rsrc_tags.c +5 -8
index 2d11d2a..ca380d8 100644
@@ -40,7 +40,7 @@ static int register_rsrc(struct io_uring *ring, int type, int nr,
 			  const void *arg, const __u64 *tags)
 {
 	struct io_uring_rsrc_register reg;
-	int ret, reg_type;
+	int reg_type;
 
 	memset(&reg, 0, sizeof(reg));
 	reg.nr = nr;
@@ -51,9 +51,8 @@ static int register_rsrc(struct io_uring *ring, int type, int nr,
 	if (type != TEST_IORING_RSRC_FILE)
 		reg_type = IORING_REGISTER_BUFFERS2;
 
-	ret = __sys_io_uring_register(ring->ring_fd, reg_type,
-					&reg, sizeof(reg));
-	return ret ? -errno : 0;
+	return __sys_io_uring_register(ring->ring_fd, reg_type, &reg,
+				       sizeof(reg));
 }
 
 /*
@@ -64,7 +63,7 @@ static int update_rsrc(struct io_uring *ring, int type, int nr, int off,
 			const void *arg, const __u64 *tags)
 {
 	struct io_uring_rsrc_update2 up;
-	int ret, up_type;
+	int up_type;
 
 	memset(&up, 0, sizeof(up));
 	up.offset = off;
@@ -75,9 +74,7 @@ static int update_rsrc(struct io_uring *ring, int type, int nr, int off,
 	up_type = IORING_REGISTER_FILES_UPDATE2;
 	if (type != TEST_IORING_RSRC_FILE)
 		up_type = IORING_REGISTER_BUFFERS_UPDATE;
-	ret = __sys_io_uring_register(ring->ring_fd, up_type,
-				      &up, sizeof(up));
-	return ret < 0 ? -errno : ret;
+	return __sys_io_uring_register(ring->ring_fd, up_type, &up, sizeof(up));
 }
 
 static bool has_rsrc_update(void)

base-commit: 4e6eec8bdea906fe5341c97aef96986d605004e9

Signature · 1 line
Ammar Faizi
maintainer Applied
#1 lore raw
Quoted 11 lines · Ammar Faizi

Back when I was adding nolibc support for liburing, I added new wrapper functions for io_uring system calls. They are ____sys_io_uring* functions (with 4 underscores), all defined as an inline function.

I left __sys_uring* functions (with 2 underscores) live in syscall.c because I thought it might break the user if we delete them. But it turned out that I was wrong, no user should use these functions because we don't export them. This situation is reflected in liburing.map and liburing.h which don't have those functions.

[...]

Applied, thanks!

[1/1] Delete src/syscall.c and get back to use __sys_io_uring* functions

      commit: 4aa1a8aefc3dc3875621c64cef0087968e57181d

Best regards,

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 11 lines · Jens Axboe
Quoted 10 lines · Ammar Faizi

Back when I was adding nolibc support for liburing, I added new wrapper functions for io_uring system calls. They are ____sys_io_uring* functions (with 4 underscores), all defined as an inline function.

I left __sys_uring* functions (with 2 underscores) live in syscall.c because I thought it might break the user if we delete them. But it turned out that I was wrong, no user should use these functions because we don't export them. This situation is reflected in liburing.map and liburing.h which don't have those functions.

Quoted 6 lines
Quoted 1 line

[...]

Applied, thanks!

[1/1] Delete src/syscall.c and get back to use __sys_io_uring* functions

       commit: 4aa1a8aefc3dc3875621c64cef0087968e57181d

Sorry Jens, it breaks other architectures, will send a patch shortly.

Signature · 1 line
Ammar Faizi
maintainer
#3 lore raw
Quoted 12 lines · Ammar Faizi
Quoted 11 lines · Jens Axboe
Quoted 10 lines · Ammar Faizi

Back when I was adding nolibc support for liburing, I added new wrapper functions for io_uring system calls. They are ____sys_io_uring* functions (with 4 underscores), all defined as an inline function.

I left __sys_uring* functions (with 2 underscores) live in syscall.c because I thought it might break the user if we delete them. But it turned out that I was wrong, no user should use these functions because we don't export them. This situation is reflected in liburing.map and liburing.h which don't have those functions.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

[...]

Applied, thanks!

[1/1] Delete src/syscall.c and get back to use __sys_io_uring* functions

       commit: 4aa1a8aefc3dc3875621c64cef0087968e57181d

Sorry Jens, it breaks other architectures, will send a patch shortly.

I ran x86-64 and aarch64, seems that it did indeed break x86. I'll wait for your patch.

Signature · 1 line
Jens Axboe
#4 lore raw

PATCH 1/1 arch/generic: Rename `____sys_io_uring*` to `__sys_io_uring*`

In commit:

4aa1a8aefc3dc3875621c64cef0087968e57181d ("Delete src/syscall.c and get back to use __sys_io_uring* functions")

I forgot to rename ____sys_io_uring* to __sys_io_uring* in arch/generic. This results in build error on archs other than aarch64 and x86-64:

error: implicit declaration of function __sys_io_uring*;

Rename ____sys_io_uring* to __sys_io_uring*. Thanks to the GitHub bot who spotted the issue quickly!

Fixes 4aa1a8aefc3dc3875621c64cef0087968e57181d ("Delete src/syscall.c and get back to use __sys_io_uring* functions")
---
 src/arch/generic/syscall.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
src/arch/generic/syscall.h +12 -12
index e637890..5a172e1 100644
@@ -5,25 +5,25 @@
 
 #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(int fd, unsigned opcode,
+					  const void *arg, unsigned 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,
-					 struct io_uring_params *p)
+static inline int __sys_io_uring_setup(unsigned entries,
+				       struct io_uring_params *p)
 {
 	int ret;
 	ret = syscall(__NR_io_uring_setup, entries, p);
 	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(int fd, unsigned to_submit,
+					unsigned min_complete, unsigned flags,
+					sigset_t *sig, int sz)
 {
 	int ret;
 	ret = syscall(__NR_io_uring_enter, fd, to_submit, min_complete, flags,
@@ -31,12 +31,12 @@ 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(int fd, unsigned to_submit,
+				       unsigned min_complete, unsigned flags,
+				       sigset_t *sig)
 {
-	return ____sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
-				       _NSIG / 8);
+	return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
+				     _NSIG / 8);
 }
 
 static inline int __sys_open(const char *pathname, int flags, mode_t mode)
Signature · 1 line
2.34.1
maintainer Applied
#5 lore raw

Re: [PATCH] arch/generic: Rename `____sys_io_uring*` to `__sys_io_uring*`

Quoted 9 lines · Ammar Faizi

In commit:

4aa1a8aefc3dc3875621c64cef0087968e57181d ("Delete src/syscall.c and get back to use __sys_io_uring* functions")

I forgot to rename ____sys_io_uring* to __sys_io_uring* in arch/generic. This results in build error on archs other than aarch64 and x86-64:

[...]

Applied, thanks!

[1/1] arch/generic: Rename ____sys_io_uring* to __sys_io_uring*

      commit: 441d376c3c1abccd92d1ba6a5ceb343a4683a434

Best regards,

Signature · 1 line
Jens Axboe