Skip to contentSkip to conversation

x86/events: modify error message in virtualized environment

PATCH New Juergen Gross 2 participants 2 messages Aug 1, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/events: modify error message in virtualized environment

It is known that PMU isn't working in some virtualized environments. Modify the message issued in that case to mention why hardware PMU isn't usable instead of reporting it to be broken.

As a side effect this will correct a little bug in the error message:
The error message was meant to be either of level err or info depending on the environment (native or virtualized). As the level is taken from the format string and not the printed string, specifying it via %s and a conditional argument didn't work the way intended.

---
 arch/x86/events/core.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
arch/x86/events/core.c +7 -4
index c17f0de..ba1335d 100644
@@ -262,10 +262,13 @@ static bool check_hw_exists(void)
 	return true;
 
 msr_fail:
-	pr_cont("Broken PMU hardware detected, using software events only.\n");
-	printk("%sFailed to access perfctr msr (MSR %x is %Lx)\n",
-		boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR,
-		reg, val_new);
+	if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) {
+		pr_cont("PMU not available due to virtualization, using software events only.\n");
+	} else {
+		pr_cont("Broken PMU hardware detected, using software events only.\n");
+		pr_err("Failed to access perfctr msr (MSR %x is %Lx)\n",
+		       reg, val_new);
+	}
 
 	return false;
 }
Signature · 1 line
2.6.6
#1 lore raw

[tip:perf/urgent] perf/x86: Modify error message in virtualized environment

perf/x86: Modify error message in virtualized environment
Commit-ID:  005bd0077a79c4bcfe64e7331b275e12f742093f
Gitweb:     http://git.kernel.org/tip/005bd0077a79c4bcfe64e7331b275e12f742093f
Author:     Juergen Gross <[email protected]>
AuthorDate: Mon, 1 Aug 2016 13:37:07 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 1 Aug 2016 14:30:34 +0200

perf/x86: Modify error message in virtualized environment

It is known that PMU isn't working in some virtualized environments.

Modify the message issued in that case to mention why hardware PMU isn't usable instead of reporting it to be broken.

As a side effect this will correct a little bug in the error message:
The error message was meant to be either of level err or info depending on the environment (native or virtualized). As the level is taken from the format string and not the printed string, specifying it via %s and a conditional argument didn't work the way intended.

Cc Alexander Shishkin <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/events/core.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
arch/x86/events/core.c +7 -4
index c17f0de..ba1335d 100644
@@ -262,10 +262,13 @@ static bool check_hw_exists(void)
 	return true;
 
 msr_fail:
-	pr_cont("Broken PMU hardware detected, using software events only.\n");
-	printk("%sFailed to access perfctr msr (MSR %x is %Lx)\n",
-		boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR,
-		reg, val_new);
+	if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) {
+		pr_cont("PMU not available due to virtualization, using software events only.\n");
+	} else {
+		pr_cont("Broken PMU hardware detected, using software events only.\n");
+		pr_err("Failed to access perfctr msr (MSR %x is %Lx)\n",
+		       reg, val_new);
+	}
 
 	return false;
 }