From patchwork Fri Oct 1 18:12:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12531483 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 7918EC433EF for ; Fri, 1 Oct 2021 18:13:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2EAD761A03 for ; Fri, 1 Oct 2021 18:13:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2EAD761A03 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 CE2C494012E; Fri, 1 Oct 2021 14:13:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9584940121; Fri, 1 Oct 2021 14:13:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0CFE94012E; Fri, 1 Oct 2021 14:13:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0114.hostedemail.com [216.40.44.114]) by kanga.kvack.org (Postfix) with ESMTP id A148C940121 for ; Fri, 1 Oct 2021 14:13:05 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5C6FE3A7D5 for ; Fri, 1 Oct 2021 18:13:05 +0000 (UTC) X-FDA: 78648665130.07.6F54BFB Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf26.hostedemail.com (Postfix) with ESMTP id 00F6F2001526 for ; Fri, 1 Oct 2021 18:13:04 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id r2so10143550pgl.10 for ; Fri, 01 Oct 2021 11:13:04 -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=jQRHCblSluQbIpKux4YUTKcJ4EpZKx7DnMWO8vXdRIU=; b=JpJB8on8KCekNV6APNk79jaBTmAAXIMYyrv8jaOwxRMB7h8GF+3I5QZp77fkYBTOEk PAnYIrlNbI346YWFB0jHiNGHAHJKLgFu8yo4jPSPorX/FLAoDw5y5akQmblzzjKNMWur 3SJyCsEYzTwY8CbLxqxLXnQg/8tkPZFEfRf8w26esAftDVjw05iN+BxYJVA4KVQxxrPb EM+WLSQmt6KlsyqHytXuXGrwx6OZlJHMuMAKhtt5wE0fQCWi8AAsnGy6IDK7NlIrPRJ4 V/6J+Mn6yJWJGKlI4nlVkLwrO0L+3mvQWFBjcvZuHOPPUXDMv6di6hehpfBuKK9N6Wxg xA0w== 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=jQRHCblSluQbIpKux4YUTKcJ4EpZKx7DnMWO8vXdRIU=; b=Ya8HK2JMPgtNcgTXSJT23S5fU+I3NPjQ8bVT22eUfcJyt96u+YMVowvBV8j/821qR9 Fh/5uEyB2eOlNp/ywY4pulkV5y2+usMs88eO4TPSFKCkYA13H7DVThSFTELC7wfEwqmC Z8mDDdFBGH+sSW0+4TK1vIU/WteU9dCtua676lnZXFdgWeTGdqvx/H+YXhkVEQpd6dL6 To4mLM4GbE8NEDbhBdbOxfO3akOz8JdqhMRwvNcMJi6yoF9z1CJHKeppj2HSeuwEfhjR +j83lExOKNoTDhMaX2gTGsndeppDRxhjzNHAFoRqIMWITzXC9WMIFxRdQ6lSXpLABIAO O4DA== X-Gm-Message-State: AOAM530by3JYBId0P19cwcNo930l42/7btshkffsRHZ6+O+3qSMnKjtq 3PTIgnEqWwtDf6o7tdl9ALQ= X-Google-Smtp-Source: ABdhPJymg4NsZq3tJG+1dEEgxkdiiZIuJNdUsgU+8t+z13Plr/rqUYI0RPW44NUkOqFp3tD8FcNCIA== X-Received: by 2002:aa7:9e1c:0:b0:44b:b97a:12c2 with SMTP id y28-20020aa79e1c000000b0044bb97a12c2mr11558717pfq.71.1633111983954; Fri, 01 Oct 2021 11:13:03 -0700 (PDT) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id d19sm7020209pfn.102.2021.10.01.11.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 11:13:03 -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 06/16] cpumask: use find_first_and_bit() Date: Fri, 1 Oct 2021 11:12:35 -0700 Message-Id: <20211001181245.228419-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001181245.228419-1-yury.norov@gmail.com> References: <20211001181245.228419-1-yury.norov@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 00F6F2001526 X-Stat-Signature: enrpiqwx13gx59khwq4sb5gdtq37ku7o Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JpJB8on8; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=yury.norov@gmail.com X-HE-Tag: 1633111984-860859 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: Now we have an efficient implementation for find_first_and_bit(), so switch cpumask to use it where appropriate. Signed-off-by: Yury Norov Tested-by: Wolfram Sang --- include/linux/cpumask.h | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 1e7399fc69c0..c4e1b9ea0ba4 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -123,6 +123,12 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp) return 0; } +static inline unsigned int cpumask_first_and(const struct cpumask *srcp1, + const struct cpumask *srcp2) +{ + return 0; +} + static inline unsigned int cpumask_last(const struct cpumask *srcp) { return 0; @@ -167,7 +173,7 @@ static inline unsigned int cpumask_local_spread(unsigned int i, int node) static inline int cpumask_any_and_distribute(const struct cpumask *src1p, const struct cpumask *src2p) { - return cpumask_next_and(-1, src1p, src2p); + return cpumask_first_and(src1p, src2p); } static inline int cpumask_any_distribute(const struct cpumask *srcp) @@ -195,6 +201,19 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp) return find_first_bit(cpumask_bits(srcp), nr_cpumask_bits); } +/** + * cpumask_first_and - return the first cpu from *srcp1 & *srcp2 + * @src1p: the first input + * @src2p: the second input + * + * Returns >= nr_cpu_ids if no cpus set in both. See also cpumask_next_and(). + */ +static inline +unsigned int cpumask_first_and(const struct cpumask *srcp1, const struct cpumask *srcp2) +{ + return find_first_and_bit(cpumask_bits(srcp1), cpumask_bits(srcp2), nr_cpumask_bits); +} + /** * cpumask_last - get the last CPU in a cpumask * @srcp: - the cpumask pointer @@ -585,15 +604,6 @@ static inline void cpumask_copy(struct cpumask *dstp, */ #define cpumask_any(srcp) cpumask_first(srcp) -/** - * cpumask_first_and - return the first cpu from *srcp1 & *srcp2 - * @src1p: the first input - * @src2p: the second input - * - * Returns >= nr_cpu_ids if no cpus set in both. See also cpumask_next_and(). - */ -#define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p), (src2p)) - /** * cpumask_any_and - pick a "random" cpu from *mask1 & *mask2 * @mask1: the first input cpumask