提交 67b4305a 编写于 作者: M Mark Rutland 提交者: Will Deacon

arm: perf: use IDR types for CPU PMUs

For systems with heterogeneous CPUs (e.g. big.LITTLE systems) the PMUs
can be different in each cluster, and not all events can be migrated
between clusters. To allow userspace to deal with this, it must be
possible to address each PMU independently.

This patch changes PMUs to be registered with dynamic (IDR) types,
allowing them to be targeted individually. Each PMU's type can be found
in ${SYSFS_ROOT}/bus/event_source/devices/${PMU_NAME}/type.

From userspace, raw events can be targeted at a specific PMU:
$ perf stat -e ${PMU_NAME}/config=V,config1=V1,.../

Doing this does not break existing tools which use existing perf types:
when perf core can't find a PMU of matching type (in perf_init_event)
it'll iterate over the set of all PMUs. If a compatible PMU exists,
it'll be found eventually. If more than one compatible PMU exists, the
event will be handled by whichever PMU happens to be earlier in the pmus
list (which currently will be the last compatible PMU registered).
Signed-off-by: NMark Rutland <mark.rutland@arm.com>
Reviewed-by: NWill Deacon <will.deacon@arm.com>
Signed-off-by: NWill Deacon <will.deacon@arm.com>
上级 548a86ca
...@@ -77,8 +77,12 @@ armpmu_map_event(struct perf_event *event, ...@@ -77,8 +77,12 @@ armpmu_map_event(struct perf_event *event,
u32 raw_event_mask) u32 raw_event_mask)
{ {
u64 config = event->attr.config; u64 config = event->attr.config;
int type = event->attr.type;
switch (event->attr.type) { if (type == event->pmu->type)
return armpmu_map_raw_event(raw_event_mask, config);
switch (type) {
case PERF_TYPE_HARDWARE: case PERF_TYPE_HARDWARE:
return armpmu_map_hw_event(event_map, config); return armpmu_map_hw_event(event_map, config);
case PERF_TYPE_HW_CACHE: case PERF_TYPE_HW_CACHE:
......
...@@ -311,7 +311,7 @@ static int cpu_pmu_device_probe(struct platform_device *pdev) ...@@ -311,7 +311,7 @@ static int cpu_pmu_device_probe(struct platform_device *pdev)
} }
cpu_pmu_init(cpu_pmu); cpu_pmu_init(cpu_pmu);
ret = armpmu_register(cpu_pmu, PERF_TYPE_RAW); ret = armpmu_register(cpu_pmu, -1);
if (!ret) if (!ret)
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册