]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drivers: perf: use bitmap_empty() where appropriate
authorYury Norov (NVIDIA) <yury.norov@gmail.com>
Tue, 16 Dec 2025 01:20:03 +0000 (20:20 -0500)
committerWill Deacon <will@kernel.org>
Mon, 5 Jan 2026 20:39:40 +0000 (20:39 +0000)
bitmap_empty() is more verbose and efficient, as it stops traversing
bitmaps as soon as the 1st set bit found.

Switch perf code to using bitmap_empty() where appropriate, and
correspondingly use boolean types.

Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
Signed-off-by: Will Deacon <will@kernel.org>
drivers/perf/riscv_pmu_sbi.c
drivers/perf/starfive_starlink_pmu.c

index 7dd282da67cef95a178dbc644405aa79dbd181c4..9dcc22fd48ef81dc5abe3efe8564f1aad9c74b4b 100644 (file)
@@ -1244,7 +1244,7 @@ static int riscv_pm_pmu_notify(struct notifier_block *b, unsigned long cmd,
 {
        struct riscv_pmu *rvpmu = container_of(b, struct riscv_pmu, riscv_pm_nb);
        struct cpu_hw_events *cpuc = this_cpu_ptr(rvpmu->hw_events);
-       int enabled = bitmap_weight(cpuc->used_hw_ctrs, RISCV_MAX_COUNTERS);
+       bool enabled = !bitmap_empty(cpuc->used_hw_ctrs, RISCV_MAX_COUNTERS);
        struct perf_event *event;
        int idx;
 
index 5e5a672b42294e9eb4ee906f1d6878475494a885..964897c2baa91964e0f098a8fedbe98e7365423a 100644 (file)
@@ -450,8 +450,7 @@ static int starlink_pmu_pm_notify(struct notifier_block *b,
                                                         starlink_pmu_pm_nb);
        struct starlink_hw_events *hw_events =
                                        this_cpu_ptr(starlink_pmu->hw_events);
-       int enabled = bitmap_weight(hw_events->used_mask,
-                                   STARLINK_PMU_MAX_COUNTERS);
+       bool enabled = !bitmap_empty(hw_events->used_mask, STARLINK_PMU_MAX_COUNTERS);
        struct perf_event *event;
        int idx;