[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1345139123-15212-5-git-send-email-bp@amd64.org>
Date: Thu, 16 Aug 2012 19:45:23 +0200
From: Borislav Petkov <bp@...64.org>
To: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>,
Frederic Weisbecker <fweisbec@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
Borislav Petkov <borislav.petkov@....com>
Subject: [RFC PATCH -v2 4/4] persistent test
From: Borislav Petkov <borislav.petkov@....com>
Signed-off-by: Borislav Petkov <borislav.petkov@....com>
---
arch/x86/include/asm/mce.h | 1 +
arch/x86/kernel/cpu/mcheck/mce.c | 5 +++++
kernel/events/persistent.c | 41 +++++++++++++++++++++++++++++++++++++++-
3 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index a3ac52b29cbf..e46b05dff64a 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -256,5 +256,6 @@ struct cper_sec_mem_err;
extern void apei_mce_report_mem_error(int corrected,
struct cper_sec_mem_err *mem_err);
+extern int perf_get_mce_event_id(void);
#endif /* __KERNEL__ */
#endif /* _ASM_X86_MCE_H */
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 292d0258311c..cacd45bfac01 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2445,3 +2445,8 @@ static int __init mcheck_debugfs_init(void)
}
late_initcall(mcheck_debugfs_init);
#endif
+
+int perf_get_mce_event_id(void)
+{
+ return event_mce_record.event.type;
+}
diff --git a/kernel/events/persistent.c b/kernel/events/persistent.c
index 33d45396dc02..edb07640d5f1 100644
--- a/kernel/events/persistent.c
+++ b/kernel/events/persistent.c
@@ -10,7 +10,7 @@
#include <asm/mce.h>
-static int pers_open_generic(struct inode *inode, struct file *filp)
+int pers_open_generic(struct inode *inode, struct file *filp)
{
filp->private_data = inode->i_private;
return 0;
@@ -127,3 +127,42 @@ void perf_rm_persistent_event(struct perf_event_desc *desc)
perf_event_release_kernel(event);
}
+
+static struct perf_event_attr pattr = {
+ .type = PERF_TYPE_TRACEPOINT,
+ .size = sizeof(pattr),
+ .sample_type = PERF_SAMPLE_RAW,
+ .persistent = 1,
+};
+
+static struct perf_event_desc pdesc = {
+ .dir_name = "mce_record",
+};
+
+static int __init pers_init(void)
+{
+ struct perf_event *event;
+ char *fname;
+ int cpu = 1;
+
+ fname = kzalloc(10 + 4, GFP_KERNEL);
+ if (!fname)
+ return -ENOMEM;
+
+ snprintf(fname, 14, "persistent%d", cpu);
+ pdesc.fname = fname;
+
+ pattr.config = perf_get_mce_event_id();
+ pattr.sample_period = 1;
+ pattr.wakeup_events = 1,
+ pdesc.pattr = &pattr;
+
+ event = perf_add_persistent_on_cpu(cpu, &pdesc, 4);
+ if (IS_ERR(event)) {
+ pr_err("%s: Error adding persistent event!\n", __func__);
+ return -EINVAL;
+ }
+ return 0;
+}
+
+late_initcall(pers_init);
--
1.7.11.rc1
--
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