Skip to content

Commit 847eef9

Browse files
rmurphy-armwilldeacon
authored andcommitted
perf/arm-cmn: Optimise DTM counter reads
When multiple nodes of the same type are connected to the same XP (particularly in CAL configurations), it seems that they are likely to be consecutive in logical ID. Therefore, we're likely to gain a small benefit from an easy tweak to optimise out consecutive reads of the same set of DTM counters for an aggregated event. Signed-off-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/7777d77c2df17693cd3dabb6e268906e15238d82.1638530442.git.robin.murphy@arm.com Signed-off-by: Will Deacon <[email protected]>
1 parent 0947c80 commit 847eef9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/perf/arm-cmn.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -690,18 +690,19 @@ static void arm_cmn_pmu_disable(struct pmu *pmu)
690690
static u64 arm_cmn_read_dtm(struct arm_cmn *cmn, struct arm_cmn_hw_event *hw,
691691
bool snapshot)
692692
{
693+
struct arm_cmn_dtm *dtm = NULL;
693694
struct arm_cmn_node *dn;
694-
unsigned int i, offset;
695-
u64 count = 0;
695+
unsigned int i, offset, dtm_idx;
696+
u64 reg, count = 0;
696697

697698
offset = snapshot ? CMN_DTM_PMEVCNTSR : CMN_DTM_PMEVCNT;
698699
for_each_hw_dn(hw, dn, i) {
699-
struct arm_cmn_dtm *dtm = &cmn->dtms[dn->dtm];
700-
int dtm_idx = arm_cmn_get_index(hw->dtm_idx, i);
701-
u64 reg = readq_relaxed(dtm->base + offset);
702-
u16 dtm_count = reg >> (dtm_idx * 16);
703-
704-
count += dtm_count;
700+
if (dtm != &cmn->dtms[dn->dtm]) {
701+
dtm = &cmn->dtms[dn->dtm];
702+
reg = readq_relaxed(dtm->base + offset);
703+
}
704+
dtm_idx = arm_cmn_get_index(hw->dtm_idx, i);
705+
count += (u16)(reg >> (dtm_idx * 16));
705706
}
706707
return count;
707708
}

0 commit comments

Comments
 (0)