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 16:32:07 -0500 |
commit | 3ced10a0f426e5ac919f9e19d61a047a6ed60490 (patch) | |
tree | 75908c5e012dc340b3fe41198d3f02fce7b3a930 | |
parent | 1c29aa44065a37888e91c3396ee17332e8a556aa (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 b7710a59672c..669d385c500b 100644 --- a/arch/arm64/include/asm/pmu.h +++ b/arch/arm64/include/asm/pmu.h @@ -65,6 +65,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 cce18c85d2e8..7c7dfe48d0f2 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -634,6 +634,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); @@ -648,6 +658,7 @@ static void __init armpmu_init(struct arm_pmu *armpmu) .start = armpmu_start, .stop = armpmu_stop, .read = armpmu_read, + .event_idx = armpmu_event_idx, }; } @@ -1378,6 +1389,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; |