public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing v2 0/8] aarch64 support
@ 2022-06-29 17:58 Ammar Faizi
  2022-06-29 17:58 ` [PATCH liburing v2 1/8] CHANGELOG: Fixup missing space Ammar Faizi
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Ammar Faizi @ 2022-06-29 17:58 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Alviro Iskandar Setiawan, Fernanda Ma'rouf,
	Pavel Begunkov, Hao Xu, io-uring Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <[email protected]>

Hi Jens,

This is v2 revision of aarch64 support.

This series contains nolibc support for aarch64 and one extra irrelevant
cleanup (patch #1). The missing bit from aarch64 is get_page_size()
which is a bit complicated to implement without libc.

aarch64 supports three values of page size: 4K, 16K, and 64K which are
selected at kernel compilation time. Therefore, we can't hard code the
page size for this arch. In this series we utilize open(), read() and
close() syscall to find the page size from /proc/self/auxv.

The auxiliary vector contains information about the page size, it is
located at `AT_PAGESZ` keyval pair.

For more details about the auxv data structure, check the link below.

Link: https://github.com/torvalds/linux/blob/v5.19-rc4/fs/binfmt_elf.c#L260
Link: https://lwn.net/Articles/631631/

There are 8 patches in this series. Summary:

- Patch 1 is just a trivial changelog fix.
- Patch 2 and 3 are to add open() and read() syscall. We will need them
  to get the page size on aarch64.
- Patch 4 is to remove __INTERNAL__LIBURING_SYSCALL_H checks.
- Patch 5 is to add get_page_size() function.
- Patch 6 is to enable the nolibc support for aarch64.
- Patch 7 is for GitHub bot build.
- Patch 8 is to update the CHANGELOG to note aarch64 nolibc support.

I have built it with GitHub bot and it compiles just fine. But I don't
have an aarch64 machine to run the tests. Since you are using aarch64,
I can rely on you to test it.

How to test this?

  make clean;
  ./configure --nolibc;
  make -j8;

  ldd src/liburing.so.2.3;
  # Make sure you don't see libc.so from the `ldd` command.

  make runtests;

Please give it a test, thanks!

## Changelog

v1 -> v2:
  - Drop aarch64 renaming directory patch.
  - Fallback the page size to 4K if we fail to get it.
  - Cache the page size after we read it from /proc/self/auxv.
  - Massage commit messages.
  - Note aarch64 nolibc support in CHANGELOG.


Signed-off-by: Ammar Faizi <[email protected]>
---

Ammar Faizi (8):
  CHANGELOG: Fixup missing space
  arch: syscall: Add `__sys_open()` syscall
  arch: syscall: Add `__sys_read()` syscall
  arch: Remove `__INTERNAL__LIBURING_LIB_H` checks
  arch/aarch64: lib: Add `get_page_size()` function
  arch: Enable nolibc support for aarch64
  .github: Enable aarch64 nolibc build for GitHub bot
  CHANGELOG: Note about aarch64 support

 .github/workflows/build.yml |  2 +-
 CHANGELOG                   |  7 +++++-
 src/arch/aarch64/lib.h      | 45 +++++++++++++++++++++++++++++++++++++
 src/arch/aarch64/syscall.h  |  8 +++----
 src/arch/generic/lib.h      |  4 ----
 src/arch/generic/syscall.h  | 20 +++++++++++++----
 src/arch/syscall-defs.h     | 12 ++++++++++
 src/arch/x86/lib.h          |  4 ----
 src/arch/x86/syscall.h      |  4 ----
 src/lib.h                   | 32 +++++++++++++-------------
 src/syscall.h               |  2 --
 11 files changed, 100 insertions(+), 40 deletions(-)
 create mode 100644 src/arch/aarch64/lib.h


base-commit: 7d1cce2112ddf358b56ae0abd18c86e8ede9447f
-- 
Ammar Faizi


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

* [PATCH liburing v2 1/8] CHANGELOG: Fixup missing space
  2022-06-29 17:58 [PATCH liburing v2 0/8] aarch64 support Ammar Faizi
@ 2022-06-29 17:58 ` Ammar Faizi
  2022-06-29 17:58 ` [PATCH liburing v2 2/8] arch: syscall: Add `__sys_open()` syscall Ammar Faizi
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Ammar Faizi @ 2022-06-29 17:58 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Alviro Iskandar Setiawan, Fernanda Ma'rouf,
	Pavel Begunkov, Hao Xu, io-uring Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <[email protected]>

  s/reducingthe/reducing the/

Signed-off-by: Ammar Faizi <[email protected]>
---
 CHANGELOG | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 01cb677..efb3ff3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,7 +6,7 @@ liburing-2.2 release
 - Add support for multishot accept.
 - io_uring_register_files() will set RLIMIT_NOFILE if necessary.
 - Add support for registered ring fds, io_uring_register_ring_fd(),
-  reducingthe overhead of an io_uring_enter() system call.
+  reducing the overhead of an io_uring_enter() system call.
 - Add support for the message ring opcode.
 - Add support for newer request cancelation features.
 - Add support for IORING_SETUP_COOP_TASKRUN, which can help reduce the
-- 
Ammar Faizi


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

* [PATCH liburing v2 2/8] arch: syscall: Add `__sys_open()` syscall
  2022-06-29 17:58 [PATCH liburing v2 0/8] aarch64 support Ammar Faizi
  2022-06-29 17:58 ` [PATCH liburing v2 1/8] CHANGELOG: Fixup missing space Ammar Faizi
@ 2022-06-29 17:58 ` Ammar Faizi
  2022-06-29 17:58 ` [PATCH liburing v2 3/8] arch: syscall: Add `__sys_read()` syscall Ammar Faizi
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Ammar Faizi @ 2022-06-29 17:58 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Alviro Iskandar Setiawan, Fernanda Ma'rouf,
	Pavel Begunkov, Hao Xu, io-uring Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <[email protected]>

A prep patch to support aarch64 nolibc. We will use this to get the
page size by reading /proc/self/auxv. For some reason __NR_open is
not defined, so also define it in aarch64 syscall specific file.

Signed-off-by: Ammar Faizi <[email protected]>
---
 src/arch/aarch64/syscall.h | 4 ++++
 src/arch/generic/syscall.h | 9 +++++++++
 src/arch/syscall-defs.h    | 7 +++++++
 3 files changed, 20 insertions(+)

diff --git a/src/arch/aarch64/syscall.h b/src/arch/aarch64/syscall.h
index c0ab7e2..5e26714 100644
--- a/src/arch/aarch64/syscall.h
+++ b/src/arch/aarch64/syscall.h
@@ -84,6 +84,10 @@
 			"r" (x4), "r"(x5));				\
 })
 
+#ifndef __NR_open
+#define __NR_open 	0x400
+#endif
+
 #include "../syscall-defs.h"
 
 #else /* #if defined(__aarch64__) */
diff --git a/src/arch/generic/syscall.h b/src/arch/generic/syscall.h
index fa93064..71b2234 100644
--- a/src/arch/generic/syscall.h
+++ b/src/arch/generic/syscall.h
@@ -7,6 +7,8 @@
 #ifndef LIBURING_ARCH_GENERIC_SYSCALL_H
 #define LIBURING_ARCH_GENERIC_SYSCALL_H
 
+#include <fcntl.h>
+
 static inline int ____sys_io_uring_register(int fd, unsigned opcode,
 					    const void *arg, unsigned nr_args)
 {
@@ -41,6 +43,13 @@ static inline int ____sys_io_uring_enter(int fd, unsigned to_submit,
 				       _NSIG / 8);
 }
 
+static inline int __sys_open(const char *pathname, int flags, mode_t mode)
+{
+	int ret;
+	ret = open(pathname, flags, mode);
+	return (ret < 0) ? -errno : ret;
+}
+
 static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
 			       int fd, off_t offset)
 {
diff --git a/src/arch/syscall-defs.h b/src/arch/syscall-defs.h
index 1e8ae1b..0f67446 100644
--- a/src/arch/syscall-defs.h
+++ b/src/arch/syscall-defs.h
@@ -3,6 +3,13 @@
 #ifndef LIBURING_ARCH_SYSCALL_DEFS_H
 #define LIBURING_ARCH_SYSCALL_DEFS_H
 
+#include <fcntl.h>
+
+static inline int __sys_open(const char *pathname, int flags, mode_t mode)
+{
+	return (int) __do_syscall3(__NR_open, pathname, flags, mode);
+}
+
 static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
 			       int fd, off_t offset)
 {
-- 
Ammar Faizi


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

* [PATCH liburing v2 3/8] arch: syscall: Add `__sys_read()` syscall
  2022-06-29 17:58 [PATCH liburing v2 0/8] aarch64 support Ammar Faizi
  2022-06-29 17:58 ` [PATCH liburing v2 1/8] CHANGELOG: Fixup missing space Ammar Faizi
  2022-06-29 17:58 ` [PATCH liburing v2 2/8] arch: syscall: Add `__sys_open()` syscall Ammar Faizi
@ 2022-06-29 17:58 ` Ammar Faizi
  2022-06-29 17:58 ` [PATCH liburing v2 4/8] arch: Remove `__INTERNAL__LIBURING_LIB_H` checks Ammar Faizi
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Ammar Faizi @ 2022-06-29 17:58 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Alviro Iskandar Setiawan, Fernanda Ma'rouf,
	Pavel Begunkov, Hao Xu, io-uring Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <[email protected]>

A prep patch to support aarch64 nolibc. We will use this to get the
page size by reading /proc/self/auxv.

Signed-off-by: Ammar Faizi <[email protected]>
---
 src/arch/generic/syscall.h | 7 +++++++
 src/arch/syscall-defs.h    | 5 +++++
 2 files changed, 12 insertions(+)

diff --git a/src/arch/generic/syscall.h b/src/arch/generic/syscall.h
index 71b2234..22252a1 100644
--- a/src/arch/generic/syscall.h
+++ b/src/arch/generic/syscall.h
@@ -50,6 +50,13 @@ static inline int __sys_open(const char *pathname, int flags, mode_t mode)
 	return (ret < 0) ? -errno : ret;
 }
 
+static inline ssize_t __sys_read(int fd, void *buffer, size_t size)
+{
+	ssize_t ret;
+	ret = read(fd, buffer, size);
+	return (ret < 0) ? -errno : ret;
+}
+
 static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
 			       int fd, off_t offset)
 {
diff --git a/src/arch/syscall-defs.h b/src/arch/syscall-defs.h
index 0f67446..4b5ba40 100644
--- a/src/arch/syscall-defs.h
+++ b/src/arch/syscall-defs.h
@@ -10,6 +10,11 @@ static inline int __sys_open(const char *pathname, int flags, mode_t mode)
 	return (int) __do_syscall3(__NR_open, pathname, flags, mode);
 }
 
+static inline int __sys_read(int fd, void *buffer, size_t size)
+{
+	return (int) __do_syscall3(__NR_read, fd, buffer, size);
+}
+
 static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
 			       int fd, off_t offset)
 {
-- 
Ammar Faizi


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

* [PATCH liburing v2 4/8] arch: Remove `__INTERNAL__LIBURING_LIB_H` checks
  2022-06-29 17:58 [PATCH liburing v2 0/8] aarch64 support Ammar Faizi
                   ` (2 preceding siblings ...)
  2022-06-29 17:58 ` [PATCH liburing v2 3/8] arch: syscall: Add `__sys_read()` syscall Ammar Faizi
@ 2022-06-29 17:58 ` Ammar Faizi
  2022-06-29 17:58 ` [PATCH liburing v2 5/8] arch/aarch64: lib: Add `get_page_size()` function Ammar Faizi
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Ammar Faizi @ 2022-06-29 17:58 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Alviro Iskandar Setiawan, Fernanda Ma'rouf,
	Pavel Begunkov, Hao Xu, io-uring Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <[email protected]>

We will include the syscall.h from another place as well. This check
was added by me when adding the x86 syscalls. For aarch64 we will
include this header from lib.h but we are restricted by this check.
Let's just remove it for all archs. User shouldn't touch this code
directly anyway.

Signed-off-by: Ammar Faizi <[email protected]>
---
 src/arch/aarch64/syscall.h | 4 ----
 src/arch/generic/lib.h     | 4 ----
 src/arch/generic/syscall.h | 4 ----
 src/arch/x86/lib.h         | 4 ----
 src/arch/x86/syscall.h     | 4 ----
 src/lib.h                  | 2 --
 src/syscall.h              | 2 --
 7 files changed, 24 deletions(-)

diff --git a/src/arch/aarch64/syscall.h b/src/arch/aarch64/syscall.h
index 5e26714..9786c14 100644
--- a/src/arch/aarch64/syscall.h
+++ b/src/arch/aarch64/syscall.h
@@ -1,9 +1,5 @@
 /* SPDX-License-Identifier: MIT */
 
-#ifndef __INTERNAL__LIBURING_SYSCALL_H
-	#error "This file should be included from src/syscall.h (liburing)"
-#endif
-
 #ifndef LIBURING_ARCH_AARCH64_SYSCALL_H
 #define LIBURING_ARCH_AARCH64_SYSCALL_H
 
diff --git a/src/arch/generic/lib.h b/src/arch/generic/lib.h
index 737e795..6b006c6 100644
--- a/src/arch/generic/lib.h
+++ b/src/arch/generic/lib.h
@@ -1,9 +1,5 @@
 /* SPDX-License-Identifier: MIT */
 
-#ifndef __INTERNAL__LIBURING_LIB_H
-	#error "This file should be included from src/lib.h (liburing)"
-#endif
-
 #ifndef LIBURING_ARCH_GENERIC_LIB_H
 #define LIBURING_ARCH_GENERIC_LIB_H
 
diff --git a/src/arch/generic/syscall.h b/src/arch/generic/syscall.h
index 22252a1..e637890 100644
--- a/src/arch/generic/syscall.h
+++ b/src/arch/generic/syscall.h
@@ -1,9 +1,5 @@
 /* SPDX-License-Identifier: MIT */
 
-#ifndef __INTERNAL__LIBURING_SYSCALL_H
-	#error "This file should be included from src/syscall.h (liburing)"
-#endif
-
 #ifndef LIBURING_ARCH_GENERIC_SYSCALL_H
 #define LIBURING_ARCH_GENERIC_SYSCALL_H
 
diff --git a/src/arch/x86/lib.h b/src/arch/x86/lib.h
index e6a74f3..6ece2d4 100644
--- a/src/arch/x86/lib.h
+++ b/src/arch/x86/lib.h
@@ -1,9 +1,5 @@
 /* SPDX-License-Identifier: MIT */
 
-#ifndef __INTERNAL__LIBURING_LIB_H
-	#error "This file should be included from src/lib.h (liburing)"
-#endif
-
 #ifndef LIBURING_ARCH_X86_LIB_H
 #define LIBURING_ARCH_X86_LIB_H
 
diff --git a/src/arch/x86/syscall.h b/src/arch/x86/syscall.h
index 43c576b..cb8fb91 100644
--- a/src/arch/x86/syscall.h
+++ b/src/arch/x86/syscall.h
@@ -1,9 +1,5 @@
 /* SPDX-License-Identifier: MIT */
 
-#ifndef __INTERNAL__LIBURING_SYSCALL_H
-	#error "This file should be included from src/syscall.h (liburing)"
-#endif
-
 #ifndef LIBURING_ARCH_X86_SYSCALL_H
 #define LIBURING_ARCH_X86_SYSCALL_H
 
diff --git a/src/lib.h b/src/lib.h
index 6672cc5..e5f3680 100644
--- a/src/lib.h
+++ b/src/lib.h
@@ -6,7 +6,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#define __INTERNAL__LIBURING_LIB_H
 #if defined(__x86_64__) || defined(__i386__)
 	#include "arch/x86/lib.h"
 #else
@@ -19,7 +18,6 @@
 	/* libc wrappers. */
 	#include "arch/generic/lib.h"
 #endif
-#undef __INTERNAL__LIBURING_LIB_H
 
 
 #ifndef offsetof
diff --git a/src/syscall.h b/src/syscall.h
index 214789d..73b04b4 100644
--- a/src/syscall.h
+++ b/src/syscall.h
@@ -70,7 +70,6 @@ static inline bool IS_ERR(const void *ptr)
 	return uring_unlikely((uintptr_t) ptr >= (uintptr_t) -4095UL);
 }
 
-#define __INTERNAL__LIBURING_SYSCALL_H
 #if defined(__x86_64__) || defined(__i386__)
 #include "arch/x86/syscall.h"
 #elif defined(__aarch64__)
@@ -86,7 +85,6 @@ static inline bool IS_ERR(const void *ptr)
 /* libc syscall wrappers. */
 #include "arch/generic/syscall.h"
 #endif
-#undef __INTERNAL__LIBURING_SYSCALL_H
 
 /*
  * For backward compatibility.
-- 
Ammar Faizi


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

* [PATCH liburing v2 5/8] arch/aarch64: lib: Add `get_page_size()` function
  2022-06-29 17:58 [PATCH liburing v2 0/8] aarch64 support Ammar Faizi
                   ` (3 preceding siblings ...)
  2022-06-29 17:58 ` [PATCH liburing v2 4/8] arch: Remove `__INTERNAL__LIBURING_LIB_H` checks Ammar Faizi
@ 2022-06-29 17:58 ` Ammar Faizi
  2022-06-29 17:58 ` [PATCH liburing v2 6/8] arch: Enable nolibc support for aarch64 Ammar Faizi
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Ammar Faizi @ 2022-06-29 17:58 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Alviro Iskandar Setiawan, Fernanda Ma'rouf,
	Pavel Begunkov, Hao Xu, io-uring Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <[email protected]>

A prep patch to add aarch64 nolibc support.

aarch64 supports three values of page size: 4K, 16K, and 64K which are
selected at kernel compilation time. Therefore, we can't hard code the
page size for this arch. Utilize open(), read() and close() syscall to
find the page size from /proc/self/auxv. For more details about the
auxv data structure, check the link below [1].

v2:
  - Fallback to 4K if the syscall fails.
  - Cache the page size after read as suggested by Jens.

Link: https://github.com/torvalds/linux/blob/v5.19-rc4/fs/binfmt_elf.c#L260 [1]
Link: https://lore.kernel.org/io-uring/[email protected]
Link: https://lore.kernel.org/io-uring/[email protected]
Suggested-by: Jens Axboe <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 src/arch/aarch64/lib.h | 45 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 src/arch/aarch64/lib.h

diff --git a/src/arch/aarch64/lib.h b/src/arch/aarch64/lib.h
new file mode 100644
index 0000000..adba512
--- /dev/null
+++ b/src/arch/aarch64/lib.h
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef LIBURING_ARCH_AARCH64_LIB_H
+#define LIBURING_ARCH_AARCH64_LIB_H
+
+#include <elf.h>
+#include <sys/auxv.h>
+#include "../../syscall.h"
+
+static inline long get_page_size(void)
+{
+	static const long fallback_ret = 4096;
+	static long cache_val = 0;
+	Elf64_Off buf[2];
+	long page_size;
+	int fd;
+
+	if (cache_val)
+		return cache_val;
+
+	fd = __sys_open("/proc/self/auxv", O_RDONLY, 0);
+	if (fd < 0)
+		return fallback_ret;
+
+	while (1) {
+		ssize_t x;
+
+		x = __sys_read(fd, buf, sizeof(buf));
+		if (x < sizeof(buf)) {
+			page_size = fallback_ret;
+			break;
+		}
+
+		if (buf[0] == AT_PAGESZ) {
+			page_size = buf[1];
+			cache_val = page_size;
+			break;
+		}
+	}
+
+	__sys_close(fd);
+	return page_size;
+}
+
+#endif /* #ifndef LIBURING_ARCH_AARCH64_LIB_H */
-- 
Ammar Faizi


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

* [PATCH liburing v2 6/8] arch: Enable nolibc support for aarch64
  2022-06-29 17:58 [PATCH liburing v2 0/8] aarch64 support Ammar Faizi
                   ` (4 preceding siblings ...)
  2022-06-29 17:58 ` [PATCH liburing v2 5/8] arch/aarch64: lib: Add `get_page_size()` function Ammar Faizi
@ 2022-06-29 17:58 ` Ammar Faizi
  2022-06-29 17:58 ` [PATCH liburing v2 7/8] .github: Enable aarch64 nolibc build for GitHub bot Ammar Faizi
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Ammar Faizi @ 2022-06-29 17:58 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Alviro Iskandar Setiawan, Fernanda Ma'rouf,
	Pavel Begunkov, Hao Xu, io-uring Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <[email protected]>

Support nolibc build for aarch64. While in there, don't indent the
block inside #if / #elif / #else / #endif.

Signed-off-by: Ammar Faizi <[email protected]>
---
 src/lib.h | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/lib.h b/src/lib.h
index e5f3680..399467c 100644
--- a/src/lib.h
+++ b/src/lib.h
@@ -7,28 +7,30 @@
 #include <unistd.h>
 
 #if defined(__x86_64__) || defined(__i386__)
-	#include "arch/x86/lib.h"
+#include "arch/x86/lib.h"
+#elif defined(__aarch64__)
+#include "arch/aarch64/lib.h"
 #else
-	/*
-	 * We don't have nolibc support for this arch. Must use libc!
-	 */
-	#ifdef CONFIG_NOLIBC
-		#error "This arch doesn't support building liburing without libc"
-	#endif
-	/* libc wrappers. */
-	#include "arch/generic/lib.h"
+/*
+ * We don't have nolibc support for this arch. Must use libc!
+ */
+#ifdef CONFIG_NOLIBC
+#error "This arch doesn't support building liburing without libc"
+#endif
+/* libc wrappers. */
+#include "arch/generic/lib.h"
 #endif
 
 
 #ifndef offsetof
-	#define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD)
+#define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD)
 #endif
 
 #ifndef container_of
-	#define container_of(PTR, TYPE, FIELD) ({			\
-		__typeof__(((TYPE *)0)->FIELD) *__FIELD_PTR = (PTR);	\
-		(TYPE *)((char *) __FIELD_PTR - offsetof(TYPE, FIELD));	\
-	})
+#define container_of(PTR, TYPE, FIELD) ({			\
+	__typeof__(((TYPE *)0)->FIELD) *__FIELD_PTR = (PTR);	\
+	(TYPE *)((char *) __FIELD_PTR - offsetof(TYPE, FIELD));	\
+})
 #endif
 
 void *__uring_malloc(size_t len);
-- 
Ammar Faizi


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

* [PATCH liburing v2 7/8] .github: Enable aarch64 nolibc build for GitHub bot
  2022-06-29 17:58 [PATCH liburing v2 0/8] aarch64 support Ammar Faizi
                   ` (5 preceding siblings ...)
  2022-06-29 17:58 ` [PATCH liburing v2 6/8] arch: Enable nolibc support for aarch64 Ammar Faizi
@ 2022-06-29 17:58 ` Ammar Faizi
  2022-06-29 17:58 ` [PATCH liburing v2 8/8] CHANGELOG: Note about aarch64 support Ammar Faizi
  2022-07-04 12:52 ` [PATCH liburing v2 0/8] " Ammar Faizi
  8 siblings, 0 replies; 12+ messages in thread
From: Ammar Faizi @ 2022-06-29 17:58 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Alviro Iskandar Setiawan, Fernanda Ma'rouf,
	Pavel Begunkov, Hao Xu, io-uring Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <[email protected]>

Signed-off-by: Ammar Faizi <[email protected]>
---
 .github/workflows/build.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 88192ff..fc119cb 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -114,7 +114,7 @@ jobs:
 
     - name: Build nolibc
       run: |
-        if [[ "${{matrix.arch}}" == "x86_64" || "${{matrix.arch}}" == "i686" ]]; then \
+        if [[ "${{matrix.arch}}" == "x86_64" || "${{matrix.arch}}" == "i686" || "${{matrix.arch}}" == "aarch64" ]]; then \
             make clean; \
             ./configure --cc=${{matrix.cc}} --cxx=${{matrix.cxx}} --nolibc; \
             make -j$(nproc) V=1 CPPFLAGS="-Werror" CFLAGS="$FLAGS" CXXFLAGS="$FLAGS"; \
-- 
Ammar Faizi


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

* [PATCH liburing v2 8/8] CHANGELOG: Note about aarch64 support
  2022-06-29 17:58 [PATCH liburing v2 0/8] aarch64 support Ammar Faizi
                   ` (6 preceding siblings ...)
  2022-06-29 17:58 ` [PATCH liburing v2 7/8] .github: Enable aarch64 nolibc build for GitHub bot Ammar Faizi
@ 2022-06-29 17:58 ` Ammar Faizi
  2022-07-04 12:52 ` [PATCH liburing v2 0/8] " Ammar Faizi
  8 siblings, 0 replies; 12+ messages in thread
From: Ammar Faizi @ 2022-06-29 17:58 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Alviro Iskandar Setiawan, Fernanda Ma'rouf,
	Pavel Begunkov, Hao Xu, io-uring Mailing List,
	GNU/Weeb Mailing List

From: Ammar Faizi <[email protected]>

Signed-off-by: Ammar Faizi <[email protected]>
---
 CHANGELOG | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index efb3ff3..9c054b0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+liburing-2.3 release
+
+- Support non-libc build for aarch64.
+
+
 liburing-2.2 release
 
 - Support non-libc builds.
-- 
Ammar Faizi


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

* Re: [PATCH liburing v2 0/8] aarch64 support
  2022-06-29 17:58 [PATCH liburing v2 0/8] aarch64 support Ammar Faizi
                   ` (7 preceding siblings ...)
  2022-06-29 17:58 ` [PATCH liburing v2 8/8] CHANGELOG: Note about aarch64 support Ammar Faizi
@ 2022-07-04 12:52 ` Ammar Faizi
  2022-07-04 13:05   ` Jens Axboe
  8 siblings, 1 reply; 12+ messages in thread
From: Ammar Faizi @ 2022-07-04 12:52 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Alviro Iskandar Setiawan, Fernanda Ma'rouf, Pavel Begunkov,
	Hao Xu, io-uring Mailing List, GNU/Weeb Mailing List

On 6/30/22 12:58 AM, Ammar Faizi wrote:
> From: Ammar Faizi <[email protected]>
> 
> Hi Jens,
> 
> This is v2 revision of aarch64 support.
> 
> This series contains nolibc support for aarch64 and one extra irrelevant
> cleanup (patch #1). The missing bit from aarch64 is get_page_size()
> which is a bit complicated to implement without libc.
> 
> aarch64 supports three values of page size: 4K, 16K, and 64K which are
> selected at kernel compilation time. Therefore, we can't hard code the
> page size for this arch. In this series we utilize open(), read() and
> close() syscall to find the page size from /proc/self/auxv.
> 
> The auxiliary vector contains information about the page size, it is
> located at `AT_PAGESZ` keyval pair.

This no longer applies, I will send v3 revision soon. If you have some
comments, let me know so I can address it together with the rebase.

-- 
Ammar Faizi

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

* Re: [PATCH liburing v2 0/8] aarch64 support
  2022-07-04 12:52 ` [PATCH liburing v2 0/8] " Ammar Faizi
@ 2022-07-04 13:05   ` Jens Axboe
  2022-07-04 15:36     ` Ammar Faizi
  0 siblings, 1 reply; 12+ messages in thread
From: Jens Axboe @ 2022-07-04 13:05 UTC (permalink / raw)
  To: Ammar Faizi
  Cc: Alviro Iskandar Setiawan, Fernanda Ma'rouf, Pavel Begunkov,
	Hao Xu, io-uring Mailing List, GNU/Weeb Mailing List

On 7/4/22 6:52 AM, Ammar Faizi wrote:
> On 6/30/22 12:58 AM, Ammar Faizi wrote:
>> From: Ammar Faizi <[email protected]>
>>
>> Hi Jens,
>>
>> This is v2 revision of aarch64 support.
>>
>> This series contains nolibc support for aarch64 and one extra irrelevant
>> cleanup (patch #1). The missing bit from aarch64 is get_page_size()
>> which is a bit complicated to implement without libc.
>>
>> aarch64 supports three values of page size: 4K, 16K, and 64K which are
>> selected at kernel compilation time. Therefore, we can't hard code the
>> page size for this arch. In this series we utilize open(), read() and
>> close() syscall to find the page size from /proc/self/auxv.
>>
>> The auxiliary vector contains information about the page size, it is
>> located at `AT_PAGESZ` keyval pair.
> 
> This no longer applies, I will send v3 revision soon. If you have some
> comments, let me know so I can address it together with the rebase.

Just send a v3, didn't have time to go fully over it yet. One note,
though - for patch 5, I'd split get_page_size() into two pieces so you
just do:

static inline long get_page_size(void)
{
	static long cache_val;

	if (cache_val)
		return cache_val;

	return __get_page_size();
}

With that, we can have __get_page_size() just do that one thing, open
the file and read the value.

No need to init static variables to 0.

And finally, if the read/open/whatever fails in __get_page_size(),
assign cache_val to the fallback value as well. I don't see a point in
retrying the same operation later and expect a different result.

-- 
Jens Axboe


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

* Re: [PATCH liburing v2 0/8] aarch64 support
  2022-07-04 13:05   ` Jens Axboe
@ 2022-07-04 15:36     ` Ammar Faizi
  0 siblings, 0 replies; 12+ messages in thread
From: Ammar Faizi @ 2022-07-04 15:36 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Alviro Iskandar Setiawan, Fernanda Ma'rouf, Pavel Begunkov,
	Hao Xu, io-uring Mailing List, GNU/Weeb Mailing List

On 7/4/22 8:05 PM, Jens Axboe wrote:
> On 7/4/22 6:52 AM, Ammar Faizi wrote:
>> This no longer applies, I will send v3 revision soon. If you have some
>> comments, let me know so I can address it together with the rebase.
> 
> Just send a v3, didn't have time to go fully over it yet. One note,
> though - for patch 5, I'd split get_page_size() into two pieces so you
> just do:
> 
> static inline long get_page_size(void)
> {
> 	static long cache_val;
> 
> 	if (cache_val)
> 		return cache_val;
> 
> 	return __get_page_size();
> }
> 
> With that, we can have __get_page_size() just do that one thing, open
> the file and read the value.
> 
> No need to init static variables to 0.
> 
> And finally, if the read/open/whatever fails in __get_page_size(),
> assign cache_val to the fallback value as well. I don't see a point in
> retrying the same operation later and expect a different result.

OK, I got the idea, folded that in.

Also, it seems we don't have any test that hits that get_page_size()
path. Do we?

I am going to create a new test:

    test/nolibc.c

That file will test the nolibc functionality, let's do get_page_size()
for starting. We can compare the result with a libc function like:

   long a = sysconf(_SC_PAGESIZE);
   long b = get_page_size();
   if (a != b) {
         fprintf(stderr, "get_page_size() fails, %ld != %ld", a, b);
         return T_EXIT_FAIL;
   }

-- 
Ammar Faizi

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

end of thread, other threads:[~2022-07-04 15:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-29 17:58 [PATCH liburing v2 0/8] aarch64 support Ammar Faizi
2022-06-29 17:58 ` [PATCH liburing v2 1/8] CHANGELOG: Fixup missing space Ammar Faizi
2022-06-29 17:58 ` [PATCH liburing v2 2/8] arch: syscall: Add `__sys_open()` syscall Ammar Faizi
2022-06-29 17:58 ` [PATCH liburing v2 3/8] arch: syscall: Add `__sys_read()` syscall Ammar Faizi
2022-06-29 17:58 ` [PATCH liburing v2 4/8] arch: Remove `__INTERNAL__LIBURING_LIB_H` checks Ammar Faizi
2022-06-29 17:58 ` [PATCH liburing v2 5/8] arch/aarch64: lib: Add `get_page_size()` function Ammar Faizi
2022-06-29 17:58 ` [PATCH liburing v2 6/8] arch: Enable nolibc support for aarch64 Ammar Faizi
2022-06-29 17:58 ` [PATCH liburing v2 7/8] .github: Enable aarch64 nolibc build for GitHub bot Ammar Faizi
2022-06-29 17:58 ` [PATCH liburing v2 8/8] CHANGELOG: Note about aarch64 support Ammar Faizi
2022-07-04 12:52 ` [PATCH liburing v2 0/8] " Ammar Faizi
2022-07-04 13:05   ` Jens Axboe
2022-07-04 15:36     ` Ammar Faizi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox