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: 12535511 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 A9498C4332F for ; Tue, 5 Oct 2021 05:41:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97EC361526 for ; Tue, 5 Oct 2021 05:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232691AbhJEFnT (ORCPT ); Tue, 5 Oct 2021 01:43:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232307AbhJEFnK (ORCPT ); Tue, 5 Oct 2021 01:43:10 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48C3BC061745; Mon, 4 Oct 2021 22:41:16 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id a11so492239plm.0; 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=qhzXEHxXloNhFSfj0Ig0XZPYOmrVzYeYSt5j5OU/g6C9QAheLLPm/sFXmuKu1fC+mL vX4Wy7DRtT3PttLLegcOpTu0kH1fOLUZV0105cuHKEJ4mQtryKpHH6hrP8wEAYBFuymO x6Q9i5sFDULMAC5Gav54L2gY6C2uVlbCmXdj0Jl6Si1WQ58HEh73ZWVCWVrLm7K/jqFX lFRTcdCQVR2FF57KCbFsNHaR1TYgEzhfsfcnm16ql45GHQFwK0a8koyGwTg/o0VBwyHf xld0LmUmbSScRT3wRUoSE2G7LbA7RfE2C2pTsvEOuyyqfEj57q8buKD+aEtKugdTGC0N 7bkg== X-Gm-Message-State: AOAM533ZnzotyJGcSEP6sT9gu7b9ReZSUwQSIhSKN6aH92zqPM2mv7CB VtDxWvmkZppsxIt2TstC3VQ= 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 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 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