Skip to contentSkip to conversation

x86/MCE: allow overriding the CMCI threshold

PATCH In review Jan Beulich 3 participants 3 messages Jan 12, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/MCE: allow overriding the CMCI threshold

We've had reports of systems where CMCIs would surface at a relatively high rate during certain periods of time, without them apparently causing subsequent more severe problems (see Xeon E7-8800/4800/2800 specification clarification SC1). Give the admin a knob to lower the impact on the system logs.

docs/misc/xen-command-line.markdown +8 -0
@@ -242,6 +242,14 @@ the NMI watchdog is also enabled.
 
 If set, override Xen's default choice for the platform timer.
 
+### cmci-threshold
+> `= <integer>`
+
+> Default: `2`
+
+Specify the event count threshold for raising Corrected Machine Check
+Interrupts.  Specifying zero disables CMCI handling.
+
 ### cmos-rtc-probe
 > `= <boolean>`
 
xen/arch/x86/cpu/mcheck/mce_intel.c +19 -3
@@ -492,6 +492,9 @@ static int do_cmci_discover(int i)
 {
     unsigned msr = MSR_IA32_MCx_CTL2(i);
     u64 val;
+    unsigned int threshold, max_threshold;
+    static unsigned int cmci_threshold = 2;
+    integer_param("cmci-threshold", cmci_threshold);
 
     rdmsrl(msr, val);
     /* Some other CPU already owns this bank. */
@@ -500,15 +503,28 @@ static int do_cmci_discover(int i)
         goto out;
     }
 
-    val &= ~CMCI_THRESHOLD_MASK;
-    wrmsrl(msr, val | CMCI_EN | CMCI_THRESHOLD);
-    rdmsrl(msr, val);
+    if ( cmci_threshold )
+    {
+        wrmsrl(msr, val | CMCI_EN | CMCI_THRESHOLD_MASK);
+        rdmsrl(msr, val);
+    }
 
     if (!(val & CMCI_EN)) {
         /* This bank does not support CMCI. Polling timer has to handle it. */
         mcabanks_set(i, __get_cpu_var(no_cmci_banks));
+        wrmsrl(msr, val & ~CMCI_THRESHOLD_MASK);
         return 0;
     }
+    max_threshold = MASK_EXTR(val, CMCI_THRESHOLD_MASK);
+    threshold = cmci_threshold;
+    if ( threshold > max_threshold )
+    {
+       mce_printk(MCE_QUIET,
+                  "CMCI: threshold %#x too large for CPU%u bank %u, using %#x\n",
+                  threshold, smp_processor_id(), i, max_threshold);
+       threshold = max_threshold;
+    }
+    wrmsrl(msr, (val & ~CMCI_THRESHOLD_MASK) | CMCI_EN | threshold);
     mcabanks_set(i, __get_cpu_var(mce_banks_owned));
 out:
     mcabanks_clear(i, __get_cpu_var(no_cmci_banks));
xen/arch/x86/cpu/mcheck/x86_mca.h +0 -3
@@ -86,9 +86,6 @@
 /* Bitfield of MSR_K8_HWCR register */
 #define K8_HWCR_MCi_STATUS_WREN		(1ULL << 18)
 
-/*Intel Specific bitfield*/
-#define CMCI_THRESHOLD			0x2
-
 #define MCi_MISC_ADDRMOD_MASK (0x7UL << 6)
 #define MCi_MISC_PHYSMOD    (0x2UL << 6)
 

x86/MCE: allow overriding the CMCI threshold

We've had reports of systems where CMCIs would surface at a relatively high rate during certain periods of time, without them apparently causing subsequent more severe problems (see Xeon E7-8800/4800/2800 specification clarification SC1). Give the admin a knob to lower the impact on the system logs.

docs/misc/xen-command-line.markdown +8 -0
@@ -242,6 +242,14 @@ the NMI watchdog is also enabled.
 
 If set, override Xen's default choice for the platform timer.
 
+### cmci-threshold
+> `= <integer>`
+
+> Default: `2`
+
+Specify the event count threshold for raising Corrected Machine Check
+Interrupts.  Specifying zero disables CMCI handling.
+
 ### cmos-rtc-probe
 > `= <boolean>`
 
xen/arch/x86/cpu/mcheck/mce_intel.c +19 -3
@@ -492,6 +492,9 @@ static int do_cmci_discover(int i)
 {
     unsigned msr = MSR_IA32_MCx_CTL2(i);
     u64 val;
+    unsigned int threshold, max_threshold;
+    static unsigned int cmci_threshold = 2;
+    integer_param("cmci-threshold", cmci_threshold);
 
     rdmsrl(msr, val);
     /* Some other CPU already owns this bank. */
@@ -500,15 +503,28 @@ static int do_cmci_discover(int i)
         goto out;
     }
 
-    val &= ~CMCI_THRESHOLD_MASK;
-    wrmsrl(msr, val | CMCI_EN | CMCI_THRESHOLD);
-    rdmsrl(msr, val);
+    if ( cmci_threshold )
+    {
+        wrmsrl(msr, val | CMCI_EN | CMCI_THRESHOLD_MASK);
+        rdmsrl(msr, val);
+    }
 
     if (!(val & CMCI_EN)) {
         /* This bank does not support CMCI. Polling timer has to handle it. */
         mcabanks_set(i, __get_cpu_var(no_cmci_banks));
+        wrmsrl(msr, val & ~CMCI_THRESHOLD_MASK);
         return 0;
     }
+    max_threshold = MASK_EXTR(val, CMCI_THRESHOLD_MASK);
+    threshold = cmci_threshold;
+    if ( threshold > max_threshold )
+    {
+       mce_printk(MCE_QUIET,
+                  "CMCI: threshold %#x too large for CPU%u bank %u, using %#x\n",
+                  threshold, smp_processor_id(), i, max_threshold);
+       threshold = max_threshold;
+    }
+    wrmsrl(msr, (val & ~CMCI_THRESHOLD_MASK) | CMCI_EN | threshold);
     mcabanks_set(i, __get_cpu_var(mce_banks_owned));
 out:
     mcabanks_clear(i, __get_cpu_var(no_cmci_banks));
xen/arch/x86/cpu/mcheck/x86_mca.h +0 -3
@@ -86,9 +86,6 @@
 /* Bitfield of MSR_K8_HWCR register */
 #define K8_HWCR_MCi_STATUS_WREN		(1ULL << 18)
 
-/*Intel Specific bitfield*/
-#define CMCI_THRESHOLD			0x2
-
 #define MCi_MISC_ADDRMOD_MASK (0x7UL << 6)
 #define MCi_MISC_PHYSMOD    (0x2UL << 6)
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jan Beulich

We've had reports of systems where CMCIs would surface at a relatively high rate during certain periods of time, without them apparently causing subsequent more severe problems (see Xeon E7-8800/4800/2800 specification clarification SC1). Give the admin a knob to lower the impact on the system logs.

A small comment at the bottom, besides of that:

Quoted 65 lines
docs/misc/xen-command-line.markdown +8 -0
@@ -242,6 +242,14 @@ the NMI watchdog is also enabled.
 
 If set, override Xen's default choice for the platform timer.
 
+### cmci-threshold
+> `= <integer>`
+
+> Default: `2`
+
+Specify the event count threshold for raising Corrected Machine Check
+Interrupts.  Specifying zero disables CMCI handling.
+
 ### cmos-rtc-probe
 > `= <boolean>`
 
xen/arch/x86/cpu/mcheck/mce_intel.c +19 -3
@@ -492,6 +492,9 @@ static int do_cmci_discover(int i)
 {
     unsigned msr = MSR_IA32_MCx_CTL2(i);
     u64 val;
+    unsigned int threshold, max_threshold;
+    static unsigned int cmci_threshold = 2;
+    integer_param("cmci-threshold", cmci_threshold);
 
     rdmsrl(msr, val);
     /* Some other CPU already owns this bank. */
@@ -500,15 +503,28 @@ static int do_cmci_discover(int i)
         goto out;
     }
 
-    val &= ~CMCI_THRESHOLD_MASK;
-    wrmsrl(msr, val | CMCI_EN | CMCI_THRESHOLD);
-    rdmsrl(msr, val);
+    if ( cmci_threshold )
+    {
+        wrmsrl(msr, val | CMCI_EN | CMCI_THRESHOLD_MASK);
+        rdmsrl(msr, val);
+    }
 
     if (!(val & CMCI_EN)) {
         /* This bank does not support CMCI. Polling timer has to handle it. */
         mcabanks_set(i, __get_cpu_var(no_cmci_banks));
+        wrmsrl(msr, val & ~CMCI_THRESHOLD_MASK);
         return 0;
     }
+    max_threshold = MASK_EXTR(val, CMCI_THRESHOLD_MASK);
+    threshold = cmci_threshold;
+    if ( threshold > max_threshold )
+    {
+       mce_printk(MCE_QUIET,
+                  "CMCI: threshold %#x too large for CPU%u bank %u, using %#x\n",
+                  threshold, smp_processor_id(), i, max_threshold);
+       threshold = max_threshold;
+    }
+    wrmsrl(msr, (val & ~CMCI_THRESHOLD_MASK) | CMCI_EN | threshold);
     mcabanks_set(i, __get_cpu_var(mce_banks_owned));
 out:
     mcabanks_clear(i, __get_cpu_var(no_cmci_banks));

xen/arch/x86/cpu/mcheck/x86_mca.h line 90

Quoted 8 lines
xen/arch/x86/cpu/mcheck/x86_mca.h +0 -3
@@ -86,9 +86,6 @@
 /* Bitfield of MSR_K8_HWCR register */
 #define K8_HWCR_MCi_STATUS_WREN		(1ULL << 18)
 
-/*Intel Specific bitfield*/
-#define CMCI_THRESHOLD			0x2
-
 #define MCi_MISC_ADDRMOD_MASK (0x7UL << 6)
 #define MCi_MISC_PHYSMOD    (0x2UL << 6)

I think these two are also Intel specific bitfields. Please leave the comment for those.

Christoph

Acked-by Acked-by Christoph Egger
#2 lore raw

Same comments with Egger.

-----邮件原件-----
发件人: Egger, Christoph [mailto:[email protected]] 发送时间: 2015年1月12日 18:18
收件人: Jan Beulich; xen-devel
抄送: 刘劲松(凯耳)
主题: Re: [PATCH] x86/MCE: allow overriding the CMCI threshold

Quoted 7 lines · Jan Beulich

We've had reports of systems where CMCIs would surface at a relatively high rate during certain periods of time, without them apparently causing subsequent more severe problems (see Xeon E7-8800/4800/2800 specification clarification SC1). Give the admin a knob to lower the impact on the system logs.

A small comment at the bottom, besides of that:

Quoted 34 lines
docs/misc/xen-command-line.markdown +8 -0
@@ -242,6 +242,14 @@ the NMI watchdog is also enabled.
 
 If set, override Xen's default choice for the platform timer.
 
+### cmci-threshold
+> `= <integer>`
+
+> Default: `2`
+
+Specify the event count threshold for raising Corrected Machine Check 
+Interrupts.  Specifying zero disables CMCI handling.
+
 ### cmos-rtc-probe
 > `= <boolean>`
 
xen/arch/x86/cpu/mcheck/mce_intel.c +3 -0
@@ -492,6 +492,9 @@ static int do_cmci_discover(int i)  {
     unsigned msr = MSR_IA32_MCx_CTL2(i);
     u64 val;
+    unsigned int threshold, max_threshold;
+    static unsigned int cmci_threshold = 2;
+    integer_param("cmci-threshold", cmci_threshold);
 
     rdmsrl(msr, val);
     /* Some other CPU already owns this bank. */ @@ -500,15 +503,28 
 @@ static int do_cmci_discover(int i)
         goto out;
     }
xen/arch/x86/cpu/mcheck/mce_intel.c +0 -1
-    val &= ~CMCI_THRESHOLD_MASK;

xen/arch/x86/cpu/mcheck/mce_intel.c static int do_cmci_discover(int i)

Quoted 10 lines
xen/arch/x86/cpu/mcheck/mce_intel.c +5 -2
-    wrmsrl(msr, val | CMCI_EN | CMCI_THRESHOLD);
-    rdmsrl(msr, val);
+    if ( cmci_threshold )
+    {
+        wrmsrl(msr, val | CMCI_EN | CMCI_THRESHOLD_MASK);
+        rdmsrl(msr, val);
+    }
 
     if (!(val & CMCI_EN)) {
         /* This bank does not support CMCI. Polling timer has to handle

it. */

xen/arch/x86/cpu/mcheck/mce_intel.c static int do_cmci_discover(int i)

Quoted 10 lines
         mcabanks_set(i, __get_cpu_var(no_cmci_banks));
xen/arch/x86/cpu/mcheck/mce_intel.c +7 -0
+        wrmsrl(msr, val & ~CMCI_THRESHOLD_MASK);
         return 0;
     }
+    max_threshold = MASK_EXTR(val, CMCI_THRESHOLD_MASK);
+    threshold = cmci_threshold;
+    if ( threshold > max_threshold )
+    {
+       mce_printk(MCE_QUIET,
+                  "CMCI: threshold %#x too large for CPU%u bank %u, using

%#x\n",

Quoted 10 lines
xen/arch/x86/cpu/mcheck/mce_intel.c +4 -0
+                  threshold, smp_processor_id(), i, max_threshold);
+       threshold = max_threshold;
+    }
+    wrmsrl(msr, (val & ~CMCI_THRESHOLD_MASK) | CMCI_EN | threshold);
     mcabanks_set(i, __get_cpu_var(mce_banks_owned));
 out:
     mcabanks_clear(i, __get_cpu_var(no_cmci_banks));

xen/arch/x86/cpu/mcheck/x86_mca.h line 90

Quoted 8 lines
xen/arch/x86/cpu/mcheck/x86_mca.h +0 -3
@@ -86,9 +86,6 @@
 /* Bitfield of MSR_K8_HWCR register */
 #define K8_HWCR_MCi_STATUS_WREN		(1ULL << 18)
 
-/*Intel Specific bitfield*/
-#define CMCI_THRESHOLD			0x2
-
 #define MCi_MISC_ADDRMOD_MASK (0x7UL << 6)
 #define MCi_MISC_PHYSMOD    (0x2UL << 6)

I think these two are also Intel specific bitfields. Please leave the comment for those.

Christoph

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel