mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@amd64.org>
To: Ingo Molnar <mingo@elte.hu>, Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Tony Luck <tony.luck@intel.com>,
	Mauro Carvalho Chehab <mchehab@redhat.com>,
	EDAC devel <linux-edac@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Borislav Petkov <borislav.petkov@amd.com>
Subject: [PATCH 4/4] x86, mce: Have MCE persistent event off by default for now
Date: Mon,  2 May 2011 19:34:51 +0200	[thread overview]
Message-ID: <1304357691-14354-5-git-send-email-bp@amd64.org> (raw)
In-Reply-To: <1304357691-14354-1-git-send-email-bp@amd64.org>

From: Borislav Petkov <borislav.petkov@amd.com>

This is new functionality and it affects all of x86 so we want to be
very conservative about it and have it off by default for now, in case
something goes awry. You can always enable it by supplying "ras" on the
kernel command line.

Also, depending on whether it is enabled or not, we emit the tracepoint
from a different place in the code to pick up additional decoded info.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 Documentation/kernel-parameters.txt |    2 ++
 arch/x86/include/asm/mce.h          |    1 +
 arch/x86/kernel/cpu/mcheck/mce.c    |   32 ++++++++++++++++++++++++++++++--
 drivers/edac/mce_amd.c              |    5 +++++
 4 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index cc85a92..f09438a 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2165,6 +2165,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 	ramdisk_size=	[RAM] Sizes of RAM disks in kilobytes
 			See Documentation/blockdev/ramdisk.txt.
 
+	ras		[X86] Enable RAS daemon supporting functionality.
+
 	rcupdate.blimit=	[KNL,BOOT]
 			Set maximum number of finished RCU callbacks to process
 			in one batch.
diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index 40cc9bc..649d47a 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -131,6 +131,7 @@ extern struct atomic_notifier_head x86_mce_decoder_chain;
 
 extern int mce_disabled;
 extern int mce_p5_enabled;
+extern int ras;
 
 #ifdef CONFIG_X86_MCE
 int mcheck_init(void);
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 9589ebf..3fb22cb 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -59,6 +59,8 @@ static DEFINE_MUTEX(mce_read_mutex);
 #define CREATE_TRACE_POINTS
 #include <trace/events/mce.h>
 
+EXPORT_TRACEPOINT_SYMBOL_GPL(mce_record);
+
 int mce_disabled __read_mostly;
 
 #define MISC_MCELOG_MINOR	227
@@ -86,6 +88,7 @@ static int			mce_dont_log_ce		__read_mostly;
 int				mce_cmci_disabled	__read_mostly;
 int				mce_ignore_ce		__read_mostly;
 int				mce_ser			__read_mostly;
+int				ras			__read_mostly;
 
 struct mce_bank                *mce_banks		__read_mostly;
 
@@ -105,6 +108,7 @@ static int			cpu_missing;
  */
 ATOMIC_NOTIFIER_HEAD(x86_mce_decoder_chain);
 EXPORT_SYMBOL_GPL(x86_mce_decoder_chain);
+EXPORT_SYMBOL_GPL(ras);
 
 static int default_decode_mce(struct notifier_block *nb, unsigned long val,
 			       void *data)
@@ -163,8 +167,9 @@ void mce_log(struct mce *mce)
 {
 	unsigned next, entry;
 
-	/* Emit the trace record: */
-	trace_mce_record(mce);
+	if (!ras)
+		/* Emit the trace record: */
+		trace_mce_record(mce);
 
 	mce->finished = 0;
 	wmb();
@@ -1721,6 +1726,19 @@ static int __init mcheck_enable(char *str)
 }
 __setup("mce", mcheck_enable);
 
+static int __init ras_enable(char *str)
+{
+	/*
+	 * We enable the persistent event only if "ras" is supplied on the
+	 * command line.
+	 */
+	ras = 1;
+
+	return 0;
+}
+
+__setup("ras", ras_enable);
+
 int __init mcheck_init(void)
 {
 	atomic_notifier_chain_register(&x86_mce_decoder_chain, &mce_dec_nb);
@@ -2081,6 +2099,9 @@ static int mce_enable_perf_event_on_cpu(int cpu)
 	struct mce_tp_desc *d = &per_cpu(mce_event, cpu);
 	int err = -EINVAL;
 
+	if (!ras)
+		return 0;
+
 	d->event = perf_enable_persistent_event(&pattr, cpu, MCE_BUF_PAGES);
 	if (IS_ERR(d->event)) {
 		printk(KERN_ERR "MCE: Error enabling event on cpu %d\n", cpu);
@@ -2105,6 +2126,10 @@ ret:
 static void mce_disable_perf_event_on_cpu(int cpu)
 {
 	struct mce_tp_desc *d = &per_cpu(mce_event, cpu);
+
+	if (!ras)
+		return;
+
 	debugfs_remove(d->debugfs_entry);
 	perf_disable_persistent_event(d->event, cpu);
 }
@@ -2113,6 +2138,9 @@ static __init int mcheck_init_persistent_event(void)
 {
 	int cpu, err = 0;
 
+	if (!ras)
+		return -EBUSY;
+
 	get_online_cpus();
 
 	pattr.config = event_mce_record.event.type;
diff --git a/drivers/edac/mce_amd.c b/drivers/edac/mce_amd.c
index 795cfbc..e329335 100644
--- a/drivers/edac/mce_amd.c
+++ b/drivers/edac/mce_amd.c
@@ -1,5 +1,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <asm/mce.h>
+#include <trace/events/mce.h>
 
 #include "mce_amd.h"
 
@@ -829,6 +831,9 @@ int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)
 
 	amd_decode_err_code(m->status & 0xffff);
 
+	if (ras)
+		trace_mce_record(m);
+
 	return NOTIFY_STOP;
 }
 EXPORT_SYMBOL_GPL(amd_decode_mce);
-- 
1.7.4.rc2


  parent reply	other threads:[~2011-05-02 17:35 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-02 17:34 [PATCH 0/4] RAS daemon: kernel part Borislav Petkov
2011-05-02 17:34 ` [PATCH 1/4] perf: Start the restructuring Borislav Petkov
2011-05-02 17:34 ` [PATCH 2/4] perf: Add persistent event facilities Borislav Petkov
2011-05-03  6:40   ` Ingo Molnar
2011-05-03  6:48     ` Ingo Molnar
2011-05-03  7:12     ` Borislav Petkov
2011-05-03  8:22       ` Ingo Molnar
2011-05-03 12:51         ` [GIT PULL] Rename perf_event.c Borislav Petkov
2011-05-03 12:59     ` [PATCH 2/4] perf: Add persistent event facilities Frederic Weisbecker
2011-05-03 13:30       ` Borislav Petkov
2011-05-03 14:26         ` Borislav Petkov
2011-05-02 17:34 ` [PATCH 3/4] x86, mce: Add persistent MCE event Borislav Petkov
2011-05-03  6:44   ` Ingo Molnar
2011-05-03  7:18     ` Borislav Petkov
2011-05-03  8:27       ` Ingo Molnar
2011-05-03 15:14       ` Joe Perches
2011-05-03 15:22         ` Borislav Petkov
2011-05-03 15:32           ` Joe Perches
2011-05-03 15:34           ` Steven Rostedt
2011-05-03 15:42             ` Borislav Petkov
2011-05-02 17:34 ` Borislav Petkov [this message]
2011-05-03  6:45   ` [PATCH 4/4] x86, mce: Have MCE persistent event off by default for now Ingo Molnar
2011-05-03  7:23     ` Borislav Petkov
2011-05-03  8:17       ` Ingo Molnar
2011-05-03 17:17       ` Luck, Tony
2011-05-03 19:52         ` Borislav Petkov
2011-05-03 19:56           ` Ingo Molnar
2011-05-04  6:58         ` Ingo Molnar
2011-05-04 21:40           ` Luck, Tony
2011-05-05  1:34             ` Arnaldo Carvalho de Melo
2011-05-05  6:39             ` Ingo Molnar
2011-05-05  7:17               ` Borislav Petkov
2011-05-05  7:33                 ` Ingo Molnar

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=1304357691-14354-5-git-send-email-bp@amd64.org \
    --to=bp@amd64.org \
    --cc=acme@infradead.org \
    --cc=borislav.petkov@amd.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@redhat.com \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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

all inboxes | Powered by JetHome®