diff --git a/arch/arm64/kernel/include/arch-perfctr.h b/arch/arm64/kernel/include/arch-perfctr.h index 0e73b499..eefdbcef 100644 --- a/arch/arm64/kernel/include/arch-perfctr.h +++ b/arch/arm64/kernel/include/arch-perfctr.h @@ -29,6 +29,9 @@ struct arm_pmu { int (*get_event_idx)(int num_events, unsigned long used_mask, unsigned long config); int (*map_event)(uint32_t, uint64_t); + int (*map_hw_event)(uint64_t config); + int (*map_cache_event)(uint64_t config); + int (*map_raw_event)(uint64_t config); void (*enable_user_access_pmu_regs)(void); void (*disable_user_access_pmu_regs)(void); struct per_cpu_arm_pmu *per_cpu; diff --git a/arch/arm64/kernel/perfctr.c b/arch/arm64/kernel/perfctr.c index c3448431..493f6d82 100644 --- a/arch/arm64/kernel/perfctr.c +++ b/arch/arm64/kernel/perfctr.c @@ -86,18 +86,10 @@ void arm64_disable_user_access_pmu_regs(void) cpu_pmu.disable_user_access_pmu_regs(); } -extern unsigned int *arm64_march_perfmap; - static int __ihk_mc_perfctr_init(int counter, uint32_t type, uint64_t config, int mode) { int ret = -1; unsigned long config_base = 0; - int mapping; - - mapping = cpu_pmu.map_event(type, config); - if (mapping < 0) { - return mapping; - } ret = cpu_pmu.disable_counter(counter); if (ret < 0) { @@ -113,7 +105,7 @@ static int __ihk_mc_perfctr_init(int counter, uint32_t type, uint64_t config, in if (ret) { return ret; } - config_base |= (unsigned long)mapping; + config_base |= config; cpu_pmu.write_evtype(counter, config_base); return ret; } diff --git a/arch/arm64/kernel/perfctr_armv8pmu.c b/arch/arm64/kernel/perfctr_armv8pmu.c index ad660179..44727e47 100644 --- a/arch/arm64/kernel/perfctr_armv8pmu.c +++ b/arch/arm64/kernel/perfctr_armv8pmu.c @@ -363,6 +363,23 @@ static int armv8_pmuv3_map_event(uint32_t type, uint64_t config) return __armv8_pmuv3_map_event(type, config, NULL, NULL); } + +static int armv8_pmuv3_map_hw_event(uint64_t config) +{ + return __armv8_pmuv3_map_event(PERF_TYPE_HARDWARE, config, NULL, NULL); +} + + +static int armv8_pmuv3_map_cache_event(uint64_t config) +{ + return __armv8_pmuv3_map_event(PERF_TYPE_HW_CACHE, config, NULL, NULL); +} + +static int armv8_pmuv3_map_raw_event(uint64_t config) +{ + return __armv8_pmuv3_map_event(PERF_TYPE_RAW, config, NULL, NULL); +} + /* @ref.impl linux-v4.15-rc3 arch/arm64/kernel/perf_event.c */ static inline uint32_t armv8pmu_pmcr_read(void) { @@ -741,6 +758,9 @@ int armv8pmu_init(struct arm_pmu* cpu_pmu) cpu_pmu->write_evtype = armv8pmu_write_evtype; cpu_pmu->get_event_idx = armv8pmu_get_event_idx; cpu_pmu->map_event = armv8_pmuv3_map_event; + cpu_pmu->map_hw_event = armv8_pmuv3_map_hw_event; + cpu_pmu->map_cache_event = armv8_pmuv3_map_cache_event; + cpu_pmu->map_raw_event = armv8_pmuv3_map_raw_event; cpu_pmu->enable_user_access_pmu_regs = armv8pmu_enable_user_access_pmu_regs; cpu_pmu->disable_user_access_pmu_regs = diff --git a/ihk b/ihk index 9a7bb111..9a15ade2 160000 --- a/ihk +++ b/ihk @@ -1 +1 @@ -Subproject commit 9a7bb111e7806c599ad01510334a8b8650685444 +Subproject commit 9a15ade2abc344b37797a6124769992cb7d80226 diff --git a/kernel/syscall.c b/kernel/syscall.c index 618d8640..54570f2b 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -4094,7 +4094,7 @@ static int mc_perf_event_alloc(struct mc_perf_event **out, extra_config = ihk_mc_hw_cache_extra_reg_map(attr->config); break; case PERF_TYPE_RAW : - val = attr->config; + val = ihk_mc_raw_event_map(attr->config); break; default: diff --git a/lib/include/ihk/cpu.h b/lib/include/ihk/cpu.h index 27767b9e..711e19d3 100644 --- a/lib/include/ihk/cpu.h +++ b/lib/include/ihk/cpu.h @@ -86,6 +86,7 @@ unsigned long ihk_mc_get_extra_reg_event(int id); unsigned long ihk_mc_hw_event_map(unsigned long hw_event); unsigned long ihk_mc_hw_cache_event_map(unsigned long hw_cache_event); unsigned long ihk_mc_hw_cache_extra_reg_map(unsigned long hw_cache_event); +unsigned long ihk_mc_raw_event_map(unsigned long raw_event); /* returns the 'prev' argument of the call that caused the switch to the context returned. */ void *ihk_mc_switch_context(ihk_mc_kernel_context_t *old_ctx,