Commit e5299926 authored by Hidetoshi Seto's avatar Hidetoshi Seto Committed by Ingo Molnar

x86: MCE: make cmci_discover_lock irq-safe

Lockdep reports the warning below when Li tries to offline one cpu:

[  110.835487] =================================
[  110.835616] [ INFO: inconsistent lock state ]
[  110.835688] 2.6.30-rc4-00336-g8c9ed899 #52
[  110.835757] ---------------------------------
[  110.835828] inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
[  110.835908] swapper/0 [HC1[1]:SC0[0]:HE0:SE1] takes:
[  110.835982]  (cmci_discover_lock){?.+...}, at: [<ffffffff80236dc0>] cmci_clear+0x30/0x9b

cmci_clear() can be called via smp_call_function_single().

It is better to disable interrupt while holding cmci_discover_lock,
to turn it into an irq-safe lock - we can deadlock otherwise.

[ Impact: fix possible deadlock in the MCE code ]
Reported-by: default avatarShaohua Li <shaohua.li@intel.com>
Signed-off-by: default avatarHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <4A03ED38.8000700@jp.fujitsu.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Reported-by: Shaohua Li<shaohua.li@intel.com>
parent 33df4db0
...@@ -151,10 +151,11 @@ static void print_update(char *type, int *hdr, int num) ...@@ -151,10 +151,11 @@ static void print_update(char *type, int *hdr, int num)
static void cmci_discover(int banks, int boot) static void cmci_discover(int banks, int boot)
{ {
unsigned long *owned = (void *)&__get_cpu_var(mce_banks_owned); unsigned long *owned = (void *)&__get_cpu_var(mce_banks_owned);
unsigned long flags;
int hdr = 0; int hdr = 0;
int i; int i;
spin_lock(&cmci_discover_lock); spin_lock_irqsave(&cmci_discover_lock, flags);
for (i = 0; i < banks; i++) { for (i = 0; i < banks; i++) {
u64 val; u64 val;
...@@ -184,7 +185,7 @@ static void cmci_discover(int banks, int boot) ...@@ -184,7 +185,7 @@ static void cmci_discover(int banks, int boot)
WARN_ON(!test_bit(i, __get_cpu_var(mce_poll_banks))); WARN_ON(!test_bit(i, __get_cpu_var(mce_poll_banks)));
} }
} }
spin_unlock(&cmci_discover_lock); spin_unlock_irqrestore(&cmci_discover_lock, flags);
if (hdr) if (hdr)
printk(KERN_CONT "\n"); printk(KERN_CONT "\n");
} }
...@@ -211,13 +212,14 @@ void cmci_recheck(void) ...@@ -211,13 +212,14 @@ void cmci_recheck(void)
*/ */
void cmci_clear(void) void cmci_clear(void)
{ {
unsigned long flags;
int i; int i;
int banks; int banks;
u64 val; u64 val;
if (!cmci_supported(&banks)) if (!cmci_supported(&banks))
return; return;
spin_lock(&cmci_discover_lock); spin_lock_irqsave(&cmci_discover_lock, flags);
for (i = 0; i < banks; i++) { for (i = 0; i < banks; i++) {
if (!test_bit(i, __get_cpu_var(mce_banks_owned))) if (!test_bit(i, __get_cpu_var(mce_banks_owned)))
continue; continue;
...@@ -227,7 +229,7 @@ void cmci_clear(void) ...@@ -227,7 +229,7 @@ void cmci_clear(void)
wrmsrl(MSR_IA32_MC0_CTL2 + i, val); wrmsrl(MSR_IA32_MC0_CTL2 + i, val);
__clear_bit(i, __get_cpu_var(mce_banks_owned)); __clear_bit(i, __get_cpu_var(mce_banks_owned));
} }
spin_unlock(&cmci_discover_lock); spin_unlock_irqrestore(&cmci_discover_lock, flags);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment