From patchwork Wed Jun 29 17:58:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12900504 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8556EC43334 for ; Wed, 29 Jun 2022 17:59:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231784AbiF2R7e (ORCPT ); Wed, 29 Jun 2022 13:59:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232101AbiF2R7b (ORCPT ); Wed, 29 Jun 2022 13:59:31 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD747E9 for ; Wed, 29 Jun 2022 10:59:30 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id 70798800EF; Wed, 29 Jun 2022 17:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656525570; bh=2+vkFY/cAwJcxO/eliCRmSw5WdJfTavO74HpsygISOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gyffyitts7KDaPZcmbnajw+MUVVkKfOfpEFZs49559NSjawby9uUASTG7vCMKzvIs dzFimMu/iMMA4JDVvsFok00Ra2uVh/ZLC7HkhcO8w3VrXH7ofMq4e87ejdgysbP9yE II55UrruAOPmGv7rlQbY8rMIh2HrnKPizaobobynPbe5A46opMR4ILyJctNqRYcitN 8Tz9yLju2xJGNwO/88bRWnjyX7aami6GQmLwrfLzQjdYRNfAGNkZjhX+8tS9ix+Nsw IxTv9/Di5w0mL4PB1Vf1ryGYJ2ZLex5VJ+SA0cX0FVBZZdjKWAtHejXuZ5Wk17l4U9 VuTy4RjfpWpOA== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Alviro Iskandar Setiawan , Fernanda Ma'rouf , Pavel Begunkov , Hao Xu , io-uring Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v2 1/8] CHANGELOG: Fixup missing space Date: Thu, 30 Jun 2022 00:58:23 +0700 Message-Id: <20220629175255.1377052-2-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629175255.1377052-1-ammar.faizi@intel.com> References: <20220629175255.1377052-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi s/reducingthe/reducing the/ Signed-off-by: Ammar Faizi --- 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 From patchwork Wed Jun 29 17:58:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12900505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E476C433EF for ; Wed, 29 Jun 2022 17:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232124AbiF2R7f (ORCPT ); Wed, 29 Jun 2022 13:59:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232118AbiF2R7f (ORCPT ); Wed, 29 Jun 2022 13:59:35 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70CB6E9 for ; Wed, 29 Jun 2022 10:59:34 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id 09FFE800D8; Wed, 29 Jun 2022 17:59:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656525574; bh=EEi2haoxNhLN0yY3nzLrm6Y7Q5tS1uuPWrI/84vA0Qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OFFgTr28ywdISED1DVZ0p4uAm7Rs30woNXTkQkjx1teiL3y+NkMx1YXM1EWJ+Z8nE NdXQ3INXRYRwGxcmZKX+s+7RY+Ggf2M2yPrV8+bJxyXNh6rqern4I+erFm4ll7joVn i2qtHkjq8nD+W65RjOp6l5v42K6wXxzzxtb70sXOH5ObUmDJmb1ZRQBX5Pim7X4ehU Scs5eIjv3Lut1Hh7oMb/TznjwsOYJNa2HGP5X7TDo327xxzUgsp2H9LeVX72H+KkNS clmlMzoa7+BboVImz4hh3DM8SJTJrbFBjRLLOTwesGkLp9sITzlmtPnnES1ZPIbgjB SxkhBizN+GpPQ== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Alviro Iskandar Setiawan , Fernanda Ma'rouf , Pavel Begunkov , Hao Xu , io-uring Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v2 2/8] arch: syscall: Add `__sys_open()` syscall Date: Thu, 30 Jun 2022 00:58:24 +0700 Message-Id: <20220629175255.1377052-3-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629175255.1377052-1-ammar.faizi@intel.com> References: <20220629175255.1377052-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi 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 --- 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 + 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 + +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) { From patchwork Wed Jun 29 17:58:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12900506 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F81DC43334 for ; Wed, 29 Jun 2022 17:59:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232164AbiF2R7j (ORCPT ); Wed, 29 Jun 2022 13:59:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231772AbiF2R7i (ORCPT ); Wed, 29 Jun 2022 13:59:38 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E58BE9 for ; Wed, 29 Jun 2022 10:59:38 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id A86B2800E7; Wed, 29 Jun 2022 17:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656525578; bh=MXth1xu2tuAlKa4FtMyb3VUpFNE681275yqlUL+dsfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ss/I1D6dUpmCCZ+P2JZmHpZgrwGnL0xPl6qpud4kr8VdcMZyqGzvyA+RVg/vXdfxs nFgX+0V9rXqtBf3w1ySO+Bpd73g+WZzWDYEuJG+myYilriS22L5lrRahnA1sEpZD9z TM73YD5Ipx180FNxmUhgZgZX1Li5jtCgYEeE2Fy/lg+BU7tBhBkSlKYc0QFuJwFRa5 T3+UYHTLGti1EEVRXZjeOos2qZ4iBKnsyCc0itXUTv5lqx6xRmDSjEHsItjQ3+oKg4 VHcFj1Oqh1c3d342stffEi+8WSV39wQbqQ9chDW7Jkb0XOEQH26qVoLDJ8X5+zvv3A A38elfNBlw5dQ== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Alviro Iskandar Setiawan , Fernanda Ma'rouf , Pavel Begunkov , Hao Xu , io-uring Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v2 3/8] arch: syscall: Add `__sys_read()` syscall Date: Thu, 30 Jun 2022 00:58:25 +0700 Message-Id: <20220629175255.1377052-4-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629175255.1377052-1-ammar.faizi@intel.com> References: <20220629175255.1377052-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi 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 --- 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) { From patchwork Wed Jun 29 17:58:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12900507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A88EC433EF for ; Wed, 29 Jun 2022 17:59:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232181AbiF2R7p (ORCPT ); Wed, 29 Jun 2022 13:59:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231347AbiF2R7o (ORCPT ); Wed, 29 Jun 2022 13:59:44 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E4F5E9 for ; Wed, 29 Jun 2022 10:59:43 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id A9EDF800C2; Wed, 29 Jun 2022 17:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656525582; bh=tXlRsNACrIIuE5j8bau8IWlvgcABX3OwzjyOsmPpR8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WDvje2StSbllRIjCDNlUJYAVkWiJLy2Hn8Ztk/Kuhgr4EjkWPRUUOHLIqAUDpnVmL kVS3AnG42tmVCJNqF+nsLO+pgOHD7cPM1R1vnpkSS/QwCv3XdeGwGHhL9jriKq3oqX Ph9x5AgRI207RNDO2PsLHl/hCkG6kJjOqMYhcre8pMgza+gRDmfDB8E1VgYSijhMrf 1uZ7iXqNbZQpxii2QGXPbbcqM4CqntYGITQLgh1GCsOD8rV5l3p54uv16+xubaZ2ay PotIQasXnIcRodopue7mOnHqXTi1YcFSX2IxGgG5S80GBTCxzxDa7llunhXtkTNZPA v+sK/EHcsE/Hg== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Alviro Iskandar Setiawan , Fernanda Ma'rouf , Pavel Begunkov , Hao Xu , io-uring Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v2 4/8] arch: Remove `__INTERNAL__LIBURING_LIB_H` checks Date: Thu, 30 Jun 2022 00:58:26 +0700 Message-Id: <20220629175255.1377052-5-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629175255.1377052-1-ammar.faizi@intel.com> References: <20220629175255.1377052-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi 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 --- 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 #include -#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. From patchwork Wed Jun 29 17:58:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12900508 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4D09CCA482 for ; Wed, 29 Jun 2022 17:59:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232138AbiF2R7u (ORCPT ); Wed, 29 Jun 2022 13:59:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232191AbiF2R7r (ORCPT ); Wed, 29 Jun 2022 13:59:47 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE18CD93 for ; Wed, 29 Jun 2022 10:59:46 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id 4D2517FC07; Wed, 29 Jun 2022 17:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656525586; bh=8rvYQ2Hh72AHYXlNPnhKEoTXHZExITmndsEjdUWGuMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d+LH6j+K5Jv3tIt5NLDp6deGJNTmtbs6kFZubD8Bk25yTF3/7EUh8JPC7/4Tja78g t5jaUsAprYzPdbpgidJTLPA3uYmO3HS4cYePkrgvWp6O5stcH11KhRiN0blIS398I2 iKuh6IJu9tOJNxA+73zhhQVY92vZo6lvisYTt3YmGZjUeksO4u6d0jHbk9OlU2cHa6 rDlKTDmSxl19yzKX6Ugv6dMxfAeA5K0r0X/u/+vCNruHhbyQeIvj1WqF0jE2FHBjfw LpmKEkQLaaNRmUmczJ9m9gaYi3sgfkzB2NnkJWAbg2uBG/ZWy+h9lRX/L5lguwHRAV BC3KJiko97OBw== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Alviro Iskandar Setiawan , Fernanda Ma'rouf , Pavel Begunkov , Hao Xu , io-uring Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v2 5/8] arch/aarch64: lib: Add `get_page_size()` function Date: Thu, 30 Jun 2022 00:58:27 +0700 Message-Id: <20220629175255.1377052-6-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629175255.1377052-1-ammar.faizi@intel.com> References: <20220629175255.1377052-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi 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/3895dbe1-8d5f-cf53-e94b-5d1545466de1@kernel.dk Link: https://lore.kernel.org/io-uring/8bfba71c-55d7-fb49-6593-4d0f9d9c3611@kernel.dk Suggested-by: Jens Axboe Signed-off-by: Ammar Faizi --- 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 +#include +#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 */ From patchwork Wed Jun 29 17:58:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12900509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89022C433EF for ; Wed, 29 Jun 2022 17:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232196AbiF2R7w (ORCPT ); Wed, 29 Jun 2022 13:59:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232191AbiF2R7v (ORCPT ); Wed, 29 Jun 2022 13:59:51 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD3F0C7F for ; Wed, 29 Jun 2022 10:59:50 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id E3015800EF; Wed, 29 Jun 2022 17:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656525590; bh=sgazs96gJXhuLUrcrg8QV44lnrofUqELK9IkwXdhdvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RDlS1y9uUown8thKLJr6nydxaHlAB/ZU4qJSQAPk9zwsRhsEfhct6zic4HHMsn1K5 pMcvUciDwREwTB5yu7TJp2JypmQxMF+BdCy28GxAfYDBhQuJOg4iHPwzedX+b2z98A iANx7McYCTkFY0HjCAiMVMCZb517LRW1WfLMqTrlIylO71J1clJ8ceXOiQ58XsLmDL MtxrZXAPIiEOwqTqdVwYFwt+7mME9dv08pU/sEvmf6f/HXqnHTn7h+xKB5FaBFxOUj tZIe2vB0uMmbg/7Urg57owi/LAL3wgByjPDTwFo5izJ8xDizLixP9nEXVRLvciKzC/ h3P7ioI50WDVA== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Alviro Iskandar Setiawan , Fernanda Ma'rouf , Pavel Begunkov , Hao Xu , io-uring Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v2 6/8] arch: Enable nolibc support for aarch64 Date: Thu, 30 Jun 2022 00:58:28 +0700 Message-Id: <20220629175255.1377052-7-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629175255.1377052-1-ammar.faizi@intel.com> References: <20220629175255.1377052-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi Support nolibc build for aarch64. While in there, don't indent the block inside #if / #elif / #else / #endif. Signed-off-by: Ammar Faizi --- 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 #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); From patchwork Wed Jun 29 17:58:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12900510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3433AC43334 for ; Wed, 29 Jun 2022 17:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232198AbiF2R75 (ORCPT ); Wed, 29 Jun 2022 13:59:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232191AbiF2R7z (ORCPT ); Wed, 29 Jun 2022 13:59:55 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1491DB1 for ; Wed, 29 Jun 2022 10:59:54 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id EEC10800D8; Wed, 29 Jun 2022 17:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656525594; bh=xth/MUDvJ+GnBq5UPBliavkj3h6/xeBFoQ2W83La9IM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BrEnnUBkliDqpBCa575pGGqjSMlmqLqSquZCHz/G6MHfOkLBJGtPTPCSBhcMNPiaW Ca9WLX0axiR6JxpsHKo7PFGTE2hWIdVJSXW9LqspqsJsq1mmsScCSzb/6Rwtp2wMeU 8UrBu9UH/yO6hgmGCS+2SLXmv9Rq1E0sd2ALtI6tAyIM+6M51jFOOOzVl99qZiVhzf tXSxSVejWq0EKVaaCCOjh1OSQCooPSfvfNyshrvPx2y/RZ3OpAjkmI6NaLj8CRRk4D 6W3rCgpp9Tb0SG7asDVt0UwsmuUej+YJsjZ5SpnAEj+dtc9fl+voND0jpZSjEZXBOG WMo86gINYTvkQ== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Alviro Iskandar Setiawan , Fernanda Ma'rouf , Pavel Begunkov , Hao Xu , io-uring Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v2 7/8] .github: Enable aarch64 nolibc build for GitHub bot Date: Thu, 30 Jun 2022 00:58:29 +0700 Message-Id: <20220629175255.1377052-8-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629175255.1377052-1-ammar.faizi@intel.com> References: <20220629175255.1377052-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi Signed-off-by: Ammar Faizi --- .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"; \ From patchwork Wed Jun 29 17:58:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12900511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 506B7C43334 for ; Wed, 29 Jun 2022 18:00:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232203AbiF2SAA (ORCPT ); Wed, 29 Jun 2022 14:00:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232227AbiF2R77 (ORCPT ); Wed, 29 Jun 2022 13:59:59 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 462BEC7F for ; Wed, 29 Jun 2022 10:59:59 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id 086A2800E7; Wed, 29 Jun 2022 17:59:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656525598; bh=zQ5DQmoxSwZ6Mva+LUDQuM5nON1RwWAYQmZoxevo84c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WlXuj/jJ27sGGLPY0zTkNnVRCIBSjyG4A6wWz+El8cCt4mKG8Sz/L8IS/LeI+xea3 OPU7JgoTExP3T/IWA/2QJhDtLFIHGxwBnW7yCaL4lsVZglXq6a/GLqNDW94xtK1HRC FATv8UIw4+G37iX+MeuZLncJgNnwwF1xGo+t55taWn21KdPiyhTdCvDK3k6xFYZDP+ 3sRRjiVnzhHWhVv/LDZbh9g9xcTcVXhPHjI06kzADFzCC48tjwYweDv1G65seGnEJu F2QZvBNhkR+xUgoOyNefbMDUoYj0ofEbQJZMP+ghgqhI1uzY9kkCczbnFnDYrIiDri RW/bVsJvYs8MQ== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Alviro Iskandar Setiawan , Fernanda Ma'rouf , Pavel Begunkov , Hao Xu , io-uring Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v2 8/8] CHANGELOG: Note about aarch64 support Date: Thu, 30 Jun 2022 00:58:30 +0700 Message-Id: <20220629175255.1377052-9-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629175255.1377052-1-ammar.faizi@intel.com> References: <20220629175255.1377052-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi Signed-off-by: Ammar Faizi --- 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.