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: 12531447 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 8E249C433F5 for ; Fri, 1 Oct 2021 18:13:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75DA361A7D for ; Fri, 1 Oct 2021 18:13:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355876AbhJASPF (ORCPT ); Fri, 1 Oct 2021 14:15:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355761AbhJASOs (ORCPT ); Fri, 1 Oct 2021 14:14:48 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AA50C0613E4; Fri, 1 Oct 2021 11:13:04 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id h1so4555257pfv.12; 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=2Mwq8NcA2nDVSYVHykPL2nR3k9oSpQQtYb8GG2xXTrF/eBMb7OZXh6tnvRm4A8k8R2 Gy39xSCFGGoIX0nWnWYtPakAHMB3vmYxG3JcNsqyhb3Y5TRRcRSqJxlbZrODGL8Qc3R3 Tah2CAwiYByxNBY6HlJqqDL9Jc7ZYO/A+q3j5mO7NSG9hjoZQQD29STTVG/PPQX0kvAG 1tmkXMXGTJS47Dnb8hwAKfXLcLYqbnuooGQRGHxTIhuqThqVNFfA9qTWWtzR9sFASKe0 jyknQ4ktu6lBT2zIzKHxu4HQtXOlrXSTFU6YO44+9RRUaCRuqWcoydqdRGQoHHdxSO3L Oj0Q== X-Gm-Message-State: AOAM533DpDlhky3ud1jFMlAYBsLtrw68ESXsVbFhxSAg/4hcHMAlkk5m IUocHlhd5WPJcEYMbFXcYNs= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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