[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1304357691-14354-5-git-send-email-bp@amd64.org>
Date: Mon, 2 May 2011 19:34:51 +0200
From: Borislav Petkov <bp@...64.org>
To: Ingo Molnar <mingo@...e.hu>, Peter Zijlstra <peterz@...radead.org>
Cc: Arnaldo Carvalho de Melo <acme@...radead.org>,
Steven Rostedt <rostedt@...dmis.org>,
Frederic Weisbecker <fweisbec@...il.com>,
Tony Luck <tony.luck@...el.com>,
Mauro Carvalho Chehab <mchehab@...hat.com>,
EDAC devel <linux-edac@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Borislav Petkov <borislav.petkov@....com>
Subject: [PATCH 4/4] x86, mce: Have MCE persistent event off by default for now
From: Borislav Petkov <borislav.petkov@....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@....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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists