From bfed648c9dae6a2459cb43f55c14d8303dcec07b Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 6 Feb 2020 07:59:00 -0700 Subject: [PATCH] Unify architecture io_uring syscall numbers Only Alpha is the odd one out, apart from that all architectures use the same system call number. So pull the code out arch headers, and into the generic arch header. Fixes: https://github.com/axboe/fio/issues/923 Signed-off-by: Jens Axboe --- arch/arch-aarch64.h | 12 ------------ arch/arch-ppc.h | 12 ------------ arch/arch-x86-common.h | 11 ----------- arch/arch.h | 28 ++++++++++++++++++++++++++++ engines/io_uring.c | 8 ++++---- t/io_uring.c | 10 +++++----- 6 files changed, 37 insertions(+), 44 deletions(-) diff --git a/arch/arch-aarch64.h b/arch/arch-aarch64.h index de9b349b..2a86cc5a 100644 --- a/arch/arch-aarch64.h +++ b/arch/arch-aarch64.h @@ -8,18 +8,6 @@ #define FIO_ARCH (arch_aarch64) -#define ARCH_HAVE_IOURING - -#ifndef __NR_sys_io_uring_setup -#define __NR_sys_io_uring_setup 425 -#endif -#ifndef __NR_sys_io_uring_enter -#define __NR_sys_io_uring_enter 426 -#endif -#ifndef __NR_sys_io_uring_register -#define __NR_sys_io_uring_register 427 -#endif - #define nop do { __asm__ __volatile__ ("yield"); } while (0) #define read_barrier() do { __sync_synchronize(); } while (0) #define write_barrier() do { __sync_synchronize(); } while (0) diff --git a/arch/arch-ppc.h b/arch/arch-ppc.h index 46246bae..804d596a 100644 --- a/arch/arch-ppc.h +++ b/arch/arch-ppc.h @@ -24,18 +24,6 @@ #define PPC_CNTLZL "cntlzw" #endif -#define ARCH_HAVE_IOURING - -#ifndef __NR_sys_io_uring_setup -#define __NR_sys_io_uring_setup 425 -#endif -#ifndef __NR_sys_io_uring_enter -#define __NR_sys_io_uring_enter 426 -#endif -#ifndef __NR_sys_io_uring_register -#define __NR_sys_io_uring_register 427 -#endif - static inline int __ilog2(unsigned long bitmask) { int lz; diff --git a/arch/arch-x86-common.h b/arch/arch-x86-common.h index 87925bdc..f32835cc 100644 --- a/arch/arch-x86-common.h +++ b/arch/arch-x86-common.h @@ -3,16 +3,6 @@ #include -#ifndef __NR_sys_io_uring_setup -#define __NR_sys_io_uring_setup 425 -#endif -#ifndef __NR_sys_io_uring_enter -#define __NR_sys_io_uring_enter 426 -#endif -#ifndef __NR_sys_io_uring_register -#define __NR_sys_io_uring_register 427 -#endif - static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) @@ -23,7 +13,6 @@ static inline void cpuid(unsigned int op, } #define ARCH_HAVE_INIT -#define ARCH_HAVE_IOURING extern bool tsc_reliable; extern int arch_random; diff --git a/arch/arch.h b/arch/arch.h index 0ec3f10f..30c0d205 100644 --- a/arch/arch.h +++ b/arch/arch.h @@ -76,4 +76,32 @@ static inline int arch_init(char *envp[]) } #endif +#ifdef __alpha__ +/* + * alpha is the only exception, all other architectures + * have common numbers for new system calls. + */ +# ifndef __NR_io_uring_setup +# define __NR_io_uring_setup 535 +# endif +# ifndef __NR_io_uring_enter +# define __NR_io_uring_enter 536 +# endif +# ifndef __NR_io_uring_register +# define __NR_io_uring_register 537 +# endif +#else /* !__alpha__ */ +# ifndef __NR_io_uring_setup +# define __NR_io_uring_setup 425 +# endif +# ifndef __NR_io_uring_enter +# define __NR_io_uring_enter 426 +# endif +# ifndef __NR_io_uring_register +# define __NR_io_uring_register 427 +# endif +#endif + +#define ARCH_HAVE_IOURING + #endif diff --git a/engines/io_uring.c b/engines/io_uring.c index f1ffc712..5e59f975 100644 --- a/engines/io_uring.c +++ b/engines/io_uring.c @@ -191,7 +191,7 @@ static struct fio_option options[] = { static int io_uring_enter(struct ioring_data *ld, unsigned int to_submit, unsigned int min_complete, unsigned int flags) { - return syscall(__NR_sys_io_uring_enter, ld->ring_fd, to_submit, + return syscall(__NR_io_uring_enter, ld->ring_fd, to_submit, min_complete, flags, NULL, 0); } @@ -548,7 +548,7 @@ static int fio_ioring_queue_init(struct thread_data *td) } } - ret = syscall(__NR_sys_io_uring_setup, depth, &p); + ret = syscall(__NR_io_uring_setup, depth, &p); if (ret < 0) return ret; @@ -563,7 +563,7 @@ static int fio_ioring_queue_init(struct thread_data *td) if (setrlimit(RLIMIT_MEMLOCK, &rlim) < 0) return -1; - ret = syscall(__NR_sys_io_uring_register, ld->ring_fd, + ret = syscall(__NR_io_uring_register, ld->ring_fd, IORING_REGISTER_BUFFERS, ld->iovecs, depth); if (ret < 0) return ret; @@ -589,7 +589,7 @@ static int fio_ioring_register_files(struct thread_data *td) f->engine_pos = i; } - ret = syscall(__NR_sys_io_uring_register, ld->ring_fd, + ret = syscall(__NR_io_uring_register, ld->ring_fd, IORING_REGISTER_FILES, ld->fds, td->o.nr_files); if (ret) { err: diff --git a/t/io_uring.c b/t/io_uring.c index c2e5e098..55b75f6e 100644 --- a/t/io_uring.c +++ b/t/io_uring.c @@ -100,7 +100,7 @@ static int io_uring_register_buffers(struct submitter *s) if (do_nop) return 0; - return syscall(__NR_sys_io_uring_register, s->ring_fd, + return syscall(__NR_io_uring_register, s->ring_fd, IORING_REGISTER_BUFFERS, s->iovecs, depth); } @@ -117,20 +117,20 @@ static int io_uring_register_files(struct submitter *s) s->files[i].fixed_fd = i; } - return syscall(__NR_sys_io_uring_register, s->ring_fd, + return syscall(__NR_io_uring_register, s->ring_fd, IORING_REGISTER_FILES, s->fds, s->nr_files); } static int io_uring_setup(unsigned entries, struct io_uring_params *p) { - return syscall(__NR_sys_io_uring_setup, entries, p); + return syscall(__NR_io_uring_setup, entries, p); } static int io_uring_enter(struct submitter *s, unsigned int to_submit, unsigned int min_complete, unsigned int flags) { - return syscall(__NR_sys_io_uring_enter, s->ring_fd, to_submit, - min_complete, flags, NULL, 0); + return syscall(__NR_io_uring_enter, s->ring_fd, to_submit, min_complete, + flags, NULL, 0); } #ifndef CONFIG_HAVE_GETTID -- 2.25.1