2013-03-12 19:39:47

by Mike Travis

[permalink] [raw]
Subject: [PATCH 12/14] x86/UV: Add uvtrace support

This patch adds support for the uvtrace KDB module by providing a
skeleton call to the registered trace function. It also provides
another separate 'NMI' tracer that is triggered by the system wide
'power nmi' command.

Cc: Alex Shi <[email protected]>
Cc: Cliff Wickman <[email protected]>
Cc: Alexander Gordeev <[email protected]>
Cc: Suresh Siddha <[email protected]>
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Steffen Persvold <[email protected]>
Reviewed-by: Dimitri Sivanich <[email protected]>
Signed-off-by: Mike Travis <[email protected]>
---
arch/x86/include/asm/uv/uv.h | 12 ++++++++++--
arch/x86/platform/uv/uv_nmi.c | 10 +++++++++-
2 files changed, 19 insertions(+), 3 deletions(-)

--- linux.orig/arch/x86/include/asm/uv/uv.h
+++ linux/arch/x86/include/asm/uv/uv.h
@@ -14,24 +14,32 @@ extern void uv_cpu_init(void);
extern void uv_nmi_init(void);
extern void uv_register_nmi_notifier(void);
extern void uv_system_init(void);
+extern void (*uv_trace_nmi_func)(int cpu, struct pt_regs *regs, int ignored);
+extern void (*uv_trace_func)(const char *f, const int l, const char *fmt, ...);
+#define uvtrace(fmt, ...) \
+do { \
+ if (unlikely(uv_trace_func)) \
+ (uv_trace_func)(__func__, __LINE__, fmt, ##__VA_ARGS__);\
+} while (0)
extern const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask,
struct mm_struct *mm,
unsigned long start,
unsigned long end,
unsigned int cpu);

-#else /* X86_UV */
+#else /* !X86_UV */

static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; }
static inline int is_uv_system(void) { return 0; }
static inline void uv_cpu_init(void) { }
static inline void uv_system_init(void) { }
+static inline void uvtrace(void *fmt, ...) { }
static inline void uv_register_nmi_notifier(void) { }
static inline const struct cpumask *
uv_flush_tlb_others(const struct cpumask *cpumask, struct mm_struct *mm,
unsigned long start, unsigned long end, unsigned int cpu)
{ return cpumask; }

-#endif /* X86_UV */
+#endif /* !X86_UV */

#endif /* _ASM_X86_UV_UV_H */
--- linux.orig/arch/x86/platform/uv/uv_nmi.c
+++ linux/arch/x86/platform/uv/uv_nmi.c
@@ -1,5 +1,5 @@
/*
- * SGI NMI support routines
+ * SGI NMI/TRACE support routines
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
*/

#include <linux/cpu.h>
+#include <linux/module.h>
#include <linux/nmi.h>

#include <asm/apic.h>
@@ -34,6 +35,13 @@
DEFINE_PER_CPU(unsigned long, cpu_last_nmi_count);
static DEFINE_SPINLOCK(uv_nmi_lock);

+void (*uv_trace_func)(const char *f, const int l, const char *fmt, ...);
+EXPORT_SYMBOL(uv_trace_func);
+
+void (*uv_trace_nmi_func)(int cpu, struct pt_regs *regs, int ignored);
+EXPORT_SYMBOL(uv_trace_nmi_func);
+
+
/*
* When NMI is received, print a stack trace.
*/

--