From patchwork Wed Jun 29 00:27:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12899120 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 0A4ECC43334 for ; Wed, 29 Jun 2022 00:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229450AbiF2A2S (ORCPT ); Tue, 28 Jun 2022 20:28:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229896AbiF2A2R (ORCPT ); Tue, 28 Jun 2022 20:28:17 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0773D21837 for ; Tue, 28 Jun 2022 17:28:17 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id 9331B7FCFD; Wed, 29 Jun 2022 00:28:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656462496; bh=2+vkFY/cAwJcxO/eliCRmSw5WdJfTavO74HpsygISOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sws9gNH+vemL5kijEiq7Or0vzGghSf1jpu/SdzVP7V8YvO+LbqJPIaPDTcobR3tV2 l20Yx6ndOwe/dmpxUAp6H4wwIa/diGbUV746BSMHkL4JcSivWn76NUvWbOrAx3BzvB HwYWI5FX1bvWFjBDHxqaeSsBn5FPvlilFjGFmareQavToXu7eGxVMeaJ8ivuWsfCdv Rda9rgKTor8Pg3cE1pPte+SJSbEFsrr65eyAVbUrRa9DpdMKt5zWEJRbdurv32jxpZ zNY+C0Ojh0N5VVmyAMI2S4yVhtabz/dwnId8QUzo1/QrNnyTZxD1pCOcCFb1XFAbcn Ujv6fa8NW4tug== 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 v1 1/9] CHANGELOG: Fixup missing space Date: Wed, 29 Jun 2022 07:27:45 +0700 Message-Id: <20220629002028.1232579-2-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629002028.1232579-1-ammar.faizi@intel.com> References: <20220629002028.1232579-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 00:27:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12899121 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 42644C433EF for ; Wed, 29 Jun 2022 00:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229896AbiF2A2V (ORCPT ); Tue, 28 Jun 2022 20:28:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229917AbiF2A2V (ORCPT ); Tue, 28 Jun 2022 20:28:21 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8747921E1E for ; Tue, 28 Jun 2022 17:28:20 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id 383367FC83; Wed, 29 Jun 2022 00:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656462500; bh=9EOHqqHpHFrcRI3qCFB5ehouMVS1GD7Rg5Ue47izIqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cNUES0/9C3ryep2qXQRP1ZZRfjfm6gdBKZDVy+KqY9KmuabqwQ8ACQq38+XCVGE8h tuKgKA/EoZ87LXKdhpuhG85rRUcy1lAJRMmeE3iTZiyHru2BGYTtCGNIwgLEkJie9U dCUdawaQEhWC8Zd/cn2PJQ1YgWexyjZPYXDloqxZISyLQaUz6Kz1vkvQSsdTXTN4Kr 1iLeC3CIxv3GhghvQdGkaiDQeKq8zdU/wECCcRFhLObrKBsiNKK3mrG7bho6wXsEUg Z5b1ChEr2CRkOpLGpgwGuhA5vflln13ALsaJ/neLm/GFzTCNgn+SFz02QITS0+gg4M v76/uvSvv2R7A== 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 v1 2/9] setup: Handle `get_page_size()` failure (for aarch64 nolibc support) Date: Wed, 29 Jun 2022 07:27:46 +0700 Message-Id: <20220629002028.1232579-3-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629002028.1232579-1-ammar.faizi@intel.com> References: <20220629002028.1232579-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi This is a preparation 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. We will utilize open(), read() and close() syscall to find the page size from /proc/self/auxv. Since syscall may fail, we may also fail to get the page size here. Handle the failure. Signed-off-by: Ammar Faizi --- src/setup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/setup.c b/src/setup.c index d2adc7f..ca9d30d 100644 --- a/src/setup.c +++ b/src/setup.c @@ -336,6 +336,9 @@ ssize_t io_uring_mlock_size_params(unsigned entries, struct io_uring_params *p) } page_size = get_page_size(); + if (page_size < 0) + return page_size; + return rings_size(p, entries, cq_entries, page_size); } From patchwork Wed Jun 29 00:27:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12899122 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 DE00EC43334 for ; Wed, 29 Jun 2022 00:28:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229917AbiF2A20 (ORCPT ); Tue, 28 Jun 2022 20:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbiF2A2Z (ORCPT ); Tue, 28 Jun 2022 20:28:25 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6120322B03 for ; Tue, 28 Jun 2022 17:28:24 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id B1CC17FD04; Wed, 29 Jun 2022 00:28:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656462504; bh=EEi2haoxNhLN0yY3nzLrm6Y7Q5tS1uuPWrI/84vA0Qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T7ppUYaKHlQYhSox/HbeP+4+aY4E64HnSfqylFk/XPWYC/7kQocOvQ4k9SCsPuprD CncHkmcpmXF6k0jWxv5re3mlT3mP5fja9BPAI6jkVBfBnzFTOiB0zTdZd3EHwLTqNV 9aiTd2rsIto3DgPazGH11iiE+Vk/YOTsxYW3yQCuV9bbsFGf/QYQVjcB5qvYLv0q54 apbLGHZRZ69rqA0I8nPUOlBra4YTnN4MQ5XsBiNUhTlks2n0pmduOaSly4233n8G20 PFWtYGwAQemDyadrNoIKYZzTiV4MOFpz/NXBRqens3lwSHlBC5Jx8yIe5jn6jfeA0y bP4L9nftSrA1g== 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 v1 3/9] arch: syscall: Add `__sys_open()` syscall Date: Wed, 29 Jun 2022 07:27:47 +0700 Message-Id: <20220629002028.1232579-4-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629002028.1232579-1-ammar.faizi@intel.com> References: <20220629002028.1232579-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 00:27:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12899123 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 F0711C43334 for ; Wed, 29 Jun 2022 00:28:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229933AbiF2A22 (ORCPT ); Tue, 28 Jun 2022 20:28:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbiF2A22 (ORCPT ); Tue, 28 Jun 2022 20:28:28 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE9B1220C5 for ; Tue, 28 Jun 2022 17:28:27 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id 973327FE70; Wed, 29 Jun 2022 00:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656462507; bh=MXth1xu2tuAlKa4FtMyb3VUpFNE681275yqlUL+dsfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b/T1RPwQIoIr5zM0uBWllw2md8R6w6uVLIE8Gs8Ena3w7o5Bv7ZocSyKUfSUVp2L/ Rp+zMVrsymrrZN7qflB2B0ZYTPss0/qEnQLD9tKXcvA5IIanK09BMLBUnXlMHCMxPT LxoiMOBGMoOQxbLywQ4afwBWwWV55/dnejMALM7gZzJra0u7ru0at7FUCloiL4ZrYz KeOgz0L/4PAxoVyN0JhBteDlUksyNeh8jKihiXc2UGsy7n/NAXFIlSiCR8iHZFHHnS 8TKjNOj2mivfHIMrodGQaL922HNecT0sSiq3SR8TyzOnrQ0QLVyxIGBoVBcNN7Y5cM Sv7uZ573qMOrg== 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 v1 4/9] arch: syscall: Add `__sys_read()` syscall Date: Wed, 29 Jun 2022 07:27:48 +0700 Message-Id: <20220629002028.1232579-5-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629002028.1232579-1-ammar.faizi@intel.com> References: <20220629002028.1232579-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 00:27:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12899124 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 2B14EC433EF for ; Wed, 29 Jun 2022 00:28:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbiF2A2d (ORCPT ); Tue, 28 Jun 2022 20:28:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbiF2A2d (ORCPT ); Tue, 28 Jun 2022 20:28:33 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D97728729 for ; Tue, 28 Jun 2022 17:28:32 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id 1EA177FCFC; Wed, 29 Jun 2022 00:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656462511; bh=2o+3Pwm0EoDG+Gn7IfnDamtvJm71dPYhZr1d3qufT5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Klfv/yrMuRedEyq97H5FTYS50WuWsIyIG95FNlA1xZAAFJ3Rn6Tdu4eUjlc9cY30C czv/pisNljtmzK0X9//hFAsGkid/KJQ9M+L7RxHDzAQwU0yVNFmsd1ApSU9Q88i2Ne 1TAImoIZvPsUV8ZGBDowmc4bm8sG4FPXB84rY5tZcp4RvVs/PT+sGFmhNoiEv0cdVr N3TTp87oODXNvrXwviJYTxlsl9a/KcztO83BiuIZ1rU2yz5SRc7knpbGpIW9ESQpIo lwydx6IsCTUteQWaFnOVeFUq6VRlX0El7IAOtcktjKe2nacSmkFVH5nM2VmhybT94l b4bgEjxMheRMg== 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 v1 5/9] arch/arm64: Rename aarch64 directory to arm64 Date: Wed, 29 Jun 2022 07:27:49 +0700 Message-Id: <20220629002028.1232579-6-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629002028.1232579-1-ammar.faizi@intel.com> References: <20220629002028.1232579-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi In the Linux kernel tree, we use `arm64` instead of `aarch64` to name the directory that saves this arch specific code. Follow this naming in liburing too. Signed-off-by: Ammar Faizi --- src/arch/{aarch64 => arm64}/syscall.h | 6 +++--- src/syscall.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/arch/{aarch64 => arm64}/syscall.h (95%) diff --git a/src/arch/aarch64/syscall.h b/src/arch/arm64/syscall.h similarity index 95% rename from src/arch/aarch64/syscall.h rename to src/arch/arm64/syscall.h index 5e26714..732ada0 100644 --- a/src/arch/aarch64/syscall.h +++ b/src/arch/arm64/syscall.h @@ -4,8 +4,8 @@ #error "This file should be included from src/syscall.h (liburing)" #endif -#ifndef LIBURING_ARCH_AARCH64_SYSCALL_H -#define LIBURING_ARCH_AARCH64_SYSCALL_H +#ifndef LIBURING_ARCH_ARM64_SYSCALL_H +#define LIBURING_ARCH_ARM64_SYSCALL_H #if defined(__aarch64__) @@ -96,4 +96,4 @@ #endif /* #if defined(__aarch64__) */ -#endif /* #ifndef LIBURING_ARCH_AARCH64_SYSCALL_H */ +#endif /* #ifndef LIBURING_ARCH_ARM64_SYSCALL_H */ diff --git a/src/syscall.h b/src/syscall.h index 214789d..9e72e6f 100644 --- a/src/syscall.h +++ b/src/syscall.h @@ -74,7 +74,7 @@ static inline bool IS_ERR(const void *ptr) #if defined(__x86_64__) || defined(__i386__) #include "arch/x86/syscall.h" #elif defined(__aarch64__) -#include "arch/aarch64/syscall.h" +#include "arch/arm64/syscall.h" #else /* * We don't have native syscall wrappers From patchwork Wed Jun 29 00:27:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12899125 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 7B033C43334 for ; Wed, 29 Jun 2022 00:28:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229931AbiF2A2h (ORCPT ); Tue, 28 Jun 2022 20:28:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbiF2A2g (ORCPT ); Tue, 28 Jun 2022 20:28:36 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5156275EC for ; Tue, 28 Jun 2022 17:28:35 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id 532BC7FBEF; Wed, 29 Jun 2022 00:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656462515; bh=lFX0gtBvdl/QClxwZ1H0rjuc8UGox5YBfq11uac/YEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HOF3E9eJ5Pgl5F4RBuKE5jCtP0cq3UCwknVZ9EJtpB96y8kYMQXlDHQ5TQu9b41u4 pGKHxSAmEcrzcLOl+5RfoWXoJT4JuESWh/XA8/u5roG9I65vrwehF31rzh64ayBqRM yHghI2/t1Y/C0NZllxDpxwtdfdlyJp8CQpCnLdE2To7PlCm4wP2rxmQMXrij9nFr3/ 2QUHDFSi5Jnoonz6815tGQ4zTDySnlPCEA03+tqaE7WTfPQ7mcFWQ8GLgSCS8w0mJR +uu6+QjBPlih16OxKnd2SvcyztSgpG2LawoTG1uOwiLwQyI8qPPK6B9nmIxZ4oTC5t y3fVOqLbHLSIA== 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 v1 6/9] arch: syscall: Remove `__INTERNAL__LIBURING_SYSCALL_H` checks Date: Wed, 29 Jun 2022 07:27:50 +0700 Message-Id: <20220629002028.1232579-7-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629002028.1232579-1-ammar.faizi@intel.com> References: <20220629002028.1232579-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 refactoring the x86 syscall. For aarch64 we will include this header from lib.h but we are restricted by this check. Just remove it for all archs. User shouldn't touch this code directly anyway. Signed-off-by: Ammar Faizi --- src/arch/arm64/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/syscall.h | 2 -- 6 files changed, 22 deletions(-) diff --git a/src/arch/arm64/syscall.h b/src/arch/arm64/syscall.h index 732ada0..69a36a3 100644 --- a/src/arch/arm64/syscall.h +++ b/src/arch/arm64/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_ARM64_SYSCALL_H #define LIBURING_ARCH_ARM64_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/syscall.h b/src/syscall.h index 9e72e6f..39a18df 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 00:27:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12899126 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 815E8C433EF for ; Wed, 29 Jun 2022 00:28:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbiF2A2l (ORCPT ); Tue, 28 Jun 2022 20:28:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbiF2A2k (ORCPT ); Tue, 28 Jun 2022 20:28:40 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 821B32DD65 for ; Tue, 28 Jun 2022 17:28:39 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id 0E54D7FC83; Wed, 29 Jun 2022 00:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656462519; bh=3t9IpOHWlckPWbRMiMlxoC7Reb/Esot+xgFrYIRtRsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cpj6b30urcMoQ39J8nmVlWFqthHZHi7u6Z3+gzJjDBiLs14HVW1uZNrr4NCp6asL1 JYf0eKp0AZtGdzEJHgfS03ccfH7f2vQabwomTxxLOGF/eyxTyiHDZ2d6VtMzT1nygG knPcWh1iWEL6S3XD4/u26lx2XnoywkADwrXCmvuS52rtfsc40cEqf7G/EarpUj1OAa IRpI26FSL85EqGgL5BJiu0SkJobb/JJa+G98l6Nf+5w9vCAC0EuX213ejXbZifGrY5 hmC5qT2DMR3chS5pvplgGX+WV9JSRAo2MOb67s6KOMXYZ0JOPxcbBwIY6M5jR5bITr nz4H+6LkhPdyQ== 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 v1 7/9] arch/arm64: Add `get_page_size()` function Date: Wed, 29 Jun 2022 07:27:51 +0700 Message-Id: <20220629002028.1232579-8-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629002028.1232579-1-ammar.faizi@intel.com> References: <20220629002028.1232579-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi This is a preparation 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. Link: https://github.com/torvalds/linux/blob/v5.19-rc4/fs/binfmt_elf.c#L260 Signed-off-by: Ammar Faizi --- src/arch/arm64/lib.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/arch/arm64/lib.h diff --git a/src/arch/arm64/lib.h b/src/arch/arm64/lib.h new file mode 100644 index 0000000..4dc39a8 --- /dev/null +++ b/src/arch/arm64/lib.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: MIT */ + +#ifndef LIBURING_ARCH_ARM64_LIB_H +#define LIBURING_ARCH_ARM64_LIB_H + +#include +#include +#include "../../syscall.h" + +static inline long get_page_size(void) +{ + Elf64_Off buf[2]; + long page_size; + int fd; + + fd = __sys_open("/proc/self/auxv", O_RDONLY, 0); + if (fd < 0) + return fd; + + while (1) { + ssize_t ret; + + ret = __sys_read(fd, buf, sizeof(buf)); + if (ret < 0) { + page_size = -errno; + break; + } + + if (ret < sizeof(buf)) { + page_size = -ENOENT; + break; + } + + if (buf[0] == AT_PAGESZ) { + page_size = buf[1]; + break; + } + } + + __sys_close(fd); + return page_size; +} + +#endif /* #ifndef LIBURING_ARCH_ARM64_LIB_H */ From patchwork Wed Jun 29 00:27:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12899127 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 3A894C433EF for ; Wed, 29 Jun 2022 00:28:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229946AbiF2A2o (ORCPT ); Tue, 28 Jun 2022 20:28:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbiF2A2o (ORCPT ); Tue, 28 Jun 2022 20:28:44 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C43F2F643 for ; Tue, 28 Jun 2022 17:28:43 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id C5284800BA; Wed, 29 Jun 2022 00:28:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656462523; bh=xxtuR21w6prt5YvyZJHHtTVW6LyjbO6UFx3Rrcqdgxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=daSUZQxD7OG5ILMdVUJpU/xhHeNyv5dhbxVCRHd8jMFLq3nXvh88mFyjeiFIYRamA /Tg39GyCBzfvHgosJpNlVTDak28tYmbbzQrOcVkRbGAmFXwoe5qOf3mr0sTwPd3wo4 H5sTlHX7CCkItgpDyGecUSS61bykG3ZTkxEvekcLGYN1xZ3wFMtROAV9FOkHUhO+kH Nfpp89ssrVBv3BE/yVpIxIXzfCiFI3YAIvabkKvdDbg4TfMCLJ3gJecXBan3k7ZSXX F59dKffGcTt2Cw7FjG1TjUeIgyxu9o+aW8w+IFpRK0sqb0WLyNaMGuK0tf6ZaHWH4s 00YvNDNtk/Ibw== 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 v1 8/9] arch: Enable nolibc support for arm64 Date: Wed, 29 Jun 2022 07:27:52 +0700 Message-Id: <20220629002028.1232579-9-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629002028.1232579-1-ammar.faizi@intel.com> References: <20220629002028.1232579-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 arm64. Signed-off-by: Ammar Faizi --- src/lib.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/lib.h b/src/lib.h index 6672cc5..e1419f8 100644 --- a/src/lib.h +++ b/src/lib.h @@ -8,16 +8,19 @@ #define __INTERNAL__LIBURING_LIB_H #if defined(__x86_64__) || defined(__i386__) - #include "arch/x86/lib.h" +#include "arch/x86/lib.h" +#elif defined(__aarch64__) +#include "arch/arm64/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 #undef __INTERNAL__LIBURING_LIB_H From patchwork Wed Jun 29 00:27:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 12899128 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 81A6CC43334 for ; Wed, 29 Jun 2022 00:28:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229960AbiF2A2s (ORCPT ); Tue, 28 Jun 2022 20:28:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbiF2A2r (ORCPT ); Tue, 28 Jun 2022 20:28:47 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3451B2F65B for ; Tue, 28 Jun 2022 17:28:47 -0700 (PDT) Received: from integral2.. (unknown [180.245.197.13]) by gnuweeb.org (Postfix) with ESMTPSA id 73BFA7FE70; Wed, 29 Jun 2022 00:28:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656462526; bh=xth/MUDvJ+GnBq5UPBliavkj3h6/xeBFoQ2W83La9IM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=talaTWBQsBjS2bmzzwMD26E/3/h3LBvnnwiUbutRXq4tM+qWSfLhvlAF0h2T/tHzE F8YWujo+6JSjx7E2GozcMZj5/OXOezKP12md0rFv4ZVJezuEufia/Nb5CVve5EmEVB ODV62PjSovyzZrg6bZ/ZeqR6NK/ZX19bH3/3y0XD8kpF1tYibz3ZA5S99w4W8ALlet 9S++uNm+UA+h3FLYJ19WNbLVHJ1TivzTgLBFfTT48eKkp6xdjH8t28rd91eh+UOZJS BX1Sgj3b2E5WvV+8sjC1SI01B8VxjdcBQu5q4hTQClmYGzCALz4EZDcM5s4d117LtI ZxKycQTzh+t1w== 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 v1 9/9] .github: Enable aarch64 nolibc build for GitHub bot Date: Wed, 29 Jun 2022 07:27:53 +0700 Message-Id: <20220629002028.1232579-10-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220629002028.1232579-1-ammar.faizi@intel.com> References: <20220629002028.1232579-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"; \