From: Peter Zijlstra <peterz@infradead.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Josh Poimboeuf <jpoimboe@redhat.com>,
Borislav Petkov <bp@suse.de>, Andi Kleen <ak@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf/x86: always warn about broken BIOS
Date: Mon, 24 Oct 2016 18:44:24 +0200 [thread overview]
Message-ID: <20161024164424.GU3102@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20161024152736.2635492-1-arnd@arndb.de>
On Mon, Oct 24, 2016 at 05:26:37PM +0200, Arnd Bergmann wrote:
> The intialization function checks for various failure scenarios, but
> unfortunately the compiler gets a little confused about the possible
> combinations, leading to a false-positive build warning when
> -Wmaybe-uninitialized is set:
>
> arch/x86/events/core.c: In function ‘init_hw_perf_events’:
> arch/x86/events/core.c:264:3: warning: ‘reg_fail’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> arch/x86/events/core.c:264:3: warning: ‘val_fail’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> pr_err(FW_BUG "the BIOS has corrupted hw-PMU resources (MSR %x is %Lx)\n",
>
> It seems reasonable to move the check for the broken BIOS a little
> higher in the function, which will lead to the kernel warning about
> both the BIOS and and broken hardware if both are faulty, but it
> has no effect otherwise at runtime.
>
> Moving it ahead of the check for broken hardware however gets rid
> of the compile-time warning.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Wouldn't something simple like this not be, well, simpler?
---
arch/x86/events/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index d31735f37ed7..3bc4d76ce0bb 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -190,8 +190,8 @@ static void release_pmc_hardware(void) {}
static bool check_hw_exists(void)
{
- u64 val, val_fail, val_new= ~0;
- int i, reg, reg_fail, ret = 0;
+ u64 val, val_fail = 0, val_new= ~0;
+ int i, reg, reg_fail = 0, ret = 0;
int bios_fail = 0;
int reg_safe = -1;
prev parent reply other threads:[~2016-10-24 16:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-24 15:26 [PATCH] perf/x86: always warn about broken BIOS Arnd Bergmann
2016-10-24 16:44 ` Peter Zijlstra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161024164424.GU3102@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=arnd@arndb.de \
--cc=bp@suse.de \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.