Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 1 | From 2919ec562ca976a0ae5f70b264379b3d45abdaf5 Mon Sep 17 00:00:00 2001 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 2 | From: Robin Murphy <robin.murphy@arm.com> |
| 3 | Date: Fri, 3 Dec 2021 11:44:56 +0000 |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 4 | Subject: [PATCH 21/40] perf/arm-cmn: Optimise DTM counter reads |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 5 | |
| 6 | When multiple nodes of the same type are connected to the same XP |
| 7 | (particularly in CAL configurations), it seems that they are likely |
| 8 | to be consecutive in logical ID. Therefore, we're likely to gain a |
| 9 | small benefit from an easy tweak to optimise out consecutive reads |
| 10 | of the same set of DTM counters for an aggregated event. |
| 11 | |
| 12 | Signed-off-by: Robin Murphy <robin.murphy@arm.com> |
| 13 | Link: https://lore.kernel.org/r/7777d77c2df17693cd3dabb6e268906e15238d82.1638530442.git.robin.murphy@arm.com |
| 14 | Signed-off-by: Will Deacon <will@kernel.org> |
| 15 | |
| 16 | Upstream-Status: Backport [https://lore.kernel.org/r/7777d77c2df17693cd3dabb6e268906e15238d82.1638530442.git.robin.murphy@arm.com] |
| 17 | Signed-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 | |
| 22 | diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 23 | index 8b98ca9666d0..005a0d83bcac 100644 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 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 | -- |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 55 | 2.34.1 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 56 | |