From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751877Ab2H0E6C (ORCPT ); Mon, 27 Aug 2012 00:58:02 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:33687 "EHLO e23smtp04.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751430Ab2H0E6A (ORCPT ); Mon, 27 Aug 2012 00:58:00 -0400 Message-ID: <50361A59.2020308@linux.vnet.ibm.com> Date: Thu, 23 Aug 2012 17:26:09 +0530 From: "Naveen N. Rao" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Borislav Petkov CC: tony.luck@intel.com, andi@firstfloor.org, gong.chen@linux.intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, tglx@linutronix.de, linux-edac@vger.kernel.org, ananth@in.ibm.com, Chris McDermott , masbock@linux.vnet.ibm.com Subject: Re: [PATCH] x86: mce: Honour bios-set CMCI threshold References: <20120822123054.29238.3864.stgit@localhost.localdomain> <20120822124649.GD5817@aftab.osrc.amd.com> In-Reply-To: <20120822124649.GD5817@aftab.osrc.amd.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit x-cbid: 12082704-9264-0000-0000-00000237D6EA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/22/2012 06:16 PM, Borislav Petkov wrote: > On Wed, Aug 22, 2012 at 06:00:54PM +0530, Naveen N. Rao wrote: >> The ACPI spec doesn't provide for a way for the bios to pass down >> recommended thresholds to the OS on a _per-bank_ basis. This patch adds >> a new boot option, which if passed, allows bios to initialize the CMCI >> threshold. In such a case, we simply skip programming any threshold >> value. >> >> As fail-safe, we initialize threshold to 1 if some banks have not been >> initialized by the bios and warn the user. >> >> Signed-off-by: Naveen N. Rao >> --- >> Documentation/x86/x86_64/boot-options.txt | 5 ++++ >> arch/x86/include/asm/mce.h | 1 + >> arch/x86/kernel/cpu/mcheck/mce.c | 4 +++ >> arch/x86/kernel/cpu/mcheck/mce_intel.c | 39 +++++++++++++++++++++++++++-- >> 4 files changed, 46 insertions(+), 3 deletions(-) >> >> diff --git a/Documentation/x86/x86_64/boot-options.txt b/Documentation/x86/x86_64/boot-options.txt >> index c54b4f5..ec92540 100644 >> --- a/Documentation/x86/x86_64/boot-options.txt >> +++ b/Documentation/x86/x86_64/boot-options.txt >> @@ -50,6 +50,11 @@ Machine check >> monarchtimeout: >> Sets the time in us to wait for other CPUs on machine checks. 0 >> to disable. >> + mce=bios_cmci_threshold >> + Don't overwrite the bios-set CMCI threshold. This boot option >> + prevents Linux from overwriting the CMCI threshold set by the >> + bios. Without this option, Linux always sets the CMCI >> + threshold to 1. >> >> nomce (for compatibility with i386): same as mce=off >> >> diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h >> index a3ac52b..8ad5078 100644 >> --- a/arch/x86/include/asm/mce.h >> +++ b/arch/x86/include/asm/mce.h >> @@ -171,6 +171,7 @@ DECLARE_PER_CPU(struct device *, mce_device); >> #ifdef CONFIG_X86_MCE_INTEL >> extern int mce_cmci_disabled; >> extern int mce_ignore_ce; >> +extern int mce_bios_cmci_threshold; >> void mce_intel_feature_init(struct cpuinfo_x86 *c); >> void cmci_clear(void); >> void cmci_reenable(void); >> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c >> index 292d025..401359d 100644 >> --- a/arch/x86/kernel/cpu/mcheck/mce.c >> +++ b/arch/x86/kernel/cpu/mcheck/mce.c >> @@ -82,6 +82,7 @@ static int mce_panic_timeout __read_mostly; >> static int mce_dont_log_ce __read_mostly; >> int mce_cmci_disabled __read_mostly; >> int mce_ignore_ce __read_mostly; >> +int mce_bios_cmci_threshold __read_mostly; >> int mce_ser __read_mostly; > > AFAICT, this is actually a single-bit flag but we're using a whole > integer for it and from looking at the other boot options a couple of > them are used as flags too. > > Care to define a > > struct boot_flags { > __u64 mce_bios_cmci_threshold : 1, > __reserved : 63; > }; > > and use > > boot_flags.mce_bios_cmci_threshold > > in the conditionals below instead? Sure - sounds like a good idea. Further, a #define could eliminate the need to change other references, but I'm not sure that's GENERALLacceptable #define mce_bios_cmci_threshold boot_flags.mce_bios_cmci_threshold could eliminate the need to change other references, but I'm not sure that's acceptable But, I just had a quick look and it seems to me that these were defined as integers since they are exposed via sysfs. For instance: static struct dev_ext_attribute dev_attr_cmci_disabled = { __ATTR(cmci_disabled, 0644, device_show_int, set_cmci_disabled), &mce_cmci_disabled }; Converting mce_cmci_disabled to a bit-field doesn't work since we take its address above. We could ignore and not set the second field at all (dev_ext_attribute->var) and define our own callbacks, but that'll be more work and I'm not sure if we work fine without > > I'll try to convert the rest of them to that struct and thus save some > more space... > > Thanks. >