From patchwork Thu Feb 10 22:48:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742573 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7335AC433EF for ; Thu, 10 Feb 2022 23:19:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IoUCltTSdId1pnxM3VgU5zDnUZse37+FF73ep6EpHws=; b=h/FmtvHsRh8Vhy mWMuVYbe+jonA73F2O8vdBPlhlRXieP8vBTPN2vA4NT2VfqRKFl3xRZm/jv6J/lckRySkWZd7oE/R eNN3mYlyzLF2e4rRGhrBo/5+7b/UlGahxdhOPBBZ4QSr3xlgILS4uivI4luJVwkOSbXmE8UDC6Jo8 YFti/EN3I9NBFj66b2B4fiVVo5OwrscWTINBpvrrfX7Df6kRrD5rN89buyLBwL/giAxaRYdxfkOPj ksB+ldpgMl4IhktbNzF2tAQbdiDNUWYepWPlCJL3W8vHon14UhS75pV+fT33sGJtLQXkgnst7Q+JL PYHhhwCG4o6PilAhxZCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIIhm-0059bT-Ir; Thu, 10 Feb 2022 23:18:26 +0000 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIIhj-0059ax-3I for linux-arm-kernel@lists.infradead.org; Thu, 10 Feb 2022 23:18:24 +0000 Received: by mail-io1-xd35.google.com with SMTP id 9so9452138iou.2 for ; Thu, 10 Feb 2022 15:18:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=TZjvXmQL+ezx3++i6ywjCYX2+WSMiXHIFAoZu2xGMQA=; b=dh1iu5XVFR9JgGmMSioQ2P16YMuiIHmUjr61dP4GMbiQ/DBV+xy86sSdWmO7JGy9if SiLJjyrhAkltJyEffBig8nn7rsqFuMeuHJldrAgRTAtSTjv8EpjOdC6vIIDTuX1vQG8X tyHGhTZ88Kz+/3L0/sgBvY4LT8htAeWWCbvSN6jtFh9goqGhVxab8f4MrhWEbhotDg6L D4rDahldztLcHt5JGGWa7cSD6YDdH1+OScMRhdxHt5HBLYDySnNVxkvB/+UwZ4lyLXil hJs2m820KUfV0pMU7wth5QjgU8v0NZ4f1LIii2okFvCOfDuYH3BHp1hpFfvaosO6XBbb ncUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TZjvXmQL+ezx3++i6ywjCYX2+WSMiXHIFAoZu2xGMQA=; b=IUyX3aRmuegA6vEXibSETqRkpZlkqz6Jiyt+lJxOWugfWi3bB2jeXt2vVFYr2QRTof 7F4PNTfyD4CbVSRcsFyky9jGdOK0qv4XTCYOyR7MpYpFJOBJJDq4Qa6KOp4y35cMkeT8 Z0lhAad+uuiufs4Yb+FQkROslLJg+7Yzi+kDpKoWRaMkW7zLN8EdTAaub7XP0jtZEFpb QTSOzWD8D6TLf1t/HmWB2yd0VfEwqaI7EGWXuy7ag3kanOSadatIgFuVTZLa+5s1QDQJ Wn89q4ATWnydwiDqnkPlkq+0+kyP+jRICPNhu3ZPWb4lo1xFi4uwMEIeEmIIiWu3TqhL ebCQ== X-Gm-Message-State: AOAM532w/EijiV+kp/om5llPghCLXN7nRxt860x2LhpyLN3voxQ3scZG pf0Z2iZbeNCP3rbIsvKi1y0= X-Google-Smtp-Source: ABdhPJzpdxrXi7jABYsEM7idoWZV3Dcam0pULppAeFkiKjAPVbRQOvUhQvFaYJB7D2HMiS0CGqRkmw== X-Received: by 2002:a05:6602:2b10:: with SMTP id p16mr5163745iov.44.1644535101887; Thu, 10 Feb 2022 15:18:21 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id p16sm8877673ilm.85.2022.02.10.15.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 15:18:21 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Will Deacon , Mark Rutland , Shaokun Zhang , Qi Liu , Khuong Dinh , linux-arm-kernel@lists.infradead.org Subject: [PATCH 12/49] perf: replace bitmap_weight with bitmap_empty where appropriate Date: Thu, 10 Feb 2022 14:48:56 -0800 Message-Id: <20220210224933.379149-13-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_151823_183206_059A7F13 X-CRM114-Status: GOOD ( 15.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In some places, drivers/perf code calls bitmap_weight() to check if any bit of a given bitmap is set. It's better to use bitmap_empty() in that case because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov Acked-by: Mark Rutland --- drivers/perf/arm-cci.c | 2 +- drivers/perf/arm_pmu.c | 4 ++-- drivers/perf/hisilicon/hisi_uncore_pmu.c | 2 +- drivers/perf/xgene_pmu.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c index 54aca3a62814..96e09fa40909 100644 --- a/drivers/perf/arm-cci.c +++ b/drivers/perf/arm-cci.c @@ -1096,7 +1096,7 @@ static void cci_pmu_enable(struct pmu *pmu) { struct cci_pmu *cci_pmu = to_cci_pmu(pmu); struct cci_pmu_hw_events *hw_events = &cci_pmu->hw_events; - int enabled = bitmap_weight(hw_events->used_mask, cci_pmu->num_cntrs); + bool enabled = !bitmap_empty(hw_events->used_mask, cci_pmu->num_cntrs); unsigned long flags; if (!enabled) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 295cc7952d0e..a31b302b0ade 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -524,7 +524,7 @@ static void armpmu_enable(struct pmu *pmu) { struct arm_pmu *armpmu = to_arm_pmu(pmu); struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events); - int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events); + bool enabled = !bitmap_empty(hw_events->used_mask, armpmu->num_events); /* For task-bound events we may be called on other CPUs */ if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus)) @@ -785,7 +785,7 @@ static int cpu_pm_pmu_notify(struct notifier_block *b, unsigned long cmd, { struct arm_pmu *armpmu = container_of(b, struct arm_pmu, cpu_pm_nb); struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events); - int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events); + bool enabled = !bitmap_empty(hw_events->used_mask, armpmu->num_events); if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus)) return NOTIFY_DONE; diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c index a738aeab5c04..358e4e284a62 100644 --- a/drivers/perf/hisilicon/hisi_uncore_pmu.c +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c @@ -393,7 +393,7 @@ EXPORT_SYMBOL_GPL(hisi_uncore_pmu_read); void hisi_uncore_pmu_enable(struct pmu *pmu) { struct hisi_pmu *hisi_pmu = to_hisi_pmu(pmu); - int enabled = bitmap_weight(hisi_pmu->pmu_events.used_mask, + bool enabled = !bitmap_empty(hisi_pmu->pmu_events.used_mask, hisi_pmu->num_counters); if (!enabled) diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c index 5283608dc055..0c32dffc7ede 100644 --- a/drivers/perf/xgene_pmu.c +++ b/drivers/perf/xgene_pmu.c @@ -867,7 +867,7 @@ static void xgene_perf_pmu_enable(struct pmu *pmu) { struct xgene_pmu_dev *pmu_dev = to_pmu_dev(pmu); struct xgene_pmu *xgene_pmu = pmu_dev->parent; - int enabled = bitmap_weight(pmu_dev->cntr_assign_mask, + bool enabled = !bitmap_empty(pmu_dev->cntr_assign_mask, pmu_dev->max_counters); if (!enabled) From patchwork Thu Feb 10 22:49:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742584 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 765C1C433EF for ; Thu, 10 Feb 2022 23:32:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=efVBC+8oLpXAzkXUGwZYLRFbwxtleqaasvYd5AGWyy0=; b=oEhbGhQlFnovSD 8/491i+Oeo7Ksn7kSc5HAHXInQX260MpLuOKBAjRQNGzKA53schrjO3qiOj3/Se1TNFTH2YzSjUzY jDOZEyLfjRcR6I21ipeVdvETmvd9b0pLCHHyXLeRaCZITEVTjn7uyKps8YPy894Z60d4U2HYoeVHk GBmclG0oE4bmftPoQXF2cSO38IcemjucEeEm2NeKJegWODsjJcgDe5EuaictXvr6fjrXbePAai6dO DdJaeTjp0Q9eKnW/iEJXrYUfGTZI4dN/x8H7oAldbc/+GKY7f6uKegLLMp2YmONowkH/o/6+IxGCt 1xzU5lTkl61Y0HnENYDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIIu0-005BCj-0e; Thu, 10 Feb 2022 23:31:05 +0000 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIIsT-005AR6-Af for linux-arm-kernel@lists.infradead.org; Thu, 10 Feb 2022 23:29:32 +0000 Received: by mail-il1-x131.google.com with SMTP id n5so5635231ilk.12 for ; Thu, 10 Feb 2022 15:29:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3bNm5/uTnBAzIRKqMnmZ8YYfpkxkteIvyaUY7P/5B+o=; b=fLgRM4uji0XMP07LvJA5cjBtqm7zXPbJEBYtQDz8uGRsGjNkvOmu1mZZGhE7PFB0h8 7PGHiZ+HnW21lWBjG1Hp5A/io3C7i6JtUrMDThpe5y92omUL2lBUuwmbVl7bS3bU0t7o bZq4lw7FX7tlNYB2G04YnPLZMYUK5kOrXpdscRdaz4TtPLlDq3oaDeUrODGU15pKMaSD ocKLNnWjsh+fu2AZ1ivgdj8WAlWXHXIdIRLnA9L7DsQS1etO2PvLwSwJhPDSSGAXJiZV jG0tuxn4fxzCTULGAwmomyB/ly9laDnDKG1pIYbAduDcAzKjTa3UKRbikmrRgcduFqam Yaeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3bNm5/uTnBAzIRKqMnmZ8YYfpkxkteIvyaUY7P/5B+o=; b=MVlH9jySA87ou8kXtgpAYUHS3M8f44AIU0DU0s2WHfSBBm7W9MPPWqmjhwKtcUpl1A 3KAYD4WW1A7XhxXeiLczNGPI8PGZKS8m7lLgvItxXb5as5R72e7z6IIKaRHFiwD8CzBD MM+hWROpw1QoHuKNxEjCSlj15M/2QVakKVwHr6B3ALJGlvA15YRst08LQz8xXiNd+t0s gaPXouxVwjOGNAujZqMg0wfkSRwq3JdOre2eQIxcsg/MoaqsF3dBFRtc4LUdBIzyEYSt eSDgb/4zN0TZHEuy3VQqi2cAKu8+qxs7OsUaP7lvDah5JXYu/KPeY1Pw8sWkaYSrVL7R t06w== X-Gm-Message-State: AOAM532dJDWsUXzKpWwKSRDxjAvGddNfA2oCvNUNAH+1QCU3blxxOoE+ emYeatHiUkweVBjmEdeYMzuiK4u2BxBnwg== X-Google-Smtp-Source: ABdhPJxG4wLZX5EPMqNJ2GZN9s/YWLmAmUwDDdSVvbnGhVn58IPPvR5sZVSRf3Lr6OSWj7N5cae0BA== X-Received: by 2002:a92:d64e:: with SMTP id x14mr5598201ilp.97.1644535767261; Thu, 10 Feb 2022 15:29:27 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id b5sm6717209ilr.0.2022.02.10.15.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 15:29:26 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Andy Gross , Bjorn Andersson , "Rafael J. Wysocki" , Viresh Kumar , Sudeep Holla , Cristian Marussi , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 17/49] cpufreq: replace cpumask_weight with cpumask_empty where appropriate Date: Thu, 10 Feb 2022 14:49:01 -0800 Message-Id: <20220210224933.379149-18-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_152929_401804_CC0A1F45 X-CRM114-Status: GOOD ( 15.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org drivers/cpufreq calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov Reviewed-by: Sudeep Holla (for SCMI cpufreq driver) --- drivers/cpufreq/qcom-cpufreq-hw.c | 2 +- drivers/cpufreq/scmi-cpufreq.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 05f3d7876e44..95a0c57ab5bb 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -482,7 +482,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy) } qcom_get_related_cpus(index, policy->cpus); - if (!cpumask_weight(policy->cpus)) { + if (cpumask_empty(policy->cpus)) { dev_err(dev, "Domain-%d failed to get related CPUs\n", index); ret = -ENOENT; goto error; diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index 1e0cd4d165f0..919fa6e3f462 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -154,7 +154,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) * table and opp-shared. */ ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, priv->opp_shared_cpus); - if (ret || !cpumask_weight(priv->opp_shared_cpus)) { + if (ret || cpumask_empty(priv->opp_shared_cpus)) { /* * Either opp-table is not set or no opp-shared was found. * Use the CPU mask from SCMI to designate CPUs sharing an OPP From patchwork Thu Feb 10 22:49:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742606 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99FB5C433EF for ; Fri, 11 Feb 2022 00:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YVibORtDeeKDb6lFEUDaZgTZvFFAUbTMO8xETucSpHE=; b=rkfBF34cwaIUGv 13AMfPa6kjYWWFwkmGwZltam4rHjycXcdEIdiGHk1lvbnMAOJ7kcYHrgw//jI4cZQq7deVIBZE8/y pcJCUBhq7qlbbcLhqBVSFo/zEvTrFXfWobrHy2jotzwXkF+SBSobQL1t7PofBYGcA+8brb4AvFyYZ ZC6FaXoURAoxNLW28AphtuRAnILrx0uWlw3JrBBl5Ytr0sEHha6X0UAMqbGcuLhN4K2M+3z0k8t6X PMstdNcu6kpk7yp4jAym+A+CHujWXdV3dMd7FE6fq65neCRuPhSlWzCW37r7dATQoGjqRFF4vNXNl YoyebwgR4lbZzE0gKRmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIJQc-005GYo-F3; Fri, 11 Feb 2022 00:04:46 +0000 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIJQY-005GYV-EO for linux-arm-kernel@lists.infradead.org; Fri, 11 Feb 2022 00:04:43 +0000 Received: by mail-qv1-xf2a.google.com with SMTP id a19so6844654qvm.4 for ; Thu, 10 Feb 2022 16:04:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4Pnr1geQeZZNYUvmzTdrAcaSDDBHcWYiYOpV2+IuXsY=; b=igNyfPN7wFlEB1yG0Q94kr/PxThWMFSj7uV6Xa4lsNO8Eodt/gd8/VSAkzJPPNNLqD qQwMyH8ytBWbsWit97TH9K8POhN09okti3ZyrqvzyHsbekkA+9K/sE9UpcWfflBJ6IX+ rhewR0hrCY8scmAiE3GTbwcTImsKu8PHITWAJ8KcJjCbRrQVFfaIPsg5CJBI+XMVT1T2 Mpfbx/rAP4rZXHBa7IM2cBBntYJ+Tq2sImYYlI9cqsl2/gWObSkvu8rlLJoLDx7IJcj1 jCx2oUFhq59q3xZWxiZBd6OlaPcAu9p4kvX0V3N74k5jHjhmq4ZfoiAb7ipvUDuOUeOL 9MJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4Pnr1geQeZZNYUvmzTdrAcaSDDBHcWYiYOpV2+IuXsY=; b=ORkN3aRHJfbvUhRFeNKwJ2xtNrpu1/r1Uz/AYCC59owPXwFoJDmu/9D9juR3QziHHW dZJ4ihDDRap4A+B2yTA/6tLfU3Ke8ws/8EqlMS4nkn2YIk9Dp/6KzLcu+NAxD1qM4AYe eksjz9JpFP/H5yCs7xAy3xEf69HCpZkwpUCq0IgMHyefAFSC2/Ly5Jg9aNfVA9PKIZ+n L0qJogK9cMb/MIFk12XvNAk7RHaoLTiyTZp3GFUtcS9ASAz24amkujKvXP9h40eFXxei DXzEZHDYjSRmvP0HDJqCof+CzMtg+Yhvf+IA1TpnE+9CZstzNvq+v3Rk+BMWLPpAaGP/ 1/ZQ== X-Gm-Message-State: AOAM531owHaP6xtYgCALs+WaDq+uJffv4/Ivnsz1yoXabvQxkHldelO/ zVevVFxKX8i1w+7FBEZ0yGE= X-Google-Smtp-Source: ABdhPJyfV3TF5HzHznBEsBWEauR+HTDxani3jRA7hek8YabMaXIpvx3P8mEI1Y1Wy7MVJOQjILfz9w== X-Received: by 2002:a05:6214:2306:: with SMTP id gc6mr6804104qvb.45.1644537881043; Thu, 10 Feb 2022 16:04:41 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id 195sm10710640qkf.30.2022.02.10.16.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 16:04:40 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 33/49] perf: replace bitmap_weight with bitmap_weight_eq for ThunderX2 Date: Thu, 10 Feb 2022 14:49:17 -0800 Message-Id: <20220210224933.379149-34-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_160442_521378_1A5DD5D3 X-CRM114-Status: GOOD ( 13.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org tx2_uncore_event_start() calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_eq because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is (or can't be) met. Signed-off-by: Yury Norov Acked-by: Mark Rutland --- drivers/perf/thunderx2_pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c index 1edb9c03704f..97d5b39778fa 100644 --- a/drivers/perf/thunderx2_pmu.c +++ b/drivers/perf/thunderx2_pmu.c @@ -623,8 +623,8 @@ static void tx2_uncore_event_start(struct perf_event *event, int flags) return; /* Start timer for first event */ - if (bitmap_weight(tx2_pmu->active_counters, - tx2_pmu->max_counters) == 1) { + if (bitmap_weight_eq(tx2_pmu->active_counters, + tx2_pmu->max_counters, 1)) { hrtimer_start(&tx2_pmu->hrtimer, ns_to_ktime(tx2_pmu->hrtimer_interval), HRTIMER_MODE_REL_PINNED); From patchwork Thu Feb 10 22:49:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742614 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF291C433F5 for ; Fri, 11 Feb 2022 00:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=N0OQris6ApFcHk/DVX1ksrHGvOPKj9se3uwSqv2EuZA=; b=wZzLOM1j8EXLwC btu2QifxcA2pUPocyvBYmm0T3DXIXUevT9YdEbGkm1kD8rqzQvzundBU2FLKV2duY3kGvEGSk95ir lZyJrRNDsDAoC43hzHm9xrnJAgAx4M8BaElK1vnr7d2GS1NVKXBJwJLV60F3POAZxFpwD3W4jyvZZ ogMoXXFelLSNgybSOMFid6juDbqLHfYLnHZ1lkPfae25rsQ1vTrBP1eQfWez5xfg3r6gJltz4pOnn DdoZ1ibowHVNuwz6SY9X1KKflac2+xnUDGAaVdJxZrsCxzhDADf1esFpe1jS3Jasyr1uD+ZNnr4X4 FDVPyM+ox60Nw6i3DMhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIJfc-005Ika-Qm; Fri, 11 Feb 2022 00:20:17 +0000 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIJfZ-005Ijx-Ho for linux-arm-kernel@lists.infradead.org; Fri, 11 Feb 2022 00:20:14 +0000 Received: by mail-io1-xd29.google.com with SMTP id c188so9527068iof.6 for ; Thu, 10 Feb 2022 16:20:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=hLEL9851jabrdDhcxhGMVE1OmCduEAH/N0L9wmwcIjg=; b=Ddx6yjYcPE8CmX5hCgpAe3NuBPN+UEnDWxaj/S4nyidlsNp29Qi4nO6yKxahYSYWze 60wBTMk/1n3Bf0Dn3Qa+ISIEaGAIbwgzWu13tuLljBfaY2PsnoHzOrV4sBzxPCb9gaGE obvUhv9/uBtVaE78ha7HcUXUC1VXhfiFzo2TuxG/D3nExuOMPflFJuzfwDMEkVz4obqJ U4tJPN3VkTmPOMPDDmKLp4mU6KISHK1gSlamntZK/Ny7CNDDZI5eMEHdTAG8rnsFssRc k94GWNgNxamMatkGjEVqYabjh/Rr7UGcEqRtK2QKFls+yc5KuvRZaVEOKnKvt6NXX9jZ 3Thw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hLEL9851jabrdDhcxhGMVE1OmCduEAH/N0L9wmwcIjg=; b=ku+jmVj+UK60c+BC+sh84IZ05Vcfk/AIiW3G2KQN2RzFrQIGIDktBXvdi+baffmn5Z LYJHZnZCYa/OviXBLbOZ50WsxXRvirI3VFdsiC3Zd5aeVPdLh8safqTnqSkU+fYtikqr RjyUMeLhIY1VCZCTX6I+RVoncRH5S7ZDVGLgJFCw/q36+7guj1g4gsJKsbmL9kVcX1qV lXSDHBfitkM2+WHJsq7B/bCEdbuIwGpWf5IaYIx1tJdsVdnBIo4hXxUGS6AJtGgvMye7 j9Noc37SjJk4Vb9v+mBsrTeELVvEIg9B3K5jYqbAjoC14dGmNTf5+Bjpde/hdMAAK3pJ SywQ== X-Gm-Message-State: AOAM531Y7HyhHytAwxokZZMrGZNZ2sxUQfL/TYgbxUVT7AikQX6SO+8x rmoHyD7RYWlAqlPqXrfj3uY= X-Google-Smtp-Source: ABdhPJw7qdPMYUQVvRvWAT1whw8GJ3WVabvUcKINgiQx0zHMbH9lOyy7aRlH2DJYa0qShCIMVimymQ== X-Received: by 2002:a6b:7316:: with SMTP id e22mr5135069ioh.125.1644538812801; Thu, 10 Feb 2022 16:20:12 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id d12sm11665467ilv.42.2022.02.10.16.20.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 16:20:12 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Mark Rutland , Lorenzo Pieralisi , linux-arm-kernel@lists.infradead.org Subject: [PATCH 40/49] firmware: pcsi: replace cpumask_weight with cpumask_weight_eq Date: Thu, 10 Feb 2022 14:49:24 -0800 Message-Id: <20220210224933.379149-41-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_162013_627186_986E4AA5 X-CRM114-Status: GOOD ( 13.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org down_and_up_cpus() calls cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_{eq, ...} because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is (or can't be) met. Signed-off-by: Yury Norov Reviewed-by: Sudeep Holla Acked-by: Mark Rutland --- drivers/firmware/psci/psci_checker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/psci/psci_checker.c b/drivers/firmware/psci/psci_checker.c index 116eb465cdb4..90c9473832a9 100644 --- a/drivers/firmware/psci/psci_checker.c +++ b/drivers/firmware/psci/psci_checker.c @@ -90,7 +90,7 @@ static unsigned int down_and_up_cpus(const struct cpumask *cpus, * cpu_down() checks the number of online CPUs before the TOS * resident CPU. */ - if (cpumask_weight(offlined_cpus) + 1 == nb_available_cpus) { + if (cpumask_weight_eq(offlined_cpus, nb_available_cpus - 1)) { if (ret != -EBUSY) { pr_err("Unexpected return code %d while trying " "to power down last online CPU %d\n", From patchwork Thu Feb 10 22:49:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742620 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A93C9C433EF for ; Fri, 11 Feb 2022 00:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YDFQvQGJ3YyfEBF7vBVevOBfgZicu++Ag+6rANB/pks=; b=lWvPYo9Up+R6K8 a2C+l8T0BtwZWapaMcCTCQsPy2a/YwqAzTAUG21UgW6hd1ajL6ZpFegT6bmbnOFYd+q0vMpKIy/Qe VF2ZYj9krOU0SNQRIR1wGEXtKMwTyy5FQeBBreUtu8FyGoYA45Guw7vgY1XyIUPCXYH9L2wSb8YcN /U3iZuMjXcUdvfiDxXj7/RudYYnLivwHlnxmiGwEnSV8swZ/CgXNnsAJoFSsP5KDG7bvQbDe9Z/5M 6Fm2e+h2mm2VyVHaO+NCDkx9XpYMEwr+VjLPoP51cu9e+aG+mDFLtodTQH9i5zZByL+P6JbIYlQWO J8Qcv71ZC2SZbK4PyV/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIJm4-005JMC-FN; Fri, 11 Feb 2022 00:26:56 +0000 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIJm0-005JLg-NU for linux-arm-kernel@lists.infradead.org; Fri, 11 Feb 2022 00:26:54 +0000 Received: by mail-il1-x133.google.com with SMTP id b5so5723382ile.11 for ; Thu, 10 Feb 2022 16:26:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1MJU8h6aqi1lREanFgpSWWzF65VdO9IwfkWhBgqaH3Y=; b=mvi1bzuGc+ZCDBoKyIvPuu57FjwX/ZNRRmbHLZvq28NxvswbVJpCtL+TPmWTVqyuNq zHOVncwF2tsmDVT250gY7kLq+jhckLGi7PlKEqS4kMkEFP1KTu7Z7xjiQlYjB2792Sy0 y79LwuSrYF42p6Ksm7buY7+zkijxS7uB/hHR9ElJmFJeaWgz2GF8WWh/oKXQxLhRyRAL sBCNNuvExT46DRyy/8TIoNJF5PD3spUAqOHHh9NO3ZMs/icV5NIDHPE+azUqsowaetzV 7cpHrDo+EZ7zUtQ5l6ZDe3klqtAXMvArBpa4JNsPnSEGr2ueqLcJfFXWmveEcH8M/UrG z/9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1MJU8h6aqi1lREanFgpSWWzF65VdO9IwfkWhBgqaH3Y=; b=nQK1KmpseJeFWaGrdLlPVCE/bt4dVUJBQsoeDg38kDCeVDFWdORyjV/PLobbg14Rq1 OezcWwlYyUeASPbYA9HcWoA+DKZiZTsAF7Z+SO/2TIJDJ295x2MsK+nTCrQtnxJGIHw9 XnUFzNpRPIXDPTfyizOsLU64VakoD2VWzm7gg6MdyXa3Ups+m5OudzZYZ0PvPhHnZvCk J52bPOCKZ8VgFNSGrqxAtBs+ECHquplFujiAEuDgBJdRRA+h7MVUIAOg3Eew5HjX0+Co K1jg2SGwa+7ah+8TMtAZPO1KwHbk1q93Z/gvGBVggP5+7bE6uGjx6z0m/1umI3fsDd6z iBtQ== X-Gm-Message-State: AOAM531KxRseUw3a8VAuIUpMTnmPtDKhWy3oLW+HUW173OIhVdMJfLN7 jqW3PRhdd8JkJOyRllgzX0c= X-Google-Smtp-Source: ABdhPJw4HRWGUzFWRINnqDSvHJhe4t426yscU51lkh9YSM6/oOmml5+22RpllautY9urs7QLFyNzJQ== X-Received: by 2002:a92:ab01:: with SMTP id v1mr5297485ilh.149.1644539212078; Thu, 10 Feb 2022 16:26:52 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id y22sm12896727iow.2.2022.02.10.16.26.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 16:26:51 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Li Yang , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 43/49] soc/qman: replace cpumask_weight with cpumask_weight_lt Date: Thu, 10 Feb 2022 14:49:27 -0800 Message-Id: <20220210224933.379149-44-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_162652_785160_6A3B4C95 X-CRM114-Status: GOOD ( 12.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org qman_test_stash() calls cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_lt because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is (or can't be) met. Signed-off-by: Yury Norov --- drivers/soc/fsl/qbman/qman_test_stash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/fsl/qbman/qman_test_stash.c b/drivers/soc/fsl/qbman/qman_test_stash.c index b7e8e5ec884c..28b08568a349 100644 --- a/drivers/soc/fsl/qbman/qman_test_stash.c +++ b/drivers/soc/fsl/qbman/qman_test_stash.c @@ -561,7 +561,7 @@ int qman_test_stash(void) { int err; - if (cpumask_weight(cpu_online_mask) < 2) { + if (cpumask_weight_lt(cpu_online_mask, 2)) { pr_info("%s(): skip - only 1 CPU\n", __func__); return 0; }