public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf,x86,p6: Add userspace RDPMC quirk for P6
@ 2014-02-05 10:27 Peter Zijlstra
  2014-02-05 19:16 ` Vince Weaver
  0 siblings, 1 reply; 14+ messages in thread
From: Peter Zijlstra @ 2014-02-05 10:27 UTC (permalink / raw)
  To: junk; +Cc: alan, Ingo Molnar, Stephane Eranian, linux-kernel

Subject: perf,x86,p6: Add userspace RDPMC quirk for P6
From: Peter Zijlstra <peterz@infradead.org>
Date: Wed Feb 5 11:17:46 CET 2014

P6 class machines can die hard when PCE gets enabled due to CPU
errata. The safe way it so disable it by default and keep it disabled.

See errata 26:

http://download.intel.com/design/archives/processors/pro/docs/24268935.pdf

Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Reported-by: Mark Davies <junk@eslaf.co.uk>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
 arch/x86/kernel/cpu/perf_event.c    |    6 +++++-
 arch/x86/kernel/cpu/perf_event.h    |    1 +
 arch/x86/kernel/cpu/perf_event_p6.c |    8 ++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)

--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1521,6 +1521,8 @@ static int __init init_hw_perf_events(vo
 
 	pr_cont("%s PMU driver.\n", x86_pmu.name);
 
+	x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */
+
 	for (quirk = x86_pmu.quirks; quirk; quirk = quirk->next)
 		quirk->func();
 
@@ -1534,7 +1536,6 @@ static int __init init_hw_perf_events(vo
 		__EVENT_CONSTRAINT(0, (1ULL << x86_pmu.num_counters) - 1,
 				   0, x86_pmu.num_counters, 0, 0);
 
-	x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */
 	x86_pmu_format_group.attrs = x86_pmu.format_attrs;
 
 	if (x86_pmu.event_attrs)
@@ -1820,6 +1821,9 @@ static ssize_t set_attr_rdpmc(struct dev
 	if (ret)
 		return ret;
 
+	if (x86_pmu.attr_rdpmc_broken)
+		return -ENOTSUPP;
+
 	if (!!val != !!x86_pmu.attr_rdpmc) {
 		x86_pmu.attr_rdpmc = !!val;
 		smp_call_function(change_rdpmc, (void *)val, 1);
--- a/arch/x86/kernel/cpu/perf_event.h
+++ b/arch/x86/kernel/cpu/perf_event.h
@@ -409,6 +409,7 @@ struct x86_pmu {
 	/*
 	 * sysfs attrs
 	 */
+	int		attr_rdpmc_broken;
 	int		attr_rdpmc;
 	struct attribute **format_attrs;
 	struct attribute **event_attrs;
--- a/arch/x86/kernel/cpu/perf_event_p6.c
+++ b/arch/x86/kernel/cpu/perf_event_p6.c
@@ -231,6 +231,13 @@ static __initconst const struct x86_pmu
 
 };
 
+static __init void p6_pmu_rdpmc_quirk(void)
+{
+	pr_warn("Userspace RDPMC support disabled due to CPU errata\n");
+	x86_pmu.attr_rdpmc_broken = 1;
+	x86_pmu.attr_rdpmc = 0;
+}
+
 __init int p6_pmu_init(void)
 {
 	switch (boot_cpu_data.x86_model) {
@@ -256,6 +263,7 @@ __init int p6_pmu_init(void)
 	memcpy(hw_cache_event_ids, p6_hw_cache_event_ids,
 		sizeof(hw_cache_event_ids));
 
+	x86_add_quirk(p6_pmu_rdpmc_quirk);
 
 	return 0;
 }

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-02-07  7:53 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-05 10:27 [PATCH] perf,x86,p6: Add userspace RDPMC quirk for P6 Peter Zijlstra
2014-02-05 19:16 ` Vince Weaver
2014-02-05 19:20   ` Peter Zijlstra
2014-02-05 19:29     ` Vince Weaver
2014-02-05 19:37       ` Vince Weaver
2014-02-05 19:55         ` Peter Zijlstra
2014-02-05 20:04           ` Vince Weaver
2014-02-05 20:20             ` Peter Zijlstra
2014-02-05 19:53       ` Peter Zijlstra
2014-02-05 19:48     ` Peter Zijlstra
2014-02-06 19:41       ` Mark Davies
2014-02-06 20:38         ` Peter Zijlstra
2014-02-06 22:15           ` Mark Davies
2014-02-07  7:52             ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox