[PATCH 1/2] perf, x86-mm: Add exit-fault tracing

From: Alexis Berlemont
Date: Tue Oct 25 2016 - 19:56:38 EST


Signed-off-by: Alexis Berlemont <alexis.berlemont@xxxxxxxxx>
---
arch/x86/include/asm/trace/exceptions.h | 21 +++++++++++++++++++++
arch/x86/mm/fault.c | 1 +
2 files changed, 22 insertions(+)

diff --git a/arch/x86/include/asm/trace/exceptions.h b/arch/x86/include/asm/trace/exceptions.h
index 2fbc66c..39f78bb 100644
--- a/arch/x86/include/asm/trace/exceptions.h
+++ b/arch/x86/include/asm/trace/exceptions.h
@@ -43,6 +43,27 @@ DEFINE_EVENT_FN(x86_exceptions, name, \
DEFINE_PAGE_FAULT_EVENT(page_fault_user);
DEFINE_PAGE_FAULT_EVENT(page_fault_kernel);

+TRACE_EVENT_FN(page_fault_exit,
+
+ TP_PROTO(unsigned long address),
+
+ TP_ARGS(address),
+
+ TP_STRUCT__entry(
+ __field(unsigned long, address)
+ ),
+
+ TP_fast_assign(
+ __entry->address = address;
+ ),
+
+ TP_printk("address=%lx", __entry->address),
+
+ trace_irq_vector_regfunc,
+
+ trace_irq_vector_unregfunc
+);
+
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#define TRACE_INCLUDE_FILE exceptions
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 9f72ca3..e31e8ef 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1488,6 +1488,7 @@ trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
prev_state = exception_enter();
trace_page_fault_entries(address, regs, error_code);
__do_page_fault(regs, error_code, address);
+ trace_page_fault_exit(address);
exception_exit(prev_state);
}
NOKPROBE_SYMBOL(trace_do_page_fault);
--
2.10.1