linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Luck <tony.luck@intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Tony Luck <tony.luck@intel.com>,
	Christopher BeSerra <beserra@amazon.com>,
	x86@kernel.org, linux-edac@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH] x86/mce: Provide sysfs interface to show CMCI storm state
Date: Tue,  1 Jun 2021 13:05:05 -0700	[thread overview]
Message-ID: <20210601200505.966849-1-tony.luck@intel.com> (raw)

Scripts that process error logs can do better if they know whether
Linux is executing in CMCI storm mode (only polling and reporting
some errors instead of trying to report them all). While it is possible
to parse the console log for:

	CMCI storm detected: switching to poll mode
	CMCI storm subsided: switching to interrupt mode

messages, that is error prone.

Add a new file to sysfs to report the current storm count.

Reported-by: Christopher BeSerra <beserra@amazon.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
---

RFC questions:
1) Is there a better way to do this?
2) Maybe just return 0 or 1 instead of the count?
3) Is there a cleaner way to handle the CONFIG_X86_MCE_INTEL dependency

 arch/x86/kernel/cpu/mce/core.c  | 20 ++++++++++++++++++++
 arch/x86/kernel/cpu/mce/intel.c |  5 +++++
 2 files changed, 25 insertions(+)

diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index bf7fe87a7e88..4c4d6b1ec120 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -2431,6 +2431,20 @@ static ssize_t store_int_with_restart(struct device *s,
 	return ret;
 }
 
+#ifndef CONFIG_X86_MCE_INTEL
+static int cmci_storm_value(void)
+{
+	return 0;
+}
+#else
+int cmci_storm_value(void);
+#endif
+
+static ssize_t show_storm(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	return sysfs_emit(buf, "%d\n", cmci_storm_value());
+}
+
 static DEVICE_INT_ATTR(tolerant, 0644, mca_cfg.tolerant);
 static DEVICE_INT_ATTR(monarch_timeout, 0644, mca_cfg.monarch_timeout);
 static DEVICE_BOOL_ATTR(dont_log_ce, 0644, mca_cfg.dont_log_ce);
@@ -2451,6 +2465,11 @@ static struct dev_ext_attribute dev_attr_cmci_disabled = {
 	&mca_cfg.cmci_disabled
 };
 
+static struct dev_ext_attribute dev_attr_show_storm = {
+	__ATTR(show_storm, 0444, show_storm, NULL),
+	NULL
+};
+
 static struct device_attribute *mce_device_attrs[] = {
 	&dev_attr_tolerant.attr,
 	&dev_attr_check_interval.attr,
@@ -2462,6 +2481,7 @@ static struct device_attribute *mce_device_attrs[] = {
 	&dev_attr_print_all.attr,
 	&dev_attr_ignore_ce.attr,
 	&dev_attr_cmci_disabled.attr,
+	&dev_attr_show_storm.attr,
 	NULL
 };
 
diff --git a/arch/x86/kernel/cpu/mce/intel.c b/arch/x86/kernel/cpu/mce/intel.c
index acfd5d9f93c6..4edaa0608de3 100644
--- a/arch/x86/kernel/cpu/mce/intel.c
+++ b/arch/x86/kernel/cpu/mce/intel.c
@@ -73,6 +73,11 @@ enum {
 
 static atomic_t cmci_storm_on_cpus;
 
+int cmci_storm_value(void)
+{
+	return atomic_read(&cmci_storm_on_cpus);
+}
+
 static int cmci_supported(int *banks)
 {
 	u64 cap;
-- 
2.29.2


             reply	other threads:[~2021-06-01 20:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01 20:05 Tony Luck [this message]
2021-06-01 20:35 ` [RFC PATCH] x86/mce: Provide sysfs interface to show CMCI storm state Borislav Petkov
2021-06-01 20:40   ` Luck, Tony
2021-06-03 22:48     ` BeSerra, Christopher
2021-06-04  9:16       ` Borislav Petkov

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=20210601200505.966849-1-tony.luck@intel.com \
    --to=tony.luck@intel.com \
    --cc=beserra@amazon.com \
    --cc=bp@alien8.de \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).