mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drivers: perf: use bitmap_empty() where appropriate
@ 2025-12-16  1:20 Yury Norov (NVIDIA)
  2026-01-05 22:58 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Yury Norov (NVIDIA) @ 2025-12-16  1:20 UTC (permalink / raw)
  To: Atish Patra, Anup Patel, Will Deacon, Mark Rutland,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Ji Sheng Teoh, linux-riscv, linux-arm-kernel, linux-perf-users,
	linux-kernel
  Cc: Yury Norov (NVIDIA)

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>
---
 drivers/perf/riscv_pmu_sbi.c         | 2 +-
 drivers/perf/starfive_starlink_pmu.c | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c
index 7dd282da67ce..9dcc22fd48ef 100644
--- a/drivers/perf/riscv_pmu_sbi.c
+++ b/drivers/perf/riscv_pmu_sbi.c
@@ -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;
 
diff --git a/drivers/perf/starfive_starlink_pmu.c b/drivers/perf/starfive_starlink_pmu.c
index 5e5a672b4229..964897c2baa9 100644
--- a/drivers/perf/starfive_starlink_pmu.c
+++ b/drivers/perf/starfive_starlink_pmu.c
@@ -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;
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drivers: perf: use bitmap_empty() where appropriate
  2025-12-16  1:20 [PATCH] drivers: perf: use bitmap_empty() where appropriate Yury Norov (NVIDIA)
@ 2026-01-05 22:58 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2026-01-05 22:58 UTC (permalink / raw)
  To: Atish Patra, Anup Patel, Mark Rutland, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Ji Sheng Teoh,
	linux-riscv, linux-arm-kernel, linux-perf-users, linux-kernel,
	Yury Norov (NVIDIA)
  Cc: catalin.marinas, kernel-team, Will Deacon

On Mon, 15 Dec 2025 20:20:03 -0500, Yury Norov (NVIDIA) wrote:
> 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.
> 
> 
> [...]

Applied to will (for-next/perf), thanks!

[1/1] drivers: perf: use bitmap_empty() where appropriate
      https://git.kernel.org/will/c/0c7c64146f70

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-01-05 22:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-16  1:20 [PATCH] drivers: perf: use bitmap_empty() where appropriate Yury Norov (NVIDIA)
2026-01-05 22:58 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®