From patchwork Fri Oct 1 18:12:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12531467 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03727C433EF for ; Fri, 1 Oct 2021 18:12:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 985F761263 for ; Fri, 1 Oct 2021 18:12:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 985F761263 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3BABC940126; Fri, 1 Oct 2021 14:12:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 36A30940121; Fri, 1 Oct 2021 14:12:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E446940126; Fri, 1 Oct 2021 14:12:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id 10085940121 for ; Fri, 1 Oct 2021 14:12:32 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C60E43C7A0 for ; Fri, 1 Oct 2021 18:12:31 +0000 (UTC) X-FDA: 78648663702.21.3C5A073 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf09.hostedemail.com (Postfix) with ESMTP id 842AC300013F for ; Fri, 1 Oct 2021 18:12:31 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id g14so8687678pfm.1 for ; Fri, 01 Oct 2021 11:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sW0jJ5BzCWKEZDvFC9cMEYLIv2cIm64unRMGWihrNWQ=; b=OvJdBZ+TF4jDhWy9BJ6uKlsG0FLwYuOoH5YLebogbOHxu0ArFHYVlz2NYsHLjGE7xb NoWQqacK8Yo+yedJyLoO1etzorDl6RZeu8n+wFlsnNqSuEPlIRXzICRdL9HJwH43Zw/P Aa/ecDWFDqUDa2loqbwBfyNNf9BTr01Y5FDteezZ1jq/MtTycZQU529DhJ6WiGtCiXcP othIZ84A8xvioPVrNWz2YcP6VMVw7a0v5zwJJ140k1ZSqRNnsxSCFZiNaArQ/apq9tyh oDz0Nz5Lm24BImyFoWs2PWEvJC8LjutHfXJ2kLyaAuQVsGhfsi6oIgfwb9Mpa96a54eV rHkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sW0jJ5BzCWKEZDvFC9cMEYLIv2cIm64unRMGWihrNWQ=; b=u/YhCuTiklYWnmnRsP3KDv4kP8EplW5fRq2mzC9eGgWViHmBut4uKJFrol7H1sZEPN 0/SvTKdd5KoMfJlnFC45d2GB7sHaKOLbfKc85+nrRL51wsVooNrkQAYM3AVsvcD9mijx LBkkl9toyBVDhNYxU6YRxnQzH1YfD6CzWI22K658ASyvodncglXLUhoS1MyAfiObVLyR wCR/y2S+Kx3G+QV9DRG77vXq6kNvRmBzdc/yIjmc94t3Qey9qz9Vq2mLyqOgj77YPGPt RDuvgkiai8mQadHZ9uEPJ/wJsHBsHpgtCpIwRQj3TcDmN+iaS0pFVu3UulxpNjmeJKr5 hrpQ== X-Gm-Message-State: AOAM530OFa5z62/qjH8OZ3AB4cIDDTtzMDrCxeEl4uRzoLkha3j7qPXk QQ+wHyrV03Kcn8YJ6RzJ7Ck= X-Google-Smtp-Source: ABdhPJxqTPwamXGfN+pIwwf94qaNiZ/wFFLL07ruZTsc1SqUjiRJCfdHOmnGO/+uLGkCcSET0GhKkg== X-Received: by 2002:a63:4f54:: with SMTP id p20mr10412536pgl.437.1633111950399; Fri, 01 Oct 2021 11:12:30 -0700 (PDT) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id q10sm3172388pgn.31.2021.10.01.11.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 11:12:30 -0700 (PDT) From: Yury Norov To: Stephen Rothwell Cc: Yury Norov , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mmc@vger.kernel.org, linux-perf-users@vger.kernel.org, kvm@vger.kernel.org, "James E.J. Bottomley" , Alexander Lobakin , Alexander Shishkin , Alexey Klimov , Andrea Merello , Andy Shevchenko , Arnaldo Carvalho de Melo , Arnd Bergmann , Ben Gardon , Benjamin Herrenschmidt , Brian Cain , Catalin Marinas , Christoph Lameter , Daniel Bristot de Oliveira , David Hildenbrand , Dennis Zhou , Geert Uytterhoeven , Heiko Carstens , Ian Rogers , Ingo Molnar , Jaegeuk Kim , Jakub Kicinski , Jiri Olsa , Joe Perches , Jonas Bonn , Leo Yan , Mark Rutland , Namhyung Kim , Palmer Dabbelt , Paolo Bonzini , Peter Xu , Peter Zijlstra , Petr Mladek , Rasmus Villemoes , Rich Felker , Samuel Mendoza-Jonas , Sean Christopherson , Sergey Senozhatsky , Shuah Khan , Stefan Kristiansson , Steven Rostedt , Tejun Heo , Thomas Bogendoerfer , Ulf Hansson , Will Deacon , Wolfram Sang , Yoshinori Sato , kernel test robot Subject: [PATCH 01/16] bitops: protect find_first_{,zero}_bit properly Date: Fri, 1 Oct 2021 11:12:11 -0700 Message-Id: <20211001181226.228340-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001181226.228340-1-yury.norov@gmail.com> References: <20211001181226.228340-1-yury.norov@gmail.com> MIME-Version: 1.0 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OvJdBZ+T; spf=pass (imf09.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=yury.norov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 842AC300013F X-Stat-Signature: xohd5imx58gm7ngiyrf8z6ar88cw5ku7 X-HE-Tag: 1633111951-347754 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: find_first_bit() and find_first_zero_bit() are not protected with ifdefs as other functions in find.h. It causes build errors on some platforms if CONFIG_GENERIC_FIND_FIRST_BIT is enabled. Signed-off-by: Yury Norov Fixes: 2cc7b6a44ac2 ("lib: add fast path for find_first_*_bit() and find_last_bit()") Reported-by: kernel test robot Tested-by: Wolfram Sang --- include/asm-generic/bitops/find.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/asm-generic/bitops/find.h b/include/asm-generic/bitops/find.h index 0d132ee2a291..835f959a25f2 100644 --- a/include/asm-generic/bitops/find.h +++ b/include/asm-generic/bitops/find.h @@ -97,6 +97,7 @@ unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, #ifdef CONFIG_GENERIC_FIND_FIRST_BIT +#ifndef find_first_bit /** * find_first_bit - find the first set bit in a memory region * @addr: The address to start the search at @@ -116,7 +117,9 @@ unsigned long find_first_bit(const unsigned long *addr, unsigned long size) return _find_first_bit(addr, size); } +#endif +#ifndef find_first_zero_bit /** * find_first_zero_bit - find the first cleared bit in a memory region * @addr: The address to start the search at @@ -136,6 +139,8 @@ unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size) return _find_first_zero_bit(addr, size); } +#endif + #else /* CONFIG_GENERIC_FIND_FIRST_BIT */ #ifndef find_first_bit From patchwork Fri Oct 1 18:12:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12531469 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DB4AC433F5 for ; Fri, 1 Oct 2021 18:12:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0927061263 for ; Fri, 1 Oct 2021 18:12:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0927061263 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A22A1940127; Fri, 1 Oct 2021 14:12:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D291940121; Fri, 1 Oct 2021 14:12:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84C50940127; Fri, 1 Oct 2021 14:12:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id 72660940121 for ; Fri, 1 Oct 2021 14:12:35 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 23AA23C7B4 for ; Fri, 1 Oct 2021 18:12:35 +0000 (UTC) X-FDA: 78648663870.09.970B02D Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf23.hostedemail.com (Postfix) with ESMTP id D197A90003A0 for ; Fri, 1 Oct 2021 18:12:34 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id k23-20020a17090a591700b001976d2db364so7764970pji.2 for ; Fri, 01 Oct 2021 11:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WUu1xNUjvy4bTpjMlz8H2ANYID2J8eFWxeuve0Yjkwg=; b=H4PsUYV6RAHW48Rw+UHHaTvyS6zRnXITpO8rNyFD7etwt7OuLkkNovh0uCSvNiSQwk o0Tckxn0YIPr4eQc9N3Ey/DgRMh/us1zRKEPWm/ovaeCUb6GUxXgmG6yOQ/y+1SwFvgz aQ6WWNaqCjKsaLqxkrUXj1v0BB882G2ccIPMMR49e7JH19zSgKrj/jL31W2FPsdJNJdT bQm5YJ7T6aRkl5uTuCEiDHDSiyCWXRE5GCsL03ESsMuMInIMRO1w9mHQt1xZ55aU8mXy k1P2L9XNQfsf/iNSFHD+NvmwiUdeYD5VnRVqZLYghH6FSsjUQEF52gPUbogJZUIxm3z3 YX7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WUu1xNUjvy4bTpjMlz8H2ANYID2J8eFWxeuve0Yjkwg=; b=StyqnvsX49ZeWKK9TdqfoIuueppzayFGcp1XhWgIPNYiEzfM9njRR3TbGRwSARTcMF l4t7CxtNwhufZZPSfNiAPteOwhxNpFxJ1XFfMFRy1WkE6AN6eE9HYBzbSZXWaSO6xs5x t0AVZgyFLIAhXy8PDdAPvfxHbdaHpaYlwxynPx+N3z8whoeRSqbLylzdX+8f2yOSc1nu B/4RddLDzDLnlZ+wG9hFQBamxj+5/VtuVc9DjCwRxZh6phEFw6cnQmZVhqMSQIFI3zTd Ve0FZnocV/w3IQO5Bn3QX4xYoWdulvODvD0NMxNfQphrUnbDGZ0EtjBBLuF7BXskhQ2x iziw== X-Gm-Message-State: AOAM531jKBsbTcyb2DQcr0WLzzG9xivhr57EE06f5C3Kd8/v4y3H9lHX 3HvgpsLpMRw0v2XkbYKBO68= X-Google-Smtp-Source: ABdhPJx68GagNvIFdEzuHAjeFvCpJR+Dpa4SQa4e6cJkqEwHLphXqCkwwSCaR4f+RJe49e4s8XN0yA== X-Received: by 2002:a17:902:6508:b0:13e:77cd:a2fa with SMTP id b8-20020a170902650800b0013e77cda2famr7874926plk.69.1633111953781; Fri, 01 Oct 2021 11:12:33 -0700 (PDT) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id d24sm6730470pfn.62.2021.10.01.11.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 11:12:33 -0700 (PDT) From: Yury Norov To: Stephen Rothwell Cc: Yury Norov , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mmc@vger.kernel.org, linux-perf-users@vger.kernel.org, kvm@vger.kernel.org, "James E.J. Bottomley" , Alexander Lobakin , Alexander Shishkin , Alexey Klimov , Andrea Merello , Andy Shevchenko , Arnaldo Carvalho de Melo , Arnd Bergmann , Ben Gardon , Benjamin Herrenschmidt , Brian Cain , Catalin Marinas , Christoph Lameter , Daniel Bristot de Oliveira , David Hildenbrand , Dennis Zhou , Geert Uytterhoeven , Heiko Carstens , Ian Rogers , Ingo Molnar , Jaegeuk Kim , Jakub Kicinski , Jiri Olsa , Joe Perches , Jonas Bonn , Leo Yan , Mark Rutland , Namhyung Kim , Palmer Dabbelt , Paolo Bonzini , Peter Xu , Peter Zijlstra , Petr Mladek , Rasmus Villemoes , Rich Felker , Samuel Mendoza-Jonas , Sean Christopherson , Sergey Senozhatsky , Shuah Khan , Stefan Kristiansson , Steven Rostedt , Tejun Heo , Thomas Bogendoerfer , Ulf Hansson , Will Deacon , Wolfram Sang , Yoshinori Sato Subject: [PATCH 02/16] bitops: move find_bit_*_le functions from le.h to find.h Date: Fri, 1 Oct 2021 11:12:12 -0700 Message-Id: <20211001181226.228340-3-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001181226.228340-1-yury.norov@gmail.com> References: <20211001181226.228340-1-yury.norov@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: D197A90003A0 X-Stat-Signature: xdu3se17y71mnd69s5hgtdw3kijtfqy1 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=H4PsUYV6; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=yury.norov@gmail.com X-HE-Tag: 1633111954-648664 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: It's convenient to have all find_bit declarations in one place. Signed-off-by: Yury Norov Tested-by: Wolfram Sang --- include/asm-generic/bitops/find.h | 69 +++++++++++++++++++++++++++++++ include/asm-generic/bitops/le.h | 64 ---------------------------- 2 files changed, 69 insertions(+), 64 deletions(-) diff --git a/include/asm-generic/bitops/find.h b/include/asm-generic/bitops/find.h index 835f959a25f2..91b1b23f2b0c 100644 --- a/include/asm-generic/bitops/find.h +++ b/include/asm-generic/bitops/find.h @@ -190,4 +190,73 @@ extern unsigned long find_next_clump8(unsigned long *clump, #define find_first_clump8(clump, bits, size) \ find_next_clump8((clump), (bits), (size), 0) +#if defined(__LITTLE_ENDIAN) + +static inline unsigned long find_next_zero_bit_le(const void *addr, + unsigned long size, unsigned long offset) +{ + return find_next_zero_bit(addr, size, offset); +} + +static inline unsigned long find_next_bit_le(const void *addr, + unsigned long size, unsigned long offset) +{ + return find_next_bit(addr, size, offset); +} + +static inline unsigned long find_first_zero_bit_le(const void *addr, + unsigned long size) +{ + return find_first_zero_bit(addr, size); +} + +#elif defined(__BIG_ENDIAN) + +#ifndef find_next_zero_bit_le +static inline +unsigned long find_next_zero_bit_le(const void *addr, unsigned + long size, unsigned long offset) +{ + if (small_const_nbits(size)) { + unsigned long val = *(const unsigned long *)addr; + + if (unlikely(offset >= size)) + return size; + + val = swab(val) | ~GENMASK(size - 1, offset); + return val == ~0UL ? size : ffz(val); + } + + return _find_next_bit(addr, NULL, size, offset, ~0UL, 1); +} +#endif + +#ifndef find_next_bit_le +static inline +unsigned long find_next_bit_le(const void *addr, unsigned + long size, unsigned long offset) +{ + if (small_const_nbits(size)) { + unsigned long val = *(const unsigned long *)addr; + + if (unlikely(offset >= size)) + return size; + + val = swab(val) & GENMASK(size - 1, offset); + return val ? __ffs(val) : size; + } + + return _find_next_bit(addr, NULL, size, offset, 0UL, 1); +} +#endif + +#ifndef find_first_zero_bit_le +#define find_first_zero_bit_le(addr, size) \ + find_next_zero_bit_le((addr), (size), 0) +#endif + +#else +#error "Please fix " +#endif + #endif /*_ASM_GENERIC_BITOPS_FIND_H_ */ diff --git a/include/asm-generic/bitops/le.h b/include/asm-generic/bitops/le.h index 5a28629cbf4d..d51beff60375 100644 --- a/include/asm-generic/bitops/le.h +++ b/include/asm-generic/bitops/le.h @@ -2,83 +2,19 @@ #ifndef _ASM_GENERIC_BITOPS_LE_H_ #define _ASM_GENERIC_BITOPS_LE_H_ -#include #include #include -#include #if defined(__LITTLE_ENDIAN) #define BITOP_LE_SWIZZLE 0 -static inline unsigned long find_next_zero_bit_le(const void *addr, - unsigned long size, unsigned long offset) -{ - return find_next_zero_bit(addr, size, offset); -} - -static inline unsigned long find_next_bit_le(const void *addr, - unsigned long size, unsigned long offset) -{ - return find_next_bit(addr, size, offset); -} - -static inline unsigned long find_first_zero_bit_le(const void *addr, - unsigned long size) -{ - return find_first_zero_bit(addr, size); -} - #elif defined(__BIG_ENDIAN) #define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) -#ifndef find_next_zero_bit_le -static inline -unsigned long find_next_zero_bit_le(const void *addr, unsigned - long size, unsigned long offset) -{ - if (small_const_nbits(size)) { - unsigned long val = *(const unsigned long *)addr; - - if (unlikely(offset >= size)) - return size; - - val = swab(val) | ~GENMASK(size - 1, offset); - return val == ~0UL ? size : ffz(val); - } - - return _find_next_bit(addr, NULL, size, offset, ~0UL, 1); -} -#endif - -#ifndef find_next_bit_le -static inline -unsigned long find_next_bit_le(const void *addr, unsigned - long size, unsigned long offset) -{ - if (small_const_nbits(size)) { - unsigned long val = *(const unsigned long *)addr; - - if (unlikely(offset >= size)) - return size; - - val = swab(val) & GENMASK(size - 1, offset); - return val ? __ffs(val) : size; - } - - return _find_next_bit(addr, NULL, size, offset, 0UL, 1); -} #endif -#ifndef find_first_zero_bit_le -#define find_first_zero_bit_le(addr, size) \ - find_next_zero_bit_le((addr), (size), 0) -#endif - -#else -#error "Please fix " -#endif static inline int test_bit_le(int nr, const void *addr) {