perf pmu: Add override support for event list CPUID
authorAndi Kleen <ak@linux.intel.com>
Thu, 15 Sep 2016 22:24:46 +0000 (15:24 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 4 Oct 2016 00:35:46 +0000 (21:35 -0300)
Add a PERF_CPUID variable to override the CPUID of the current CPU
(within the current architecture). This is useful for testing, so that
all event lists can be tested on a single system.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/1473978296-20712-10-git-send-email-sukadev@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/pmu.c

index 9dc3506d23fc8a9735d0d04db8700f0a0edc26c9..79242cf9bb79937a2a0ff172e23923443e111b9e 100644 (file)
@@ -501,10 +501,16 @@ static void pmu_add_cpu_aliases(struct list_head *head)
        struct pmu_event *pe;
        char *cpuid;
 
-       cpuid = get_cpuid_str();
+       cpuid = getenv("PERF_CPUID");
+       if (cpuid)
+               cpuid = strdup(cpuid);
+       if (!cpuid)
+               cpuid = get_cpuid_str();
        if (!cpuid)
                return;
 
+       pr_debug("Using CPUID %s\n", cpuid);
+
        i = 0;
        while (1) {
                map = &pmu_events_map[i++];