From patchwork Tue Oct 5 05:40:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12535545 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 2EB45C4332F for ; Tue, 5 Oct 2021 05:41:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D89B961504 for ; Tue, 5 Oct 2021 05:41:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D89B961504 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 7AE446B0078; Tue, 5 Oct 2021 01:41:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 736186B007B; Tue, 5 Oct 2021 01:41:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53A486B007D; Tue, 5 Oct 2021 01:41:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 44CC46B0078 for ; Tue, 5 Oct 2021 01:41:17 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 006C21814905E for ; Tue, 5 Oct 2021 05:41:16 +0000 (UTC) X-FDA: 78661285794.17.01827A3 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf24.hostedemail.com (Postfix) with ESMTP id C2067B000BC5 for ; Tue, 5 Oct 2021 05:41:16 +0000 (UTC) Received: by mail-pl1-f182.google.com with SMTP id x4so1520964pln.5 for ; Mon, 04 Oct 2021 22:41:16 -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=pDr/2wmKOhtISD4bTLAYys4abxrcPBrhwIDJ4wnRZw0=; b=WITMNTfkqR7TVUYnguYCLl7md8pYe01Wx+ljByw14DxDIsV9LRFj6o44yqqDfsHFoH M5nTtm7+OJPsrfx/6Pmf83O/AbLBLQ9XdoqYvBJpjBrN26NKKBgJitJGqfe81CJsW5JS voOL+Q4Sr3cIdzvwSmwUDpShwpll4642aC+Wkx3hPlGk5wFqpsfw76JUdazqwo/wExn9 ex+6AIVSVksgqRSjnpBOvZ8fCzRt580yJ0fs+cFnIrq3eAbKJnBpCF3rfq+hI287+FlO KPpQeyey4ivPfe3sCnWEOJRlQPSZXcC/nfZ+F//UwA7ReYxAfn+3D3QTkx03Tgyw8Vyh 2dAg== 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=pDr/2wmKOhtISD4bTLAYys4abxrcPBrhwIDJ4wnRZw0=; b=yCfxF6eWoDYVV1UvaFa++7pE9S+0en+65Xik/4ty6LWP47EpbqToS5WOsgH4f7YI9t n3gG/ppFHT3fy1zbRr5swL/Vm/R3Ih2dxt9vE/aM/SjtoqXka6LkZ/w3O2ozbO9ybgoy CEMBaqXQCBCHTxsp5iDZKwtSIluyjdl4b2AnomlkClMSp1nVGNiorW9TCkTSvU93ti8A 2a9MJJ2MJmOguP9ti1sRDLlTv64PFfFJGNUF/eGUq+uGMIg98ZsN+L3MaZvdqYMztfHa N/GccNKFkpwnQ+07HI2nrcwF9BT7cV79EwvhZTJRdpf1/OPafwDLYAR9AHoRCTVs8Pkv TMkQ== X-Gm-Message-State: AOAM53037HpBV8OIRa7EfHjVaayGLuEmfMrA7GW7nsYVmfXwd4DDtYLs CliB20LGnSPfFyqOk1361+U= X-Google-Smtp-Source: ABdhPJwpfQTh6J6dcL0YXRPohLHBsZRGMm3qVmnYH5MGjeG+Mt0DfSSRl/M24lky7ufNhUNuHQ79Mw== X-Received: by 2002:a17:902:db05:b0:13e:7b36:5e11 with SMTP id m5-20020a170902db0500b0013e7b365e11mr3507916plx.43.1633412475755; Mon, 04 Oct 2021 22:41:15 -0700 (PDT) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id o15sm16762764pfg.14.2021.10.04.22.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 22:41:15 -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: Mon, 4 Oct 2021 22:40:49 -0700 Message-Id: <20211005054059.475634-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211005054059.475634-1-yury.norov@gmail.com> References: <20211005054059.475634-1-yury.norov@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C2067B000BC5 X-Stat-Signature: iuu4wtwozeereny7afigrgx1ew8ipx9f Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WITMNTfk; spf=pass (imf24.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=yury.norov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1633412476-961520 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 5d4d07a9e1ed..c7be6c5b7523 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