Skip to content

Commit a428eb4

Browse files
rmurphy-armwilldeacon
authored andcommitted
Partially revert "perf/arm-cmn: Optimise DTC counter accesses"
It turns out the optimisation implemented by commit 4f2c387 is totally broken, since all the places that consume hw->dtcs_used for events other than cycle count are still not expecting it to be sparsely populated, and fail to read all the relevant DTC counters correctly if so. If implemented correctly, the optimisation potentially saves up to 3 register reads per event update, which is reasonably significant for events targeting a single node, but still not worth a massive amount of additional code complexity overall. Getting it right within the current design looks a fair bit more involved than it was ever intended to be, so let's just make a functional revert which restores the old behaviour while still backporting easily. Fixes: 4f2c387 ("perf/arm-cmn: Optimise DTC counter accesses") Reported-by: Ilkka Koskinen <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/b41bb4ed7283c3d8400ce5cf5e6ec94915e6750f.1674498637.git.robin.murphy@arm.com Signed-off-by: Will Deacon <[email protected]>
1 parent 68a63a4 commit a428eb4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/perf/arm-cmn.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,6 @@ static int arm_cmn_event_init(struct perf_event *event)
15761576
hw->dn++;
15771577
continue;
15781578
}
1579-
hw->dtcs_used |= arm_cmn_node_to_xp(cmn, dn)->dtc;
15801579
hw->num_dns++;
15811580
if (bynodeid)
15821581
break;
@@ -1589,6 +1588,12 @@ static int arm_cmn_event_init(struct perf_event *event)
15891588
nodeid, nid.x, nid.y, nid.port, nid.dev, type);
15901589
return -EINVAL;
15911590
}
1591+
/*
1592+
* Keep assuming non-cycles events count in all DTC domains; turns out
1593+
* it's hard to make a worthwhile optimisation around this, short of
1594+
* going all-in with domain-local counter allocation as well.
1595+
*/
1596+
hw->dtcs_used = (1U << cmn->num_dtcs) - 1;
15921597

15931598
return arm_cmn_validate_group(cmn, event);
15941599
}

0 commit comments

Comments
 (0)