linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] perf/x86: Use KERN_INFO when checking PMU fails on virtual environment
@ 2014-09-25  3:55 Wei Huang
  2014-09-30  4:19 ` Wei Huang
  2014-10-03  5:28 ` [tip:perf/core] perf/x86: Tone down kernel messages when the PMU check fails in a " tip-bot for Wei Huang
  0 siblings, 2 replies; 6+ messages in thread
From: Wei Huang @ 2014-09-25  3:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: x86, tglx, mingo, hpa, Wei Huang

PMU checking can fail due to various reasons. On native machine,
this is mostly caused by faulty hardware and it is reasonable to
use KERN_ERR in reporting. However, when kernel is running on
virtualized environment, this checking can fail if virtual PMU is
not supported (e.g. KVM on AMD host). It is annoying to see
an error message on splash screen, even though we know such failure
is benign on virtualized environment.

This patch checks if kernel is running in virtualized environment.
If so, it will use KERN_INFO in reporting. This patch was tested
successfully on KVM.

Signed-off-by: Wei Huang <wei@redhat.com>
---
 arch/x86/kernel/cpu/perf_event.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 918d75f..16c7302 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -243,7 +243,8 @@ static bool check_hw_exists(void)
 
 msr_fail:
 	printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n");
-	printk(KERN_ERR "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
+	printk(boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR
+	       "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
 
 	return false;
 }
-- 
1.9.3


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

* Re: [PATCH 1/1] perf/x86: Use KERN_INFO when checking PMU fails on virtual environment
  2014-09-25  3:55 [PATCH 1/1] perf/x86: Use KERN_INFO when checking PMU fails on virtual environment Wei Huang
@ 2014-09-30  4:19 ` Wei Huang
  2014-10-03  5:28 ` [tip:perf/core] perf/x86: Tone down kernel messages when the PMU check fails in a " tip-bot for Wei Huang
  1 sibling, 0 replies; 6+ messages in thread
From: Wei Huang @ 2014-09-30  4:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: x86, tglx, mingo, hpa

Hi Ingo, tglx and hpa,

Any comment on this patch? Thanks.

-Wei

On 09/24/2014 10:55 PM, Wei Huang wrote:
> PMU checking can fail due to various reasons. On native machine,
> this is mostly caused by faulty hardware and it is reasonable to
> use KERN_ERR in reporting. However, when kernel is running on
> virtualized environment, this checking can fail if virtual PMU is
> not supported (e.g. KVM on AMD host). It is annoying to see
> an error message on splash screen, even though we know such failure
> is benign on virtualized environment.
>
> This patch checks if kernel is running in virtualized environment.
> If so, it will use KERN_INFO in reporting. This patch was tested
> successfully on KVM.
>
> Signed-off-by: Wei Huang <wei@redhat.com>
> ---
>   arch/x86/kernel/cpu/perf_event.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
> index 918d75f..16c7302 100644
> --- a/arch/x86/kernel/cpu/perf_event.c
> +++ b/arch/x86/kernel/cpu/perf_event.c
> @@ -243,7 +243,8 @@ static bool check_hw_exists(void)
>
>   msr_fail:
>   	printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n");
> -	printk(KERN_ERR "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
> +	printk(boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR
> +	       "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
>
>   	return false;
>   }
>

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

* [tip:perf/core] perf/x86: Tone down kernel messages when the PMU check fails in a virtual environment
  2014-09-25  3:55 [PATCH 1/1] perf/x86: Use KERN_INFO when checking PMU fails on virtual environment Wei Huang
  2014-09-30  4:19 ` Wei Huang
@ 2014-10-03  5:28 ` tip-bot for Wei Huang
  2014-10-06 21:10   ` Andy Lutomirski
  1 sibling, 1 reply; 6+ messages in thread
From: tip-bot for Wei Huang @ 2014-10-03  5:28 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, acme, wei, tglx

Commit-ID:  cc6cd47e7395bc05c5077009808b820633eb3f18
Gitweb:     http://git.kernel.org/tip/cc6cd47e7395bc05c5077009808b820633eb3f18
Author:     Wei Huang <wei@redhat.com>
AuthorDate: Wed, 24 Sep 2014 22:55:14 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 3 Oct 2014 06:04:41 +0200

perf/x86: Tone down kernel messages when the PMU check fails in a virtual environment

PMU checking can fail due to various reasons. On native machine, this
is mostly caused by faulty hardware and it is reasonable to use
KERN_ERR in reporting. However, when kernel is running on virtualized
environment, this checking can fail if virtual PMU is not supported
(e.g. KVM on AMD host). It is annoying to see an error message on
splash screen, even though we know such failure is benign on
virtualized environment.

This patch checks if the kernel is running in a virtualized environment.
If so, it will use KERN_INFO in reporting, which reduces the syslog
priority of them. This patch was tested successfully on KVM.

Signed-off-by: Wei Huang <wei@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Link: http://lkml.kernel.org/r/1411617314-24659-1-git-send-email-wei@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/perf_event.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 918d75f..16c7302 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -243,7 +243,8 @@ static bool check_hw_exists(void)
 
 msr_fail:
 	printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n");
-	printk(KERN_ERR "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
+	printk(boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR
+	       "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
 
 	return false;
 }

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

* Re: [tip:perf/core] perf/x86:  Tone down kernel messages when the PMU check fails in a virtual environment
  2014-10-03  5:28 ` [tip:perf/core] perf/x86: Tone down kernel messages when the PMU check fails in a " tip-bot for Wei Huang
@ 2014-10-06 21:10   ` Andy Lutomirski
  2014-10-07 12:47     ` Peter Zijlstra
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Lutomirski @ 2014-10-06 21:10 UTC (permalink / raw)
  To: mingo, hpa, linux-kernel, peterz, tglx, wei, acme, linux-tip-commits

On 10/02/2014 10:28 PM, tip-bot for Wei Huang wrote:
> Commit-ID:  cc6cd47e7395bc05c5077009808b820633eb3f18
> Gitweb:     http://git.kernel.org/tip/cc6cd47e7395bc05c5077009808b820633eb3f18
> Author:     Wei Huang <wei@redhat.com>
> AuthorDate: Wed, 24 Sep 2014 22:55:14 -0500
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Fri, 3 Oct 2014 06:04:41 +0200
> 
> perf/x86: Tone down kernel messages when the PMU check fails in a virtual environment
> 
> PMU checking can fail due to various reasons. On native machine, this
> is mostly caused by faulty hardware and it is reasonable to use
> KERN_ERR in reporting. However, when kernel is running on virtualized
> environment, this checking can fail if virtual PMU is not supported
> (e.g. KVM on AMD host). It is annoying to see an error message on
> splash screen, even though we know such failure is benign on
> virtualized environment.
> 
> This patch checks if the kernel is running in a virtualized environment.
> If so, it will use KERN_INFO in reporting, which reduces the syslog
> priority of them. This patch was tested successfully on KVM.
> 
> Signed-off-by: Wei Huang <wei@redhat.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Link: http://lkml.kernel.org/r/1411617314-24659-1-git-send-email-wei@redhat.com
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> ---
>  arch/x86/kernel/cpu/perf_event.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
> index 918d75f..16c7302 100644
> --- a/arch/x86/kernel/cpu/perf_event.c
> +++ b/arch/x86/kernel/cpu/perf_event.c
> @@ -243,7 +243,8 @@ static bool check_hw_exists(void)
>  
>  msr_fail:
>  	printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n");
> -	printk(KERN_ERR "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
> +	printk(boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR
> +	       "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
>  

This is bogus.  String concatenation doesn't work like that.

Try "%sFailed...", boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_ERR :
KERN_INFO), etc.

--Andy

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

* Re: [tip:perf/core] perf/x86:  Tone down kernel messages when the PMU check fails in a virtual environment
  2014-10-06 21:10   ` Andy Lutomirski
@ 2014-10-07 12:47     ` Peter Zijlstra
  2014-10-28 11:08       ` [tip:perf/urgent] perf: Fix bogus kernel printk tip-bot for Peter Zijlstra (Intel)
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2014-10-07 12:47 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: mingo, hpa, linux-kernel, tglx, wei, acme, linux-tip-commits

On Mon, Oct 06, 2014 at 02:10:23PM -0700, Andy Lutomirski wrote:
> On 10/02/2014 10:28 PM, tip-bot for Wei Huang wrote:
> >  msr_fail:
> >  	printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n");
> > -	printk(KERN_ERR "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
> > +	printk(boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR
> > +	       "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
> >  
> 
> This is bogus.  String concatenation doesn't work like that.
> 
> Try "%sFailed...", boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_ERR :
> KERN_INFO), etc.

Haha, indeed. The hypervisor message is empty in this case. Wei, test
this much? ;-)

---
Subject: perf: Fix bogus kernel printk

Andy spotted the fail in what was intended as a conditional printk
level.

Fixes: cc6cd47e7395 ("perf/x86: Tone down kernel messages when the PMU check fails in a virtual environment")
Reported-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/kernel/cpu/perf_event.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -243,8 +243,9 @@ static bool check_hw_exists(void)
 
 msr_fail:
 	printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n");
-	printk(boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR
-	       "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
+	printk("%sFailed to access perfctr msr (MSR %x is %Lx)\n",
+		boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR,
+		reg, val_new);
 
 	return false;
 }

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

* [tip:perf/urgent] perf: Fix bogus kernel printk
  2014-10-07 12:47     ` Peter Zijlstra
@ 2014-10-28 11:08       ` tip-bot for Peter Zijlstra (Intel)
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Peter Zijlstra (Intel) @ 2014-10-28 11:08 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, hpa, peterz, tglx, torvalds, linux-kernel, luto, acme

Commit-ID:  65d71fe1375b973083733294795bf2b09d45b3c2
Gitweb:     http://git.kernel.org/tip/65d71fe1375b973083733294795bf2b09d45b3c2
Author:     Peter Zijlstra (Intel) <peterz@infradead.org>
AuthorDate: Tue, 7 Oct 2014 19:07:33 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 28 Oct 2014 10:51:01 +0100

perf: Fix bogus kernel printk

Andy spotted the fail in what was intended as a conditional printk level.

Reported-by: Andy Lutomirski <luto@amacapital.net>
Fixes: cc6cd47e7395 ("perf/x86: Tone down kernel messages when the PMU check fails in a virtual environment")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20141007124757.GH19379@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/perf_event.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 1b8299d..66451a6 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -243,8 +243,9 @@ static bool check_hw_exists(void)
 
 msr_fail:
 	printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n");
-	printk(boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR
-	       "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
+	printk("%sFailed to access perfctr msr (MSR %x is %Lx)\n",
+		boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR,
+		reg, val_new);
 
 	return false;
 }

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

end of thread, other threads:[~2014-10-28 11:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-25  3:55 [PATCH 1/1] perf/x86: Use KERN_INFO when checking PMU fails on virtual environment Wei Huang
2014-09-30  4:19 ` Wei Huang
2014-10-03  5:28 ` [tip:perf/core] perf/x86: Tone down kernel messages when the PMU check fails in a " tip-bot for Wei Huang
2014-10-06 21:10   ` Andy Lutomirski
2014-10-07 12:47     ` Peter Zijlstra
2014-10-28 11:08       ` [tip:perf/urgent] perf: Fix bogus kernel printk tip-bot for Peter Zijlstra (Intel)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).