blob: af334686fbad83ed43a24f02ff4ba5e372e3f48f [file] [log] [blame]
Brad Bishopbec4ebc2022-08-03 09:55:16 -04001From a63878c01597e21451c2b3f239cbf0a2fbdeeadf Mon Sep 17 00:00:00 2001
2From: Robin Murphy <robin.murphy@arm.com>
3Date: Fri, 3 Dec 2021 11:44:56 +0000
4Subject: [PATCH 09/14] perf/arm-cmn: Optimise DTM counter reads
5
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
23index 2ae3e92690a7..5fa31ebc1fce 100644
24--- 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--
552.25.1
56