mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] perf: arm_pmuv3: Use BR_RETIRED for HW branch event if enabled
@ 2024-09-06 19:15 Ilkka Koskinen
  2024-09-09 16:15 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Ilkka Koskinen @ 2024-09-06 19:15 UTC (permalink / raw)
  To: Anshuman Khandual, Will Deacon, Mark Rutland
  Cc: linux-arm-kernel, linux-kernel, ilkka

The PMU driver attempts to use PC_WRITE_RETIRED for the HW branch event,
if enabled. However, PC_WRITE_RETIRED counts only taken branches,
whereas BR_RETIRED counts also non-taken ones.

Furthermore, perf uses HW branch event to calculate branch misses ratio,
implying BR_RETIRED is the correct event to count.

We keep PC_WRITE_RETIRED still as an option in case BR_RETIRED isn't
implemented.

Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
---

v2: Instead of removing PC_WRITE_RETIRED, keep it as an alternative

---

 drivers/perf/arm_pmuv3.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c
index d246840797b6..f5ee6e2adb30 100644
--- a/drivers/perf/arm_pmuv3.c
+++ b/drivers/perf/arm_pmuv3.c
@@ -1089,14 +1089,14 @@ static int __armv8_pmuv3_map_event_id(struct arm_pmu *armpmu,
 	if (event->attr.type == PERF_TYPE_HARDWARE &&
 	    event->attr.config == PERF_COUNT_HW_BRANCH_INSTRUCTIONS) {
 
-		if (test_bit(ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED,
-			     armpmu->pmceid_bitmap))
-			return ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED;
-
 		if (test_bit(ARMV8_PMUV3_PERFCTR_BR_RETIRED,
 			     armpmu->pmceid_bitmap))
 			return ARMV8_PMUV3_PERFCTR_BR_RETIRED;
 
+		if (test_bit(ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED,
+			     armpmu->pmceid_bitmap))
+			return ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED;
+
 		return HW_OP_UNSUPPORTED;
 	}
 
-- 
2.42.0


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

* Re: [PATCH v2] perf: arm_pmuv3: Use BR_RETIRED for HW branch event if enabled
  2024-09-06 19:15 [PATCH v2] perf: arm_pmuv3: Use BR_RETIRED for HW branch event if enabled Ilkka Koskinen
@ 2024-09-09 16:15 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2024-09-09 16:15 UTC (permalink / raw)
  To: Anshuman Khandual, Mark Rutland, Ilkka Koskinen
  Cc: catalin.marinas, kernel-team, Will Deacon, linux-arm-kernel,
	linux-kernel

On Fri, 06 Sep 2024 12:15:39 -0700, Ilkka Koskinen wrote:
> The PMU driver attempts to use PC_WRITE_RETIRED for the HW branch event,
> if enabled. However, PC_WRITE_RETIRED counts only taken branches,
> whereas BR_RETIRED counts also non-taken ones.
> 
> Furthermore, perf uses HW branch event to calculate branch misses ratio,
> implying BR_RETIRED is the correct event to count.
> 
> [...]

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

[1/1] perf: arm_pmuv3: Use BR_RETIRED for HW branch event if enabled
      https://git.kernel.org/will/c/5967a19f1c2f

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:[~2024-09-09 16:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-06 19:15 [PATCH v2] perf: arm_pmuv3: Use BR_RETIRED for HW branch event if enabled Ilkka Koskinen
2024-09-09 16:15 ` 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®