From: Aristeu Rozanski <aris@ruivo.org>
To: Borislav Petkov <bp@alien8.de>
Cc: "Luck, Tony" <tony.luck@intel.com>,
"linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>,
Aristeu Rozanski <aris@redhat.com>
Subject: Re: [PATCH] mce: prevent concurrent polling of MCE events
Date: Fri, 9 Jun 2023 11:59:29 -0400 [thread overview]
Message-ID: <20230609155929.GV4090740@cathedrallabs.org> (raw)
In-Reply-To: <20230606140848.GCZH898MYjw6+b2yux@fat_crate.local>
Hi Borislav,
On Tue, Jun 06, 2023 at 04:08:48PM +0200, Borislav Petkov wrote:
> Independent of that, yes, we will try not to pollute it with duplicates
> once we know what the issue exactly is which makes people disable CMCI.
how about this (untested, with possibly a short comment on
intel_cmci_poll_lock()):
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -1618,7 +1618,9 @@ static void mce_timer_fn(struct timer_list *t)
iv = __this_cpu_read(mce_next_interval);
if (mce_available(this_cpu_ptr(&cpu_info))) {
+ bool locked = intel_cmci_poll_lock();
machine_check_poll(0, this_cpu_ptr(&mce_poll_banks));
+ intel_cmci_poll_unlock(locked);
if (mce_intel_cmci_poll()) {
iv = mce_adjust_timer(iv);
diff --git a/arch/x86/kernel/cpu/mce/intel.c b/arch/x86/kernel/cpu/mce/intel.c
index 95275a5e57e0..c688c088f5cf 100644
--- a/arch/x86/kernel/cpu/mce/intel.c
+++ b/arch/x86/kernel/cpu/mce/intel.c
@@ -73,13 +73,10 @@ enum {
static atomic_t cmci_storm_on_cpus;
-static int cmci_supported(int *banks)
+static int cmci_supported_hw(int *banks)
{
u64 cap;
- if (mca_cfg.cmci_disabled || mca_cfg.ignore_ce)
- return 0;
-
/*
* Vendor check is not strictly needed, but the initial
* initialization is vendor keyed and this
@@ -96,6 +93,14 @@ static int cmci_supported(int *banks)
return !!(cap & MCG_CMCI_P);
}
+static int cmci_supported(int *banks)
+{
+ if (mca_cfg.cmci_disabled || mca_cfg.ignore_ce)
+ return 0;
+
+ return cmci_supported_hw(banks);
+}
+
static bool lmce_supported(void)
{
u64 tmp;
@@ -519,3 +524,25 @@ bool intel_filter_mce(struct mce *m)
return false;
}
+
+static DEFINE_SPINLOCK(cmci_poll_lock);
+bool intel_cmci_poll_lock(void)
+{
+ int banks;
+
+ if (!cmci_supported_hw(&banks))
+ return false;
+
+ spin_lock(&cmci_poll_lock);
+
+ return true;
+}
+
+void intel_cmci_poll_unlock(bool locked)
+{
+ if (!locked)
+ return;
+
+ spin_unlock(&cmci_poll_lock);
+}
+
diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h
index d2412ce2d312..25bcc4a13e8c 100644
--- a/arch/x86/kernel/cpu/mce/internal.h
+++ b/arch/x86/kernel/cpu/mce/internal.h
@@ -49,6 +49,8 @@ void intel_init_cmci(void);
void intel_init_lmce(void);
void intel_clear_lmce(void);
bool intel_filter_mce(struct mce *m);
+bool intel_cmci_poll_lock(void);
+void intel_cmci_poll_unlock(bool locked);
#else
# define cmci_intel_adjust_timer mce_adjust_timer_default
static inline bool mce_intel_cmci_poll(void) { return false; }
@@ -58,6 +60,8 @@ static inline void intel_init_cmci(void) { }
static inline void intel_init_lmce(void) { }
static inline void intel_clear_lmce(void) { }
static inline bool intel_filter_mce(struct mce *m) { return false; }
+static inline bool intel_cmci_poll_lock(void) { return false; }
+static inline void intel_cmci_poll_unlock(bool locked) { }
#endif
void mce_timer_kick(unsigned long interval);
--
Aristeu
next prev parent reply other threads:[~2023-06-09 16:00 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-15 14:32 [PATCH] mce: prevent concurrent polling of MCE events Aristeu Rozanski
2023-05-15 14:52 ` Borislav Petkov
2023-05-15 17:18 ` Luck, Tony
2023-05-15 18:30 ` Borislav Petkov
2023-05-15 19:08 ` Luck, Tony
2023-05-15 19:44 ` Borislav Petkov
2023-05-15 20:07 ` Luck, Tony
2023-05-15 20:20 ` Aristeu Rozanski
2023-05-15 20:27 ` Luck, Tony
2023-05-15 20:32 ` Aristeu Rozanski
2023-05-15 20:40 ` Luck, Tony
2023-05-16 17:08 ` Borislav Petkov
2023-05-23 14:15 ` Aristeu Rozanski
2023-06-04 16:04 ` Aristeu Rozanski
2023-06-05 15:33 ` Luck, Tony
2023-06-05 17:41 ` Borislav Petkov
2023-06-05 17:58 ` Luck, Tony
2023-06-05 19:30 ` Borislav Petkov
2023-06-05 19:37 ` Luck, Tony
2023-06-05 19:43 ` Borislav Petkov
2023-06-05 20:10 ` Aristeu Rozanski
2023-06-05 20:33 ` Aristeu Rozanski
2023-06-05 20:56 ` Borislav Petkov
2023-06-05 21:01 ` Aristeu Rozanski
2023-06-05 21:06 ` Borislav Petkov
2023-06-05 21:29 ` Luck, Tony
2023-06-05 21:58 ` Aristeu Rozanski
2023-06-06 8:25 ` Borislav Petkov
2023-06-06 14:00 ` Aristeu Rozanski
2023-06-06 14:08 ` Borislav Petkov
2023-06-09 0:26 ` Luck, Tony
2023-06-09 10:17 ` Borislav Petkov
2023-06-09 15:00 ` Yazen Ghannam
2023-06-09 15:24 ` Luck, Tony
2023-06-09 16:00 ` Yazen Ghannam
2023-06-09 15:59 ` Aristeu Rozanski [this message]
2023-06-05 19:08 ` Aristeu Rozanski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230609155929.GV4090740@cathedrallabs.org \
--to=aris@ruivo.org \
--cc=aris@redhat.com \
--cc=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox