From patchwork Thu Oct 20 11:52:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13013335 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 9129DC4332F for ; Thu, 20 Oct 2022 11:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229498AbiJTLxI (ORCPT ); Thu, 20 Oct 2022 07:53:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbiJTLxI (ORCPT ); Thu, 20 Oct 2022 07:53:08 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7913F7B584 for ; Thu, 20 Oct 2022 04:53:07 -0700 (PDT) Received: from localhost.localdomain (unknown [182.253.183.172]) by gnuweeb.org (Postfix) with ESMTPSA id 8307481161; Thu, 20 Oct 2022 11:53:04 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1666266787; bh=PzznPjZ0LbFEEazJSAMQHo+lgL2uwM7RwvTOadd9yB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E0/R14q5VKHUWBK4V247GAzC/KG2wBYuQ+7bUfUPBiHqAdCNizTPlwVUZAlOMflkm Oe3x/DBSHqgwnSDb5nvHl9Qd5JGcgNNpG2SQhRCNBoOs3VyTZMTPfIoltrAq0Gf0Yr C8ap3WaeG9aZ1bBVGHV2B4dp+OdjI8644c1kMkqJi3ZwO4IWnG1Sa7LDCOa6zXvEsP rnPpV/iCLxyzeFAcD9Mk2kySQQ4RwxOPHDv3B2q873tu2q91rRPiOuRq32jNDJp0tk Ikuum2Fn8nfACAa93L8zIl+qkPO/mXtKCNegTee+S9X7vIy3QvVJJRt7eh8w12HHhM n7Z+56p9QNeGQ== From: Ammar Faizi To: Jens Axboe Cc: Dylan Yudaken , Ammar Faizi , Pavel Begunkov , GNU/Weeb Mailing List , io-uring Mailing List , Facebook Kernel Team , Dylan Yudaken Subject: [PATCH liburing v1 1/3] liburing: Clean up `-Wshorten-64-to-32` warnings from clang Date: Thu, 20 Oct 2022 18:52:04 +0700 Message-Id: <20221020114814.63133-2-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020114814.63133-1-ammar.faizi@intel.com> References: <20221020114814.63133-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Dylan Yudaken liburing has a couple of int shortening issues found by clang. Clean them all. This cleanup is particularly useful for build systems that include these files and run with that error enabled. Link: https://lore.kernel.org/io-uring/20221019145042.446477-1-dylany@meta.com Signed-off-by: Dylan Yudaken Co-authored-by: Ammar Faizi Signed-off-by: Ammar Faizi --- src/arch/syscall-defs.h | 4 ++-- src/register.c | 5 ++++- src/setup.c | 12 ++++++------ src/syscall.h | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/arch/syscall-defs.h b/src/arch/syscall-defs.h index 4afb2af..7660574 100644 --- a/src/arch/syscall-defs.h +++ b/src/arch/syscall-defs.h @@ -11,9 +11,9 @@ static inline int __sys_open(const char *pathname, int flags, mode_t mode) * Some architectures don't have __NR_open, but __NR_openat. */ #ifdef __NR_open - return __do_syscall3(__NR_open, pathname, flags, mode); + return (int)__do_syscall3(__NR_open, pathname, flags, mode); #else - return __do_syscall4(__NR_openat, AT_FDCWD, pathname, flags, mode); + return (int)__do_syscall4(__NR_openat, AT_FDCWD, pathname, flags, mode); #endif } diff --git a/src/register.c b/src/register.c index 0a2e5af..912851a 100644 --- a/src/register.c +++ b/src/register.c @@ -277,8 +277,11 @@ int io_uring_enable_rings(struct io_uring *ring) int io_uring_register_iowq_aff(struct io_uring *ring, size_t cpusz, const cpu_set_t *mask) { + if (cpusz >= (1U << 31)) + return -EINVAL; + return __sys_io_uring_register(ring->ring_fd, IORING_REGISTER_IOWQ_AFF, - mask, cpusz); + mask, (int)cpusz); } int io_uring_unregister_iowq_aff(struct io_uring *ring) diff --git a/src/setup.c b/src/setup.c index 21283eb..1885731 100644 --- a/src/setup.c +++ b/src/setup.c @@ -248,29 +248,29 @@ __cold void io_uring_free_probe(struct io_uring_probe *probe) uring_free(probe); } -static inline int __fls(int x) +static inline int __fls(unsigned long x) { if (!x) return 0; - return 8 * sizeof(x) - __builtin_clz(x); + return 8 * sizeof(x) - __builtin_clzl(x); } static unsigned roundup_pow2(unsigned depth) { - return 1UL << __fls(depth - 1); + return 1U << __fls(depth - 1); } -static size_t npages(size_t size, unsigned page_size) +static size_t npages(size_t size, long page_size) { size--; size /= page_size; - return __fls(size); + return __fls((int)size); } #define KRING_SIZE 320 static size_t rings_size(struct io_uring_params *p, unsigned entries, - unsigned cq_entries, unsigned page_size) + unsigned cq_entries, long page_size) { size_t pages, sq_size, cq_size; diff --git a/src/syscall.h b/src/syscall.h index f750782..c61d572 100644 --- a/src/syscall.h +++ b/src/syscall.h @@ -23,9 +23,9 @@ static inline void *ERR_PTR(intptr_t n) return (void *) n; } -static inline intptr_t PTR_ERR(const void *ptr) +static inline int PTR_ERR(const void *ptr) { - return (intptr_t) ptr; + return (int) (intptr_t)ptr; } static inline bool IS_ERR(const void *ptr) From patchwork Thu Oct 20 11:52:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13013336 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 3F2F1C43217 for ; Thu, 20 Oct 2022 11:53:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229452AbiJTLxM (ORCPT ); Thu, 20 Oct 2022 07:53:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbiJTLxL (ORCPT ); Thu, 20 Oct 2022 07:53:11 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B28707B58D for ; Thu, 20 Oct 2022 04:53:10 -0700 (PDT) Received: from localhost.localdomain (unknown [182.253.183.172]) by gnuweeb.org (Postfix) with ESMTPSA id C1BEC8060C; Thu, 20 Oct 2022 11:53:07 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1666266790; bh=AzQErpK2u3zRMFBEAk1HPuph+7o59AjPDxcA9cnyZPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nupol7u9WDUIdSn9d51zOfTrgLegmq4kcq6ZBygsR3ItamzjxSbW2y90BuAz/aBMx Fo9kzA+ayserSXiK17cGcpO/wlRJZ9wI5gjrg36Aq4jbKbodLtHte9/TNjUHDgLy78 sVsisoPj2XDmKrTdqq6JyFUcnUWkc3NpOW+skxAYWxahgG8+dxj8eQ5j4eHcFhVR4P iRKOtE5GKCOU4MSX9VE003GkgXGhZuwBmxq0IdWZ3aLqO+hyW6RS5WEqL+EW5Z6rNM IiADqE/Y+CS6ctw0Z0iyiMZbXcFXiXIkwtG5Ca2Ar/evKVUpT2WmWJu4ZjC7C/Qrik oLNZmgtB3cqzw== From: Ammar Faizi To: Jens Axboe Cc: Dylan Yudaken , Ammar Faizi , Pavel Begunkov , GNU/Weeb Mailing List , io-uring Mailing List , Facebook Kernel Team , Dylan Yudaken Subject: [PATCH liburing v1 2/3] Makefile: Introduce `LIBURING_CFLAGS` variable Date: Thu, 20 Oct 2022 18:52:05 +0700 Message-Id: <20221020114814.63133-3-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020114814.63133-1-ammar.faizi@intel.com> References: <20221020114814.63133-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi `LIBURING_CFLAGS` will be appended to `CFLAGS` but it only applies to files in the `src/` directory (the main library). The first use case of this variable is for appending a clang-specific flag, `-Wshorten-64-to-32` in the GitHub bot. Co-authored-by: Dylan Yudaken Signed-off-by: Dylan Yudaken Signed-off-by: Ammar Faizi --- src/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 73a98ba..09617fb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,11 +5,14 @@ includedir ?= $(prefix)/include libdir ?= $(prefix)/lib libdevdir ?= $(prefix)/lib +LIBURING_CFLAGS ?= CPPFLAGS ?= override CPPFLAGS += -D_GNU_SOURCE \ -Iinclude/ -include ../config-host.h CFLAGS ?= -g -O3 -Wall -Wextra -fno-stack-protector -override CFLAGS += -Wno-unused-parameter -Wno-sign-compare -DLIBURING_INTERNAL +override CFLAGS += -Wno-unused-parameter -Wno-sign-compare \ + -DLIBURING_INTERNAL \ + $(LIBURING_CFLAGS) SO_CFLAGS=-fPIC $(CFLAGS) L_CFLAGS=$(CFLAGS) LINK_FLAGS= From patchwork Thu Oct 20 11:52:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13013337 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 05530C433FE for ; Thu, 20 Oct 2022 11:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229494AbiJTLxP (ORCPT ); Thu, 20 Oct 2022 07:53:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbiJTLxO (ORCPT ); Thu, 20 Oct 2022 07:53:14 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F087F7B593 for ; Thu, 20 Oct 2022 04:53:13 -0700 (PDT) Received: from localhost.localdomain (unknown [182.253.183.172]) by gnuweeb.org (Postfix) with ESMTPSA id 0BCE481101; Thu, 20 Oct 2022 11:53:10 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1666266793; bh=jnZvodqpnnsAyxXZpMTOloEEdBVMnRIQh2CflLouVGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fEMZMIRtLfPC68DGZtt3dU1LJXOp6B2jKa77jFYBa0CBXAXSvRuqmy7BWu04ytmdq MiwHG2Wk9yJoMa1+uB6sgCZKOVVSLwBTIsahAq7gpw6wLD2FcAnc0n7od6XScMEjK7 ENOrF7Zw//x3WUEcFZm9kHI2bG1k4/3YYMfHkR/NZrmT3Xfsey3FLPzmps0rnfQ7wi +FoXBPXJ5gH/ZslJ/FwnvI+Sw1SFBA9jAK/jigTU6Ac0nWjeXJM4qhhKqCJXMbE2mZ UfdGBVeAmDOdkagv5H1E6pIVaDd+/1EzKKJJPv9lKyc4JGadktPYLlhLZ3ZQGvkRqR 3YOK5jonODAgg== From: Ammar Faizi To: Jens Axboe Cc: Dylan Yudaken , Ammar Faizi , Pavel Begunkov , GNU/Weeb Mailing List , io-uring Mailing List , Facebook Kernel Team , Dylan Yudaken Subject: [PATCH liburing v1 3/3] github: Append `-Wshorten-64-to-32` flag for clang build Date: Thu, 20 Oct 2022 18:52:06 +0700 Message-Id: <20221020114814.63133-4-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020114814.63133-1-ammar.faizi@intel.com> References: <20221020114814.63133-1-ammar.faizi@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi liburing has a couple of int shortening issues found by clang. A previous commit has cleaned them up. Integrate -Wshorten-64-to-32 flag to the GitHub bot to spot the same issue in the future. This flag is clang-specific, it currently doesn't exist in GCC. Co-authored-by: Dylan Yudaken Signed-off-by: Dylan Yudaken Signed-off-by: Ammar Faizi --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2608644..b0e669d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,6 +26,7 @@ jobs: cxx_pkg: clang cc: clang cxx: clang++ + extra_flags: -Wshorten-64-to-32 # x86 (32-bit) gcc - arch: i686 @@ -86,6 +87,9 @@ jobs: env: FLAGS: -g -O3 -Wall -Wextra -Werror + # Flags for building sources in src/ dir only. + LIBURING_CFLAGS: ${{matrix.extra_flags}} + steps: - name: Checkout source uses: actions/checkout@v2