[PATCH 2/7] x86/mce: Extend the MCE tracepoint with a decoded string

From: Borislav Petkov
Date: Fri Aug 25 2017 - 06:25:54 EST


From: Borislav Petkov <bp@xxxxxxx>

... which will be filled in by an in-kernel decoder, if one present.
Export it to modules too.

Signed-off-by: Borislav Petkov <bp@xxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
arch/x86/kernel/cpu/mcheck/mce.c | 3 ++-
include/trace/events/mce.h | 11 +++++++----
2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index dcf75f40e031..62bab5d5e96c 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -59,6 +59,7 @@ static DEFINE_MUTEX(mce_log_mutex);

#define CREATE_TRACE_POINTS
#include <trace/events/mce.h>
+EXPORT_TRACEPOINT_SYMBOL_GPL(mce_record);

#define SPINUNIT 100 /* 100ns */

@@ -564,7 +565,7 @@ static int mce_first_notifier(struct notifier_block *nb, unsigned long val,

/* Emit the trace record: */
if (!mca_cfg.has_decoder)
- trace_mce_record(m);
+ trace_mce_record(m, "");

set_bit(0, &mce_need_notify);

diff --git a/include/trace/events/mce.h b/include/trace/events/mce.h
index 70f02149808c..82ff4014fab1 100644
--- a/include/trace/events/mce.h
+++ b/include/trace/events/mce.h
@@ -10,9 +10,9 @@

TRACE_EVENT(mce_record,

- TP_PROTO(struct mce *m),
+ TP_PROTO(struct mce *m, const char *param_str),

- TP_ARGS(m),
+ TP_ARGS(m, param_str),

TP_STRUCT__entry(
__field( u64, mcgcap )
@@ -32,6 +32,7 @@ TRACE_EVENT(mce_record,
__field( u8, cs )
__field( u8, bank )
__field( u8, cpuvendor )
+ __string( str, param_str )
),

TP_fast_assign(
@@ -52,9 +53,10 @@ TRACE_EVENT(mce_record,
__entry->cs = m->cs;
__entry->bank = m->bank;
__entry->cpuvendor = m->cpuvendor;
+ __assign_str(str, param_str);
),

- TP_printk("CPU: %d, MCGc/s: %llx/%llx, MC%d: %016Lx, IPID: %016Lx, ADDR/MISC/SYND: %016Lx/%016Lx/%016Lx, RIP: %02x:<%016Lx>, TSC: %llx, PROCESSOR: %u:%x, TIME: %llu, SOCKET: %u, APIC: %x",
+ TP_printk("CPU: %d, MCGc/s: %llx/%llx, MC%d: %016Lx, IPID: %016Lx, ADDR/MISC/SYND: %016Lx/%016Lx/%016Lx, RIP: %02x:<%016Lx>, TSC: %llx, PROCESSOR: %u:%x, TIME: %llu, SOCKET: %u, APIC: %x %s",
__entry->cpu,
__entry->mcgcap, __entry->mcgstatus,
__entry->bank, __entry->status,
@@ -65,7 +67,8 @@ TRACE_EVENT(mce_record,
__entry->cpuvendor, __entry->cpuid,
__entry->walltime,
__entry->socketid,
- __entry->apicid)
+ __entry->apicid,
+ __get_str(str))
);

#endif /* _TRACE_MCE_H */
--
2.13.0