summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/files/perf-x86-intel-Use-rdmsrl_safe-when-initializing-RAP.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-kernel/linux/files/perf-x86-intel-Use-rdmsrl_safe-when-initializing-RAP.patch')
-rw-r--r--recipes-kernel/linux/files/perf-x86-intel-Use-rdmsrl_safe-when-initializing-RAP.patch80
1 files changed, 80 insertions, 0 deletions
diff --git a/recipes-kernel/linux/files/perf-x86-intel-Use-rdmsrl_safe-when-initializing-RAP.patch b/recipes-kernel/linux/files/perf-x86-intel-Use-rdmsrl_safe-when-initializing-RAP.patch
new file mode 100644
index 0000000..6b29970
--- /dev/null
+++ b/recipes-kernel/linux/files/perf-x86-intel-Use-rdmsrl_safe-when-initializing-RAP.patch
@@ -0,0 +1,80 @@
1From 24223657806a0ebd0ae5c9caaf7b021091889cf2 Mon Sep 17 00:00:00 2001
2From: Venkatesh Srinivas <venkateshs@google.com>
3Date: Thu, 13 Mar 2014 12:36:26 -0700
4Subject: [PATCH] perf/x86/intel: Use rdmsrl_safe() when initializing RAPL PMU
5
6CPUs which should support the RAPL counters according to
7Family/Model/Stepping may still issue #GP when attempting to access
8the RAPL MSRs. This may happen when Linux is running under KVM and
9we are passing-through host F/M/S data, for example. Use rdmsrl_safe
10to first access the RAPL_POWER_UNIT MSR; if this fails, do not
11attempt to use this PMU.
12
13Signed-off-by: Venkatesh Srinivas <venkateshs@google.com>
14Signed-off-by: Peter Zijlstra <peterz@infradead.org>
15Link: http://lkml.kernel.org/r/1394739386-22260-1-git-send-email-venkateshs@google.com
16Cc: zheng.z.yan@intel.com
17Cc: eranian@google.com
18Cc: ak@linux.intel.com
19Cc: linux-kernel@vger.kernel.org
20[ The patch also silently fixes another bug: rapl_pmu_init() didn't handle the memory alloc failure case previously. ]
21Signed-off-by: Ingo Molnar <mingo@kernel.org>
22Upstream-Status: Backport
23---
24 arch/x86/kernel/cpu/perf_event_intel_rapl.c | 12 +++++++++---
25 1 file changed, 9 insertions(+), 3 deletions(-)
26
27diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
28index 4b9a9e9..7c87424 100644
29--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
30+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
31@@ -535,6 +535,7 @@ static int rapl_cpu_prepare(int cpu)
32 struct rapl_pmu *pmu = per_cpu(rapl_pmu, cpu);
33 int phys_id = topology_physical_package_id(cpu);
34 u64 ms;
35+ u64 msr_rapl_power_unit_bits;
36
37 if (pmu)
38 return 0;
39@@ -542,6 +543,9 @@ static int rapl_cpu_prepare(int cpu)
40 if (phys_id < 0)
41 return -1;
42
43+ if (!rdmsrl_safe(MSR_RAPL_POWER_UNIT, &msr_rapl_power_unit_bits))
44+ return -1;
45+
46 pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu));
47 if (!pmu)
48 return -1;
49@@ -555,8 +559,7 @@ static int rapl_cpu_prepare(int cpu)
50 *
51 * we cache in local PMU instance
52 */
53- rdmsrl(MSR_RAPL_POWER_UNIT, pmu->hw_unit);
54- pmu->hw_unit = (pmu->hw_unit >> 8) & 0x1FULL;
55+ pmu->hw_unit = (msr_rapl_power_unit_bits >> 8) & 0x1FULL;
56 pmu->pmu = &rapl_pmu_class;
57
58 /*
59@@ -677,7 +680,9 @@ static int __init rapl_pmu_init(void)
60 cpu_notifier_register_begin();
61
62 for_each_online_cpu(cpu) {
63- rapl_cpu_prepare(cpu);
64+ ret = rapl_cpu_prepare(cpu);
65+ if (ret)
66+ goto out;
67 rapl_cpu_init(cpu);
68 }
69
70@@ -700,6 +705,7 @@ static int __init rapl_pmu_init(void)
71 hweight32(rapl_cntr_mask),
72 ktime_to_ms(pmu->timer_interval));
73
74+out:
75 put_online_cpus();
76
77 return 0;
78--
791.9.0
80