diff options
author | Yogesh Tillu <yogesh.tillu@linaro.org> | 2015-02-04 01:04:27 +0530 |
---|---|---|
committer | Yogesh Tillu <yogesh.tillu@linaro.org> | 2015-09-11 17:34:25 +0530 |
commit | 76537ebc825da8c76185404d1b63bdadd56a38bb (patch) | |
tree | 5e49729efc8da3ea548b6c5ec3a77422c5f64962 | |
parent | 64291f7db5bd8150a74ad2036f1037e6a0428df2 (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>
-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 b31e9a4b6275..b3aa2bf27d77 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, }; } @@ -1380,6 +1391,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; |