Skip to content

Commit 4f2c387

Browse files
rmurphy-armwilldeacon
authored andcommitted
perf/arm-cmn: Optimise DTC counter accesses
In cases where we do know which DTC domain a node belongs to, we can skip initialising or reading the global count in DTCs where we know it won't change. The machinery to achieve that is mostly in place already, so finish hooking it up by converting the vestigial domain tracking to propagate suitable bitmaps all the way through to events. Note that this does not allow allocating such an unused counter to a different event on that DTC, because that is a flippin' nightmare. Signed-off-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/51d930fd945ef51c81f5889ccca055c302b0a1d0.1638530442.git.robin.murphy@arm.com Signed-off-by: Will Deacon <[email protected]>
1 parent 847eef9 commit 4f2c387

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

drivers/perf/arm-cmn.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ struct arm_cmn_node {
193193
u8 occupid_count;
194194
};
195195
/* XP */
196-
int dtc;
196+
u8 dtc;
197197
};
198198
union {
199199
u8 event[4];
@@ -968,14 +968,14 @@ static int arm_cmn_event_init(struct perf_event *event)
968968
if (!hw->dn)
969969
return -EINVAL;
970970
for (dn = hw->dn; dn->type == type; dn++) {
971-
if (!bynodeid) {
972-
hw->num_dns++;
973-
} else if (dn->id != nodeid) {
971+
if (bynodeid && dn->id != nodeid) {
974972
hw->dn++;
975-
} else {
976-
hw->num_dns = 1;
977-
break;
973+
continue;
978974
}
975+
hw->dtcs_used |= arm_cmn_node_to_xp(cmn, dn)->dtc;
976+
hw->num_dns++;
977+
if (bynodeid)
978+
break;
979979
}
980980

981981
if (!hw->num_dns) {
@@ -985,11 +985,6 @@ static int arm_cmn_event_init(struct perf_event *event)
985985
nodeid, nid.x, nid.y, nid.port, nid.dev, type);
986986
return -EINVAL;
987987
}
988-
/*
989-
* By assuming events count in all DTC domains, we cunningly avoid
990-
* needing to know anything about how XPs are assigned to domains.
991-
*/
992-
hw->dtcs_used = (1U << cmn->num_dtcs) - 1;
993988

994989
return arm_cmn_validate_group(event);
995990
}
@@ -1311,6 +1306,7 @@ static int arm_cmn_init_dtcs(struct arm_cmn *cmn)
13111306
{
13121307
struct arm_cmn_node *dn, *xp;
13131308
int dtc_idx = 0;
1309+
u8 dtcs_present = (1 << cmn->num_dtcs) - 1;
13141310

13151311
cmn->dtc = devm_kcalloc(cmn->dev, cmn->num_dtcs, sizeof(cmn->dtc[0]), GFP_KERNEL);
13161312
if (!cmn->dtc)
@@ -1322,8 +1318,7 @@ static int arm_cmn_init_dtcs(struct arm_cmn *cmn)
13221318

13231319
for (dn = cmn->dns; dn->type; dn++) {
13241320
if (dn->type == CMN_TYPE_XP) {
1325-
if (dn->dtc < 0 && cmn->num_dtcs == 1)
1326-
dn->dtc = 0;
1321+
dn->dtc &= dtcs_present;
13271322
continue;
13281323
}
13291324

@@ -1333,8 +1328,8 @@ static int arm_cmn_init_dtcs(struct arm_cmn *cmn)
13331328
if (dn->type == CMN_TYPE_DTC) {
13341329
int err;
13351330
/* We do at least know that a DTC's XP must be in that DTC's domain */
1336-
if (xp->dtc < 0)
1337-
xp->dtc = dtc_idx;
1331+
if (xp->dtc == 0xf)
1332+
xp->dtc = 1 << dtc_idx;
13381333
err = arm_cmn_init_dtc(cmn, dn, dtc_idx++);
13391334
if (err)
13401335
return err;
@@ -1435,7 +1430,7 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
14351430
if (xp->id == (1 << 3))
14361431
cmn->mesh_x = xp->logid;
14371432

1438-
xp->dtc = -1;
1433+
xp->dtc = 0xf;
14391434
xp->dtm = dtm - cmn->dtms;
14401435
arm_cmn_init_dtm(dtm++, xp);
14411436

0 commit comments

Comments
 (0)