From: Borislav Petkov <bp@amd64.org>
To: Arnaldo Carvalho de Melo <acme@infradead.org>,
Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>,
Steven Rostedt <rostedt@goodmis.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Tony Luck <tony.luck@intel.com>,
Mauro Carvalho Chehab <mchehab@redhat.com>,
David Ahern <dsahern@gmail.com>,
EDAC devel <linux-edac@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Borislav Petkov <borislav.petkov@amd.com>
Subject: [PATCH 04/18] x86, mce: Have MCE persistent event off by default for now
Date: Sat, 23 Apr 2011 18:28:06 +0200 [thread overview]
Message-ID: <1303576100-425-5-git-send-email-bp@amd64.org> (raw)
In-Reply-To: <1303576100-425-1-git-send-email-bp@amd64.org>
From: Borislav Petkov <borislav.petkov@amd.com>
Since this is a pretty new functionality and since it affects all x86,
we want to have it off by default for now, in case something goes awry.
You can always enable it by supplying "ras" on your 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 any 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 81f5545..8872af9 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..54b411f 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. We still can add further options to parameter later.
+ */
+ 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
next prev parent reply other threads:[~2011-04-23 16:29 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-23 16:28 [PATCH 00/18] RAS daemon: Easter Eggs Edition Borislav Petkov
2011-04-23 16:28 ` [PATCH 01/18] perf: Start the restructuring Borislav Petkov
2011-04-23 16:28 ` [PATCH 02/18] perf: Add persistent event facilities Borislav Petkov
2011-04-26 10:57 ` Peter Zijlstra
2011-04-26 12:45 ` Ingo Molnar
2011-04-26 14:05 ` Borislav Petkov
2011-04-23 16:28 ` [PATCH 03/18] x86, mce: Add persistent MCE event Borislav Petkov
2011-04-23 16:28 ` Borislav Petkov [this message]
2011-04-23 16:28 ` [PATCH 05/18] perf: Add Makefile.lib Borislav Petkov
2011-04-23 16:28 ` [PATCH 06/18] tools: Add a toplevel Makefile Borislav Petkov
2011-04-23 16:28 ` [PATCH 07/18] perf: Export trace-event utils Borislav Petkov
2011-04-23 16:28 ` [PATCH 08/18] perf: Remove duplicate enum trace_flag_type Borislav Petkov
2011-04-23 16:28 ` [PATCH 09/18] perf: Drop redundant FD macro definitions Borislav Petkov
2011-07-25 15:04 ` Arnaldo Carvalho de Melo
2011-04-23 16:28 ` [PATCH 10/18] perf: Export debugfs utilities Borislav Petkov
2011-04-23 16:28 ` [PATCH 11/18] perf: Export cpumap.[ch] Borislav Petkov
2011-04-23 16:28 ` [PATCH 12/18] perf: Export thread_map.[ch] Borislav Petkov
2011-04-23 16:28 ` [PATCH 13/18] perf: Export evsel.[ch] Borislav Petkov
2011-04-23 16:28 ` [PATCH 14/18] perf: Export cgroup.[ch] Borislav Petkov
2011-04-23 16:28 ` [PATCH 15/18] perf: Export evlist.[ch] Borislav Petkov
2011-04-23 16:28 ` [PATCH 16/18] perf: Export ctype.c Borislav Petkov
2011-04-23 16:28 ` [PATCH 17/18] perf: Export tracepoint_id_to_path Borislav Petkov
2011-04-23 16:28 ` [PATCH 18/18] ras: Add RAS daemon Borislav Petkov
2011-04-29 14:08 ` [PATCH 00/18] RAS daemon: Easter Eggs Edition Frederic Weisbecker
2011-04-29 14:25 ` Borislav Petkov
2011-04-29 14:31 ` Ingo Molnar
2011-04-29 17:35 ` Arnaldo Carvalho de Melo
2011-04-29 14:39 ` Steven Rostedt
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=1303576100-425-5-git-send-email-bp@amd64.org \
--to=bp@amd64.org \
--cc=acme@infradead.org \
--cc=borislav.petkov@amd.com \
--cc=dsahern@gmail.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;
as well as URLs for NNTP newsgroup(s).