From patchwork Sun Jan 23 18:38:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12721087 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 09EF4C433F5 for ; Sun, 23 Jan 2022 18:41:48 +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=Jqw4fpp2Vvb/GaLCepcZmHPmdrv0XT4pIrfA23nlXzA=; b=LrZNHlV7XG+6ys 6xiu+1SQTxuGR6/Z8qB77wv+raIH7AZO+Y/Rtv2qHpyZ2DrVRF1CREZh5rDZ70tcrm8Zdmkr3obZS yrINVyBee4l8uLRWX6VM0EDdWJ3w/sShDsxo5tBnVcUkeefM1S29sYGD/WuJdwd0sCi6NNR1DqdFX qj8JU/D9sJp52OvptgiUka2nhdzla9mWczvWPAlkgV1J6JqaBWy7IwUzqpyyvRngt6vhVrEC1UvSD gbR8U/7MH8KH2k/+2c7Kn2lnKDvJDagEY4F5Rqws4Me9KhQXix8liXNrbWn83E9wu3wDIpb279hXH SKieC20QkFe2fB35HSCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBhmu-001ZEX-CI; Sun, 23 Jan 2022 18:40:28 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBhmq-001ZDQ-0I for linux-arm-kernel@lists.infradead.org; Sun, 23 Jan 2022 18:40:25 +0000 Received: by mail-pg1-x52a.google.com with SMTP id j10so1013318pgc.6 for ; Sun, 23 Jan 2022 10:40:23 -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=QmvdvRYrU0pccxZjPQvOPFahs5Q0IVqksGfZERujS/w=; b=fEMWqJ0non1/1G7N6hoyBkFO73hoqLatan184u4QZ+CXOWfIxa+mKWmDZWQ330NtrL 79a4csmu1WrP8S5N3nNrCuH8lsqH8E0i37IaLhihnfxVCBlGpZ2fIrpdpj0Sf/sxDVCm SD1AIe7Vg0kK9S/RYVeb5lJ1TkJynGTztkTNtNc6fjgN8wXC13OCBbb3Yjz2/2uYMPif zlhj6Q8IPowwVu8vMseCCqQVQa4umcM/Hzid4RgLiZfxYjowX4xiAAPFyMkcjLChRCh+ JugaXNORXRbfPA4WwAdsVX5PX3vxTJsaiYITdOJiuCO+CTZSTYJLrDCdMCbCYWgff9A+ TYkA== 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=QmvdvRYrU0pccxZjPQvOPFahs5Q0IVqksGfZERujS/w=; b=DNmg/upSfXaFixfiWyitRem3aKUgSiZN5E2nOIx6HON5ufCwOPYhZQjkBgPlkX4fQb cS68YAUz65XVLY+Pq7M1Nh39tTrEO8kK0HEmj/Vdy2heSbrLq+P+isEWyOLHEZr7MD/2 NVw4EAs/RLRSxBqbZDGtv88G7Zi0mBDf2eN+dUCwh3PzknFht2nBTvE8SKNfXdc3NjHV LIDJZ1QI3C5g5MqcaHOP8OznKN9Dn/uvpn2bChNTqvQ5E8+pmmqqwV1Ph+Eq0YtFaVzk OhQSFaYxcn8vRcqKpjyEcsskvmuf9CWb70lR1sc0+xcPUQJp2PXJ6IePd82ZW6lXjRem GLvA== X-Gm-Message-State: AOAM531hdawCwXbwiHpYkHY+zjcK7CXPliIV+BhY/bwu751AR7zBILrp O/PPdoAYfvBbIw0J3BdYejI= X-Google-Smtp-Source: ABdhPJxe9Mdrm++g1fWsFijEPfG65qpS18BjZ5G1v3x54Dtr9GF+uWdZkbmUM6P3YG36cjhhM695Fg== X-Received: by 2002:a63:7543:: with SMTP id f3mr9431653pgn.360.1642963223187; Sun, 23 Jan 2022 10:40:23 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id y42sm5575467pfw.157.2022.01.23.10.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:22 -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 11/54] perf: replace bitmap_weight with bitmap_empty where appropriate Date: Sun, 23 Jan 2022 10:38:42 -0800 Message-Id: <20220123183925.1052919-12-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-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-20220123_104024_071338_DD3FF0FC X-CRM114-Status: GOOD ( 15.28 ) 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 --- 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 2b6d476bd213..88bd100a9633 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)