Skip to content

Commit 539707c

Browse files
zhangshkwilldeacon
authored andcommitted
arm64: perf: Correct the event index in sysfs
When PMU event ID is equal or greater than 0x4000, it will be reduced by 0x4000 and it is not the raw number in the sysfs. Let's correct it and obtain the raw event ID. Before this patch: cat /sys/bus/event_source/devices/armv8_pmuv3_0/events/sample_feed event=0x001 After this patch: cat /sys/bus/event_source/devices/armv8_pmuv3_0/events/sample_feed event=0x4001 Signed-off-by: Shaokun Zhang <[email protected]> Cc: Will Deacon <[email protected]> Cc: Mark Rutland <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] [will: fixed formatting of 'if' condition] Signed-off-by: Will Deacon <[email protected]>
1 parent f011856 commit 539707c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

arch/arm64/kernel/perf_event.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ armv8pmu_events_sysfs_show(struct device *dev,
155155

156156
pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
157157

158-
return sprintf(page, "event=0x%03llx\n", pmu_attr->id);
158+
return sprintf(page, "event=0x%04llx\n", pmu_attr->id);
159159
}
160160

161161
#define ARMV8_EVENT_ATTR(name, config) \
@@ -244,10 +244,13 @@ armv8pmu_event_attr_is_visible(struct kobject *kobj,
244244
test_bit(pmu_attr->id, cpu_pmu->pmceid_bitmap))
245245
return attr->mode;
246246

247-
pmu_attr->id -= ARMV8_PMUV3_EXT_COMMON_EVENT_BASE;
248-
if (pmu_attr->id < ARMV8_PMUV3_MAX_COMMON_EVENTS &&
249-
test_bit(pmu_attr->id, cpu_pmu->pmceid_ext_bitmap))
250-
return attr->mode;
247+
if (pmu_attr->id >= ARMV8_PMUV3_EXT_COMMON_EVENT_BASE) {
248+
u64 id = pmu_attr->id - ARMV8_PMUV3_EXT_COMMON_EVENT_BASE;
249+
250+
if (id < ARMV8_PMUV3_MAX_COMMON_EVENTS &&
251+
test_bit(id, cpu_pmu->pmceid_ext_bitmap))
252+
return attr->mode;
253+
}
251254

252255
return 0;
253256
}

0 commit comments

Comments
 (0)