From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751778AbdAPV5B (ORCPT ); Mon, 16 Jan 2017 16:57:01 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:42203 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652AbdAPV4j (ORCPT ); Mon, 16 Jan 2017 16:56:39 -0500 Date: Mon, 16 Jan 2017 22:56:06 +0100 (CET) From: Thomas Gleixner To: Prarit Bhargava cc: linux-kernel@vger.kernel.org, Tony Luck , Borislav Petkov , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-edac@vger.kernel.org Subject: Re: [PATCH] x86/mce: Fix initialization error warning In-Reply-To: <1484603381-15018-1-git-send-email-prarit@redhat.com> Message-ID: References: <1484603381-15018-1-git-send-email-prarit@redhat.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Jan 2017, Prarit Bhargava wrote: > When booting kernel with mce=off a loud warning from the mce code > is displayed. This causes confusion for end users. > > Add a check to see if MCE is available before outputting the warning > message. Sigh. > Signed-off-by: Prarit Bhargava > Cc: Tony Luck > Cc: Borislav Petkov > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: "H. Peter Anvin" > Cc: x86@kernel.org > Cc: linux-edac@vger.kernel.org > --- > arch/x86/kernel/cpu/mcheck/mce.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c > index 00ef43233e03..943a0c440c55 100644 > --- a/arch/x86/kernel/cpu/mcheck/mce.c > +++ b/arch/x86/kernel/cpu/mcheck/mce.c > @@ -2662,7 +2662,8 @@ static __init int mcheck_init_device(void) > free_cpumask_var(mce_device_initialized); > > err_out: > - pr_err("Unable to init device /dev/mcelog (rc: %d)\n", err); > + if (mce_available(&boot_cpu_data)) > + pr_err("Unable to init device /dev/mcelog (rc: %d)\n", err); This is really crap. Why would you check the same condition twice? Just because it's so much more complicated than doing the obvious: --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -2615,10 +2615,8 @@ static __init int mcheck_init_device(voi enum cpuhp_state hp_online; int err; - if (!mce_available(&boot_cpu_data)) { - err = -EIO; - goto err_out; - } + if (!mce_available(&boot_cpu_data)) + return -EIO; if (!zalloc_cpumask_var(&mce_device_initialized, GFP_KERNEL)) { err = -ENOMEM;