Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf: arm_pmuv3: Zero initialize hw_id branch stack field
@ 2026-08-07  9:14 James Clark
  2026-08-07  9:27 ` sashiko-bot
  2026-08-07 10:44 ` Anshuman Khandual
  0 siblings, 2 replies; 6+ messages in thread
From: James Clark @ 2026-08-07  9:14 UTC (permalink / raw)
  To: Will Deacon, Mark Rutland, Rob Herring (Arm), Anshuman Khandual,
	Leo Yan, Suzuki Poulose
  Cc: linux-arm-kernel, linux-perf-users, linux-kernel, James Clark

PERF_SAMPLE_BRANCH_HW_INDEX is supported by BRBE so hw_id is passed to
userspace, but it's never set by the BRBE driver. Zero initialize it as
it should be according to the docs:

   * For the architectures whose raw branch records are
   * already stored in age order, the hw_idx should be 0.

It's probably too risky to remove PERF_SAMPLE_BRANCH_HW_INDEX from BRBE
now in case anyone is setting it and reading the value, but zero
initializing the whole struct also protects against the same issue with
new fields that are added in the future.

Fixes: 58074a0fce66 ("perf: arm_pmuv3: Add support for the Branch Record Buffer Extension (BRBE)")
Signed-off-by: James Clark <james.clark@linaro.org>
---
Very small fix spotted by Sashiko. It was probably always zero during
testing or never looked at.
---
 drivers/perf/arm_pmuv3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c
index 8014ff766cff..b9a8592bf112 100644
--- a/drivers/perf/arm_pmuv3.c
+++ b/drivers/perf/arm_pmuv3.c
@@ -1361,7 +1361,7 @@ static int branch_records_alloc(struct arm_pmu *armpmu)
 		struct pmu_hw_events *events_cpu;
 
 		events_cpu = per_cpu_ptr(armpmu->hw_events, cpu);
-		events_cpu->branch_stack = kmalloc(size, GFP_KERNEL);
+		events_cpu->branch_stack = kzalloc(size, GFP_KERNEL);
 		if (!events_cpu->branch_stack)
 			return -ENOMEM;
 	}

---
base-commit: f9a2394a23482bfd330911e9c8295b71724feacd
change-id: 20260807-james-brbe-init-hw-idx-53dec54fe266

Best regards,
--  
James Clark <james.clark@linaro.org>


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

end of thread, other threads:[~2026-08-07 14:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07  9:14 [PATCH] perf: arm_pmuv3: Zero initialize hw_id branch stack field James Clark
2026-08-07  9:27 ` sashiko-bot
2026-08-07 10:05   ` James Clark
2026-08-07 10:44 ` Anshuman Khandual
2026-08-07 12:18   ` James Clark
2026-08-07 14:27     ` Will Deacon

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