diff options
author | Yogesh Tillu <yogesh.tillu@linaro.org> | 2015-08-11 12:42:19 +0530 |
---|---|---|
committer | Gary S. Robertson <gary.robertson@linaro.org> | 2015-09-09 13:37:04 -0500 |
commit | 2e1b4f1186785dd153f7d75921b922c882f4832c (patch) | |
tree | 8ba41438667aefe7a0bed34a5432363d3c768bf0 | |
parent | 323fd216e723d3e03ccb7030cc27d5e3d21ec4df (diff) |
ARM64: perf: add support for accessing counters from userspace with mmap way
This patch adds support for accessing perf hw counters
from userspace with usage of perf_event_mmap_page.
Signed-off-by: Yogesh Tillu <yogesh.tillu@linaro.org>
Signed-off-by: Gary S. Robertson <gary.robertson@linaro.org>
-rw-r--r-- | arch/arm64/include/asm/pmu.h | 1 | ||||
-rw-r--r-- | arch/arm64/kernel/perf_event.c | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/arch/arm64/include/asm/pmu.h b/arch/arm64/include/asm/pmu.h index e6f087806aaf..def95ff73d2b 100644 --- a/arch/arm64/include/asm/pmu.h +++ b/arch/arm64/include/asm/pmu.h @@ -64,6 +64,7 @@ struct arm_pmu { u64 max_period; struct platform_device *plat_device; struct pmu_hw_events *(*get_hw_events)(void); + int attr_rdpmc; }; #define to_arm_pmu(p) (container_of(p, struct arm_pmu, pmu)) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index 70dcde67a808..b84c9366e332 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -607,6 +607,16 @@ static void armpmu_disable(struct pmu *pmu) armpmu->stop(); } +static int armpmu_event_idx(struct perf_event *event) +{ + int idx = event->hw.idx; + + if (!cpu_pmu->attr_rdpmc) + return 0; + + return idx + 1; +} + static void __init armpmu_init(struct arm_pmu *armpmu) { atomic_set(&armpmu->active_events, 0); @@ -621,6 +631,7 @@ static void __init armpmu_init(struct arm_pmu *armpmu) .start = armpmu_start, .stop = armpmu_stop, .read = armpmu_read, + .event_idx = armpmu_event_idx, }; } @@ -1309,6 +1320,11 @@ static struct pmu_hw_events *armpmu_get_cpu_events(void) return this_cpu_ptr(&cpu_hw_events); } +void arch_perf_update_userpage(struct perf_event_mmap_page *userpg, u64 now) +{ + userpg->cap_user_rdpmc = cpu_pmu->attr_rdpmc; +} + static void __init cpu_pmu_init(struct arm_pmu *armpmu) { int cpu; |