blob: 07e0484318cb27edd69bb4bf2d6bc3f1ea6ef4c1 [file] [log] [blame]
Patrick Williams2194f502022-10-16 14:26:09 -05001From 2919ec562ca976a0ae5f70b264379b3d45abdaf5 Mon Sep 17 00:00:00 2001
Brad Bishopbec4ebc2022-08-03 09:55:16 -04002From: Robin Murphy <robin.murphy@arm.com>
3Date: Fri, 3 Dec 2021 11:44:56 +0000
Patrick Williams2194f502022-10-16 14:26:09 -05004Subject: [PATCH 21/40] perf/arm-cmn: Optimise DTM counter reads
Brad Bishopbec4ebc2022-08-03 09:55:16 -04005
6When multiple nodes of the same type are connected to the same XP
7(particularly in CAL configurations), it seems that they are likely
8to be consecutive in logical ID. Therefore, we're likely to gain a
9small benefit from an easy tweak to optimise out consecutive reads
10of the same set of DTM counters for an aggregated event.
11
12Signed-off-by: Robin Murphy <robin.murphy@arm.com>
13Link: https://lore.kernel.org/r/7777d77c2df17693cd3dabb6e268906e15238d82.1638530442.git.robin.murphy@arm.com
14Signed-off-by: Will Deacon <will@kernel.org>
15
16Upstream-Status: Backport [https://lore.kernel.org/r/7777d77c2df17693cd3dabb6e268906e15238d82.1638530442.git.robin.murphy@arm.com]
17Signed-off-by: Rupinderjit Singh <rupinderjit.singh@arm.com>
18---
19 drivers/perf/arm-cmn.c | 17 +++++++++--------
20 1 file changed, 9 insertions(+), 8 deletions(-)
21
22diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
Patrick Williams2194f502022-10-16 14:26:09 -050023index 8b98ca9666d0..005a0d83bcac 100644
Brad Bishopbec4ebc2022-08-03 09:55:16 -040024--- a/drivers/perf/arm-cmn.c
25+++ b/drivers/perf/arm-cmn.c
26@@ -690,18 +690,19 @@ static void arm_cmn_pmu_disable(struct pmu *pmu)
27 static u64 arm_cmn_read_dtm(struct arm_cmn *cmn, struct arm_cmn_hw_event *hw,
28 bool snapshot)
29 {
30+ struct arm_cmn_dtm *dtm = NULL;
31 struct arm_cmn_node *dn;
32- unsigned int i, offset;
33- u64 count = 0;
34+ unsigned int i, offset, dtm_idx;
35+ u64 reg, count = 0;
36
37 offset = snapshot ? CMN_DTM_PMEVCNTSR : CMN_DTM_PMEVCNT;
38 for_each_hw_dn(hw, dn, i) {
39- struct arm_cmn_dtm *dtm = &cmn->dtms[dn->dtm];
40- int dtm_idx = arm_cmn_get_index(hw->dtm_idx, i);
41- u64 reg = readq_relaxed(dtm->base + offset);
42- u16 dtm_count = reg >> (dtm_idx * 16);
43-
44- count += dtm_count;
45+ if (dtm != &cmn->dtms[dn->dtm]) {
46+ dtm = &cmn->dtms[dn->dtm];
47+ reg = readq_relaxed(dtm->base + offset);
48+ }
49+ dtm_idx = arm_cmn_get_index(hw->dtm_idx, i);
50+ count += (u16)(reg >> (dtm_idx * 16));
51 }
52 return count;
53 }
54--
Patrick Williams2194f502022-10-16 14:26:09 -0500552.34.1
Brad Bishopbec4ebc2022-08-03 09:55:16 -040056