perf/x86: Allow for architecture specific RDPMC indexes
authorJacob Shin <jacob.shin@amd.com>
Wed, 6 Feb 2013 17:26:28 +0000 (11:26 -0600)
committerIngo Molnar <mingo@kernel.org>
Wed, 6 Feb 2013 18:45:24 +0000 (19:45 +0100)
Similar to config_base and event_base, allow architecture
specific RDPMC ECX values.

Signed-off-by: Jacob Shin <jacob.shin@amd.com>
Acked-by: Stephane Eranian <eranian@google.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1360171589-6381-6-git-send-email-jacob.shin@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/cpu/perf_event.c
arch/x86/kernel/cpu/perf_event.h
arch/x86/kernel/cpu/perf_event_amd.c

index c0df5ed2e048c8bf636ac7de13237c1f8a143d69..bf0f01aea99449e53a87f092a84b3263263da911 100644 (file)
@@ -829,7 +829,7 @@ static inline void x86_assign_hw_event(struct perf_event *event,
        } else {
                hwc->config_base = x86_pmu_config_addr(hwc->idx);
                hwc->event_base  = x86_pmu_event_addr(hwc->idx);
-               hwc->event_base_rdpmc = hwc->idx;
+               hwc->event_base_rdpmc = x86_pmu_rdpmc_index(hwc->idx);
        }
 }
 
index a7f06a90d2e740b8d4036a54bc664885cc4fd6f5..7f5c75c2afdd9552653ffd7c9babb8c871669b05 100644 (file)
@@ -326,6 +326,7 @@ struct x86_pmu {
        unsigned        eventsel;
        unsigned        perfctr;
        int             (*addr_offset)(int index, bool eventsel);
+       int             (*rdpmc_index)(int index);
        u64             (*event_map)(int);
        int             max_events;
        int             num_counters;
@@ -459,6 +460,11 @@ static inline unsigned int x86_pmu_event_addr(int index)
                                  x86_pmu.addr_offset(index, false) : index);
 }
 
+static inline int x86_pmu_rdpmc_index(int index)
+{
+       return x86_pmu.rdpmc_index ? x86_pmu.rdpmc_index(index) : index;
+}
+
 int x86_setup_perfctr(struct perf_event *event);
 
 int x86_pmu_hw_config(struct perf_event *event);
index b60f31caeda0f39098b7ef84e1abdb8ab28e0abd..05462f0432d50d17e6658d9e59d1a973b5021310 100644 (file)
@@ -173,6 +173,11 @@ static inline int amd_pmu_addr_offset(int index, bool eventsel)
        return offset;
 }
 
+static inline int amd_pmu_rdpmc_index(int index)
+{
+       return index;
+}
+
 static int amd_pmu_hw_config(struct perf_event *event)
 {
        int ret;
@@ -620,6 +625,7 @@ static __initconst const struct x86_pmu amd_pmu = {
        .eventsel               = MSR_K7_EVNTSEL0,
        .perfctr                = MSR_K7_PERFCTR0,
        .addr_offset            = amd_pmu_addr_offset,
+       .rdpmc_index            = amd_pmu_rdpmc_index,
        .event_map              = amd_pmu_event_map,
        .max_events             = ARRAY_SIZE(amd_perfmon_event_map),
        .num_counters           = AMD64_NUM_COUNTERS,