Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1505557
| From | Imre Palik <imrep.amz@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC PATCH v2] perf: honouring the cpuid for number of fixed counters in hypervisors |
| Date | 2016-10-21 10:20 +0200 |
| Message-ID | <suDdv-2Xg-1@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
From: Imre Palik <imrep@amazon.de>
perf doesn't seem to honour the number of fixed counters specified by cpuid
leaf 0xa. It always assume that Intel CPUs have at least 3 fixed counters.
So if some of the fixed counters are masked out by the hypervisor, it still
tries to check/set them.
This patch makes perf behave nicer when the kernel is running under a
hypervisor that doesn't expose all the counters.
This patch contains some ideas from Matt Wilson.
Signed-off-by: Imre Palik <imrep@amazon.de>
Cc: Matt Wilson <msw@amazon.com>
Cc: David Woodhouse <dwmw@amazon.co.uk>
---
arch/x86/events/intel/core.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index a3a9eb8..e06d071 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3607,10 +3607,14 @@ __init int intel_pmu_init(void)
/*
* Quirk: v2 perfmon does not report fixed-purpose events, so
- * assume at least 3 events:
+ * assume at least 3 events, when not running in a hypervisor:
*/
- if (version > 1)
- x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
+ if (version > 1) {
+ if (static_cpu_has(X86_FEATURE_HYPERVISOR))
+ x86_pmu.num_counters_fixed = edx.split.num_counters_fixed;
+ else
+ x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
+ }
if (boot_cpu_has(X86_FEATURE_PDCM)) {
u64 capabilities;
--
2.10.1
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[RFC PATCH v2] perf: honouring the cpuid for number of fixed counters in hypervisors Imre Palik <imrep.amz@gmail.com> - 2016-10-21 10:20 +0200 Re: [RFC PATCH v2] perf: honouring the cpuid for number of fixed counters in hypervisors Andi Kleen <ak@linux.intel.com> - 2016-10-24 19:00 +0200 Re: [RFC PATCH v2] perf: honouring the cpuid for number of fixed counters in hypervisors Peter Zijlstra <peterz@infradead.org> - 2016-10-26 11:30 +0200
csiph-web