Tea Inside Mailing List <[email protected]>
 help / color / mirror / Atom feed
* [PATCH liburing v1 0/2] Support busybox mktemp and add x86-64 syscall macros
@ 2022-02-15 15:36 Ammar Faizi
  2022-02-15 15:36 ` [PATCH liburing v1 1/2] configure: Support busybox mktemp Ammar Faizi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ammar Faizi @ 2022-02-15 15:36 UTC (permalink / raw)
  To: Jens Axboe
  Cc: io-uring Mailing List, GNU/Weeb Mailing List,
	Tea Inside Mailing List, Ammar Faizi, Arthur Lapz, Nugra,
	Alviro Iskandar Setiawan, Nugra

Hi Jens,

Two patches in this series.
1) Support busybox mktemp from Nugra.
-------------------------------------
Busybox mktemp does not support `--tmpdir`, it says:
    mktemp: unrecognized option: tmpdir

It can be fixed with:
	1. Create a temporary directory.
	2. Use touch to create the temporary files inside the directory.
	3. Clean up by deleting the temporary directory.

2) Create syscall __do_syscall{0..6} macros from Alviro.
----------------------------------------------------------
Reduce arch dependent code by creating __do_syscall{0..6} macros.
These macros are made of inline Assembly x86-64. Use them to invoke
syscall via __sys* functions. By using this design, we don't have to
code in inline Assembly again when adding a new syscall.

Tested on Linux x86-64, all test passed, but rsrc_tags timedout.

Cc: Arthur Lapz <[email protected]>
Cc: Nugra <[email protected]>
Signed-off-by: Alviro Iskandar Setiawan <[email protected]>
Signed-off-by: Nugra <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---

Alviro Iskandar Setiawan (1):
  arch/x86: Create syscall __do_syscall{0..6} macros

Nugra (1):
  configure: Support busybox mktemp

 configure              |  13 ++-
 src/arch/x86/syscall.h | 242 +++++++++++++++++++++--------------------
 2 files changed, 132 insertions(+), 123 deletions(-)


base-commit: ea1e6f8c4e9180bde1844bd56a072bd4c1afae3e
-- 
2.32.0


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

* [PATCH liburing v1 1/2] configure: Support busybox mktemp
  2022-02-15 15:36 [PATCH liburing v1 0/2] Support busybox mktemp and add x86-64 syscall macros Ammar Faizi
@ 2022-02-15 15:36 ` Ammar Faizi
  2022-02-15 15:36 ` [PATCH liburing v1 2/2] arch/x86: Create syscall __do_syscall{0..6} macros Ammar Faizi
  2022-02-15 21:43 ` [PATCH liburing v1 0/2] Support busybox mktemp and add x86-64 syscall macros Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Ammar Faizi @ 2022-02-15 15:36 UTC (permalink / raw)
  To: Jens Axboe
  Cc: io-uring Mailing List, GNU/Weeb Mailing List,
	Tea Inside Mailing List, Nugra, Ammar Faizi

From: Nugra <[email protected]>

Busybox mktemp does not support `--tmpdir`, it says:
    mktemp: unrecognized option: tmpdir

It can be fixed with:
1. Create a temporary directory.
2. Use touch to create the temporary files inside the directory.
3. Clean up by deleting the temporary directory.

Signed-off-by: Nugra <[email protected]>
Link: https://t.me/GNUWeeb/530154
[ammarfaizi2: Rephrase the commit message and add touch command]
[ammarfaizi2: s/fio/liburing/]
Co-authored-by: Ammar Faizi <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 configure | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 805a671..1f7f1c3 100755
--- a/configure
+++ b/configure
@@ -78,14 +78,17 @@ EOF
 exit 0
 fi
 
-TMPC="$(mktemp --tmpdir fio-conf-XXXXXXXXXX.c)"
-TMPC2="$(mktemp --tmpdir fio-conf-XXXXXXXXXX-2.c)"
-TMPO="$(mktemp --tmpdir fio-conf-XXXXXXXXXX.o)"
-TMPE="$(mktemp --tmpdir fio-conf-XXXXXXXXXX.exe)"
+TMP_DIRECTORY="$(mktemp -d)"
+TMPC="$TMP_DIRECTORY/liburing-conf.c"
+TMPC2="$TMP_DIRECTORY/liburing-conf-2.c"
+TMPO="$TMP_DIRECTORY/liburing-conf.o"
+TMPE="$TMP_DIRECTORY/liburing-conf.exe"
+
+touch $TMPC $TMPC2 $TMPO $TMPE
 
 # NB: do not call "exit" in the trap handler; this is buggy with some shells;
 # see <[email protected]>
-trap "rm -f $TMPC $TMPC2 $TMPO $TMPE" EXIT INT QUIT TERM
+trap "rm -rf $TMP_DIRECTORY" EXIT INT QUIT TERM
 
 rm -rf config.log
 
-- 
2.32.0


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

* [PATCH liburing v1 2/2] arch/x86: Create syscall __do_syscall{0..6} macros
  2022-02-15 15:36 [PATCH liburing v1 0/2] Support busybox mktemp and add x86-64 syscall macros Ammar Faizi
  2022-02-15 15:36 ` [PATCH liburing v1 1/2] configure: Support busybox mktemp Ammar Faizi
@ 2022-02-15 15:36 ` Ammar Faizi
  2022-02-15 21:43 ` [PATCH liburing v1 0/2] Support busybox mktemp and add x86-64 syscall macros Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Ammar Faizi @ 2022-02-15 15:36 UTC (permalink / raw)
  To: Jens Axboe
  Cc: io-uring Mailing List, GNU/Weeb Mailing List,
	Tea Inside Mailing List, Alviro Iskandar Setiawan, Arthur Lapz,
	Nugra, Ammar Faizi

From: Alviro Iskandar Setiawan <[email protected]>

Reduce arch dependent code by creating __do_syscall{0..6} macros.
These macros are made of inline Assembly x86-64. Use them to invoke
syscall via __sys* functions. By using this design, we don't have to
code in inline Assembly again when adding a new syscall.

Tested on Linux x86-64, all test passed, but rsrc_tags timedout.

Tested-by: Arthur Lapz <[email protected]>
Tested-by: Nugra <[email protected]>
Signed-off-by: Alviro Iskandar Setiawan <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 src/arch/x86/syscall.h | 242 +++++++++++++++++++++--------------------
 1 file changed, 124 insertions(+), 118 deletions(-)

diff --git a/src/arch/x86/syscall.h b/src/arch/x86/syscall.h
index 02677f2..c4ae24e 100644
--- a/src/arch/x86/syscall.h
+++ b/src/arch/x86/syscall.h
@@ -29,162 +29,168 @@
  *   %r11 == %rflags and %rcx == %rip.
  */
 
+#define __do_syscall0(NUM) ({			\
+	intptr_t rax;				\
+						\
+	__asm__ volatile(			\
+		"syscall"			\
+		: "=a"(rax)	/* %rax */	\
+		: "a"(NUM)	/* %rax */	\
+		: "rcx", "r11", "memory"	\
+	);					\
+	rax;					\
+})
+
+#define __do_syscall1(NUM, ARG1) ({		\
+	intptr_t rax;				\
+						\
+	__asm__ volatile(			\
+		"syscall"			\
+		: "=a"(rax)	/* %rax */	\
+		: "a"((NUM)),	/* %rax */	\
+		  "D"((ARG1))	/* %rdi */	\
+		: "rcx", "r11", "memory"	\
+	);					\
+	rax;					\
+})
+
+#define __do_syscall2(NUM, ARG1, ARG2) ({	\
+	intptr_t rax;				\
+						\
+	__asm__ volatile(			\
+		"syscall"			\
+		: "=a"(rax)	/* %rax */	\
+		: "a"((NUM)),	/* %rax */	\
+		  "D"((ARG1)),	/* %rdi */	\
+		  "S"((ARG2))	/* %rsi */	\
+		: "rcx", "r11", "memory"	\
+	);					\
+	rax;					\
+})
+
+#define __do_syscall3(NUM, ARG1, ARG2, ARG3) ({	\
+	intptr_t rax;				\
+						\
+	__asm__ volatile(			\
+		"syscall"			\
+		: "=a"(rax)	/* %rax */	\
+		: "a"((NUM)),	/* %rax */	\
+		  "D"((ARG1)),	/* %rdi */	\
+		  "S"((ARG2)),	/* %rsi */	\
+		  "d"((ARG3))	/* %rdx */	\
+		: "rcx", "r11", "memory"	\
+	);					\
+	rax;					\
+})
+
+#define __do_syscall4(NUM, ARG1, ARG2, ARG3, ARG4) ({			\
+	intptr_t rax;							\
+	register __typeof__(ARG4) __r10 __asm__("r10") = (ARG4);	\
+									\
+	__asm__ volatile(						\
+		"syscall"						\
+		: "=a"(rax)	/* %rax */				\
+		: "a"((NUM)),	/* %rax */				\
+		  "D"((ARG1)),	/* %rdi */				\
+		  "S"((ARG2)),	/* %rsi */				\
+		  "d"((ARG3)),	/* %rdx */				\
+		  "r"(__r10)	/* %r10 */				\
+		: "rcx", "r11", "memory"				\
+	);								\
+	rax;								\
+})
+
+#define __do_syscall5(NUM, ARG1, ARG2, ARG3, ARG4, ARG5) ({		\
+	intptr_t rax;							\
+	register __typeof__(ARG4) __r10 __asm__("r10") = (ARG4);	\
+	register __typeof__(ARG5) __r8 __asm__("r8") = (ARG5);		\
+									\
+	__asm__ volatile(						\
+		"syscall"						\
+		: "=a"(rax)	/* %rax */				\
+		: "a"((NUM)),	/* %rax */				\
+		  "D"((ARG1)),	/* %rdi */				\
+		  "S"((ARG2)),	/* %rsi */				\
+		  "d"((ARG3)),	/* %rdx */				\
+		  "r"(__r10),	/* %r10 */				\
+		  "r"(__r8)	/* %r8 */				\
+		: "rcx", "r11", "memory"				\
+	);								\
+	rax;								\
+})
+
+#define __do_syscall6(NUM, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) ({	\
+	intptr_t rax;							\
+	register __typeof__(ARG4) __r10 __asm__("r10") = (ARG4);	\
+	register __typeof__(ARG5) __r8 __asm__("r8") = (ARG5);		\
+	register __typeof__(ARG6) __r9 __asm__("r9") = (ARG6);		\
+									\
+	__asm__ volatile(						\
+		"syscall"						\
+		: "=a"(rax)	/* %rax */				\
+		: "a"((NUM)),	/* %rax */				\
+		  "D"((ARG1)),	/* %rdi */				\
+		  "S"((ARG2)),	/* %rsi */				\
+		  "d"((ARG3)),	/* %rdx */				\
+		  "r"(__r10),	/* %r10 */				\
+		  "r"(__r8),	/* %r8 */				\
+		  "r"(__r9)	/* %r9 */				\
+		: "rcx", "r11", "memory"				\
+	);								\
+	rax;								\
+})
+
 static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
 			       int fd, off_t offset)
 {
-	void *rax;
-	register int r10 __asm__("r10") = flags;
-	register int r8 __asm__("r8") = fd;
-	register off_t r9 __asm__("r9") = offset;
-
-	__asm__ volatile(
-		"syscall"
-		: "=a"(rax)		/* %rax */
-		: "a"(__NR_mmap),	/* %rax */
-		  "D"(addr),		/* %rdi */
-		  "S"(length),		/* %rsi */
-		  "d"(prot),		/* %rdx */
-		  "r"(r10),		/* %r10 */
-		  "r"(r8),		/* %r8  */
-		  "r"(r9)		/* %r9  */
-		: "memory", "rcx", "r11"
-	);
-	return rax;
+	return (void *) __do_syscall6(__NR_mmap, addr, length, prot, flags, fd,
+				      offset);
 }
 
 static inline int __sys_munmap(void *addr, size_t length)
 {
-	long rax;
-
-	__asm__ volatile(
-		"syscall"
-		: "=a"(rax)		/* %rax */
-		: "a"(__NR_munmap),	/* %rax */
-		  "D"(addr),		/* %rdi */
-		  "S"(length)		/* %rsi */
-		: "memory", "rcx", "r11"
-	);
-	return (int) rax;
+	return (int) __do_syscall2(__NR_munmap, addr, length);
 }
 
 static inline int __sys_madvise(void *addr, size_t length, int advice)
 {
-	long rax;
-
-	__asm__ volatile(
-		"syscall"
-		: "=a"(rax)		/* %rax */
-		: "a"(__NR_madvise),	/* %rax */
-		  "D"(addr),		/* %rdi */
-		  "S"(length),		/* %rsi */
-		  "d"(advice)		/* %rdx */
-		: "memory", "rcx", "r11"
-	);
-	return (int) rax;
+	return (int) __do_syscall2(__NR_madvise, addr, length);
 }
 
 static inline int __sys_getrlimit(int resource, struct rlimit *rlim)
 {
-	long rax;
-
-	__asm__ volatile(
-		"syscall"
-		: "=a"(rax)		/* %rax */
-		: "a"(__NR_getrlimit),	/* %rax */
-		  "D"(resource),	/* %rdi */
-		  "S"(rlim)		/* %rsi */
-		: "memory", "rcx", "r11"
-	);
-	return (int) rax;
+	return (int) __do_syscall2(__NR_getrlimit, resource, rlim);
 }
 
 static inline int __sys_setrlimit(int resource, const struct rlimit *rlim)
 {
-	long rax;
-
-	__asm__ volatile(
-		"syscall"
-		: "=a"(rax)		/* %rax */
-		: "a"(__NR_setrlimit),	/* %rax */
-		  "D"(resource),	/* %rdi */
-		  "S"(rlim)		/* %rsi */
-		: "memory", "rcx", "r11"
-	);
-	return (int) rax;
+	return (int) __do_syscall2(__NR_setrlimit, resource, rlim);
 }
 
 static inline int __sys_close(int fd)
 {
-	long rax;
-
-	__asm__ volatile(
-		"syscall"
-		: "=a"(rax)		/* %rax */
-		: "a"(__NR_close),	/* %rax */
-		  "D"(fd)		/* %rdi */
-		: "memory", "rcx", "r11"
-	);
-	return (int) rax;
+	return (int) __do_syscall1(__NR_close, fd);
 }
 
 static inline int ____sys_io_uring_register(int fd, unsigned opcode,
-					    const void *arg,
-					    unsigned nr_args)
+					    const void *arg, unsigned nr_args)
 {
-	long rax;
-	register unsigned r10 __asm__("r10") = nr_args;
-
-	__asm__ volatile(
-		"syscall"
-		: "=a"(rax)			/* %rax */
-		: "a"(__NR_io_uring_register),	/* %rax */
-		  "D"(fd),			/* %rdi */
-		  "S"(opcode),			/* %rsi */
-		  "d"(arg),			/* %rdx */
-		  "r"(r10)			/* %r10 */
-		: "memory", "rcx", "r11"
-	);
-	return (int) rax;
+	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)
 {
-	long rax;
-
-	__asm__ volatile(
-		"syscall"
-		: "=a"(rax)			/* %rax */
-		: "a"(__NR_io_uring_setup),	/* %rax */
-		  "D"(entries),			/* %rdi */
-		  "S"(p)			/* %rsi */
-		: "memory", "rcx", "r11"
-	);
-	return (int) rax;
+	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)
 {
-	long rax;
-	register unsigned r10 __asm__("r10") = flags;
-	register sigset_t *r8 __asm__("r8") = sig;
-	register int r9 __asm__("r9") = sz;
-
-	__asm__ volatile(
-		"syscall"
-		: "=a"(rax)			/* %rax */
-		: "a"(__NR_io_uring_enter),	/* %rax */
-		  "D"(fd),			/* %rdi */
-		  "S"(to_submit),		/* %rsi */
-		  "d"(min_complete),		/* %rdx */
-		  "r"(r10),			/* %r10 */
-		  "r"(r8),			/* %r8  */
-		  "r"(r9)			/* %r9  */
-		: "memory", "rcx", "r11"
-	);
-	return (int) rax;
+	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,
-- 
2.32.0


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

* Re: [PATCH liburing v1 0/2] Support busybox mktemp and add x86-64 syscall macros
  2022-02-15 15:36 [PATCH liburing v1 0/2] Support busybox mktemp and add x86-64 syscall macros Ammar Faizi
  2022-02-15 15:36 ` [PATCH liburing v1 1/2] configure: Support busybox mktemp Ammar Faizi
  2022-02-15 15:36 ` [PATCH liburing v1 2/2] arch/x86: Create syscall __do_syscall{0..6} macros Ammar Faizi
@ 2022-02-15 21:43 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-02-15 21:43 UTC (permalink / raw)
  To: Ammar Faizi
  Cc: GNU/Weeb Mailing List, Nugra, Nugra, io-uring Mailing List,
	Alviro Iskandar Setiawan, Tea Inside Mailing List, Arthur Lapz

On Tue, 15 Feb 2022 22:36:49 +0700, Ammar Faizi wrote:
> Two patches in this series.
> 1) Support busybox mktemp from Nugra.
> -------------------------------------
> Busybox mktemp does not support `--tmpdir`, it says:
>     mktemp: unrecognized option: tmpdir
> 
> It can be fixed with:
> 	1. Create a temporary directory.
> 	2. Use touch to create the temporary files inside the directory.
> 	3. Clean up by deleting the temporary directory.
> 
> [...]

Applied, thanks!

[1/2] configure: Support busybox mktemp
      commit: cce3026ee45a86cfdd104fd1be270b759a161233
[2/2] arch/x86: Create syscall __do_syscall{0..6} macros
      commit: 20bb37e0f828909742f845b8113b2bb7e1065cd1

Best regards,
-- 
Jens Axboe



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

end of thread, other threads:[~2022-02-15 21:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 15:36 [PATCH liburing v1 0/2] Support busybox mktemp and add x86-64 syscall macros Ammar Faizi
2022-02-15 15:36 ` [PATCH liburing v1 1/2] configure: Support busybox mktemp Ammar Faizi
2022-02-15 15:36 ` [PATCH liburing v1 2/2] arch/x86: Create syscall __do_syscall{0..6} macros Ammar Faizi
2022-02-15 21:43 ` [PATCH liburing v1 0/2] Support busybox mktemp and add x86-64 syscall macros Jens Axboe

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