Skip to content

Commit ed5c41d

Browse files
KAGA-KOKOtorvalds
authored andcommitted
x86: MCE: Add raw_lock conversion again
Commit ea43164 ("x86/mce: Fix CMCI preemption bugs") breaks RT by the completely unrelated conversion of the cmci_discover_lock to a regular (non raw) spinlock. This lock was annotated in commit 59d958d ("locking, x86: mce: Annotate cmci_discover_lock as raw") with a proper explanation why. The argument for converting the lock back to a regular spinlock was: - it does percpu ops without disabling preemption. Preemption is not disabled due to the mistaken use of a raw spinlock. Which is complete nonsense. The raw_spinlock is disabling preemption in the same way as a regular spinlock. In mainline spinlock maps to raw_spinlock, in RT spinlock becomes a "sleeping" lock. raw_spinlock has on RT exactly the same semantics as in mainline. And because this lock is taken in non preemptible context it must be raw on RT. Undo the locking brainfart. Reported-by: Clark Williams <williams@redhat.com> Reported-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f4d3333 commit ed5c41d

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎arch/x86/kernel/cpu/mcheck/mce_intel.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static DEFINE_PER_CPU(mce_banks_t, mce_banks_owned);
4242
* cmci_discover_lock protects against parallel discovery attempts
4343
* which could race against each other.
4444
*/
45-
static DEFINE_SPINLOCK(cmci_discover_lock);
45+
static DEFINE_RAW_SPINLOCK(cmci_discover_lock);
4646

4747
#define CMCI_THRESHOLD 1
4848
#define CMCI_POLL_INTERVAL (30 * HZ)
@@ -144,14 +144,14 @@ static void cmci_storm_disable_banks(void)
144144
int bank;
145145
u64 val;
146146

147-
spin_lock_irqsave(&cmci_discover_lock, flags);
147+
raw_spin_lock_irqsave(&cmci_discover_lock, flags);
148148
owned = __get_cpu_var(mce_banks_owned);
149149
for_each_set_bit(bank, owned, MAX_NR_BANKS) {
150150
rdmsrl(MSR_IA32_MCx_CTL2(bank), val);
151151
val &= ~MCI_CTL2_CMCI_EN;
152152
wrmsrl(MSR_IA32_MCx_CTL2(bank), val);
153153
}
154-
spin_unlock_irqrestore(&cmci_discover_lock, flags);
154+
raw_spin_unlock_irqrestore(&cmci_discover_lock, flags);
155155
}
156156

157157
static bool cmci_storm_detect(void)
@@ -211,7 +211,7 @@ static void cmci_discover(int banks)
211211
int i;
212212
int bios_wrong_thresh = 0;
213213

214-
spin_lock_irqsave(&cmci_discover_lock, flags);
214+
raw_spin_lock_irqsave(&cmci_discover_lock, flags);
215215
for (i = 0; i < banks; i++) {
216216
u64 val;
217217
int bios_zero_thresh = 0;
@@ -266,7 +266,7 @@ static void cmci_discover(int banks)
266266
WARN_ON(!test_bit(i, __get_cpu_var(mce_poll_banks)));
267267
}
268268
}
269-
spin_unlock_irqrestore(&cmci_discover_lock, flags);
269+
raw_spin_unlock_irqrestore(&cmci_discover_lock, flags);
270270
if (mca_cfg.bios_cmci_threshold && bios_wrong_thresh) {
271271
pr_info_once(
272272
"bios_cmci_threshold: Some banks do not have valid thresholds set\n");
@@ -316,10 +316,10 @@ void cmci_clear(void)
316316

317317
if (!cmci_supported(&banks))
318318
return;
319-
spin_lock_irqsave(&cmci_discover_lock, flags);
319+
raw_spin_lock_irqsave(&cmci_discover_lock, flags);
320320
for (i = 0; i < banks; i++)
321321
__cmci_disable_bank(i);
322-
spin_unlock_irqrestore(&cmci_discover_lock, flags);
322+
raw_spin_unlock_irqrestore(&cmci_discover_lock, flags);
323323
}
324324

325325
static void cmci_rediscover_work_func(void *arg)
@@ -360,9 +360,9 @@ void cmci_disable_bank(int bank)
360360
if (!cmci_supported(&banks))
361361
return;
362362

363-
spin_lock_irqsave(&cmci_discover_lock, flags);
363+
raw_spin_lock_irqsave(&cmci_discover_lock, flags);
364364
__cmci_disable_bank(bank);
365-
spin_unlock_irqrestore(&cmci_discover_lock, flags);
365+
raw_spin_unlock_irqrestore(&cmci_discover_lock, flags);
366366
}
367367

368368
static void intel_init_cmci(void)

0 commit comments

Comments
 (0)