x86:Instruments page fault trace event
Subsystems (5)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/2 Add page fault trace event definitions
Add page_fault_entry and page_fault_exit event definitions. It will allow each architecture to instrument their page faults.
--- include/trace/events/fault.h | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 include/trace/events/fault.h
include/trace/events/fault.h new file +51 -0
@@ -0,0 +1,51 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM fault + +#if !defined(_TRACE_FAULT_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_FAULT_H + +#include <linux/tracepoint.h> + +TRACE_EVENT (page_fault_entry, + + TP_PROTO(struct pt_regs *regs, unsigned long address, + int write_access), + +TP_ARGS (regs, address, write_access), + +TP_STRUCT__entry ( + __field( unsigned long, ip ) + __field( unsigned long, addr ) +__field ( uint8_t, write ) + ), + +TP_fast_assign ( + __entry->ip = regs ? instruction_pointer(regs) : 0UL; + __entry->addr = address; + __entry->write = !!write_access; + ), + +TP_printk ("ip=%lu addr=%lu write_access=%d" , + __entry->ip, __entry->addr, __entry->write) +); + +TRACE_EVENT (page_fault_exit, + + TP_PROTO(int result), + +TP_ARGS (result), + +TP_STRUCT__entry ( +__field ( int, res ) + ), + +TP_fast_assign ( + __entry->res = result; + ), + +TP_printk ("result=%d" , __entry->res) +); + +#endif /* _TRACE_FAULT_H */ +/* This part must be outside protection */ +#include <trace/define_trace.h>
Signature · 7 lines
1.7.10.4 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Mathieu Desnoyers
reviewerRe: [RFC-Patch 1/2] Add page fault trace event definitions
In reply to a message not in the archiveQuoted 25 lines · * Francis Deslauriers ([email protected]) wrote:
Add
page_fault_entryandpage_fault_exitevent definitions. It will allow each architecture to instrument their page faults.Signed-off-by Francis Deslauriers <[email protected]>Reviewed-by Raphaël Beamonte <[email protected]>--- include/trace/events/fault.h | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 include/trace/events/fault.hinclude/trace/events/fault.h new file +9
-0@@ -0,0 +1,51 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM fault + +#if !defined(_TRACE_FAULT_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_FAULT_H + +#include <linux/tracepoint.h> + +TRACE_EVENT(page_fault_entry,
include/trace/events/fault.h line 19
Quoted 10 lines
include/trace/events/fault.h new file +10
-0+ + TP_PROTO(struct pt_regs *regs, unsigned long address, + int write_access), + +TP_ARGS (regs, address, write_access), + +TP_STRUCT__entry ( + __field( unsigned long, ip ) +__field (unsigned long ,addr ) + __field( int, write )
uint8_t, write
will save some space.
include/trace/events/fault.h line 25
Quoted 6 lines
include/trace/events/fault.h new file +6
-0+ ), + +TP_fast_assign ( + __entry->ip = regs ? instruction_pointer(regs) : 0UL; + __entry->addr = address; + __entry->write = write_access;
Just to be clean, if we use uint8_t:
__entry->write = !!write_access;
It will map zero/nonzero values to 0 and 1, and thus ensure it can be represented on a uint8_t.
Thanks,
Mathieu
Quoted 34 lines
include/trace/events/fault.h new file +26
-0+ ), + +TP_printk ("ip=%lu addr=%lu write_access=%d" , + __entry->ip, __entry->addr, __entry->write) +); + +TRACE_EVENT (page_fault_exit, + + TP_PROTO(int result), + +TP_ARGS (result), + +TP_STRUCT__entry ( +__field ( int, res ) + ), + +TP_fast_assign ( + __entry->res = result; + ), + +TP_printk ("result=%d" , __entry->res) +); + +#endif /* _TRACE_FAULT_H */ +/* This part must be outside protection */ +#include <trace/define_trace.h> Signature · 7 lines
1.7.10.4 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
A message that is not in the archive (sent off-list or not yet received): [email protected]
Mathieu Desnoyers
reviewerQuoted 21 lines · * Francis Deslauriers ([email protected]) wrote:
Signed-off-by Francis Deslauriers <[email protected]>Reviewed-by Raphaël Beamonte <[email protected]>--- arch/x86/mm/fault.c | 5 +++++ 1 file changed, 5 insertions(+)arch/x86/mm/fault.c +3
-0@@ -20,6 +20,9 @@#include <asm/fixmap.h> /* VSYSCALL_START */ #include <asm/context_tracking.h> /* exception_enter(), ... */ +#define CREATE_TRACE_POINTS +#include <trace/events/fault.h> /* trace_page_fault_*(), ... */ +/* * Page fault error code bits: *
arch/x86/mm/fault.c good_area: · line 1191
Quoted 6 lines
arch/x86/mm/fault.c +2
-0@@ -1183,7 +1186,9 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault: */ +trace_page_fault_entry (regs, address, write); fault =handle_mm_fault (mm, vma, address, flags); +trace_page_fault_exit (fault);
If you look at the lttng 0.x instrumentation, I think there are other tracepoints in get user pages too ?
Thanks,
Mathieu
Quoted 11 lines
arch/x86/mm/fault.c +0
-0if (unlikely (fault & (VM_FAULT_RETRY |VM_FAULT_ERROR ))) {if (mm_fault_error (regs, error_code, address, fault))Signature · 7 lines
1.7.10.4 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
PATCH 2/2 x86:Instruments page fault trace event
In reply to a message not in the archive--- arch/x86/mm/fault.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/x86/mm/fault.c +5 -0
@@ -20,6 +20,9 @@#include <asm/fixmap.h> /* VSYSCALL_START */ #include <asm/context_tracking.h> /* exception_enter(), ... */ +#define CREATE_TRACE_POINTS +#include <trace/events/fault.h> /* trace_page_fault_*(), ... */ +/* * Page fault error code bits: *
@@ -1183,7 +1186,9 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault: */ +trace_page_fault_entry (regs, address, write); fault =handle_mm_fault (mm, vma, address, flags); +trace_page_fault_exit (fault);if (unlikely (fault & (VM_FAULT_RETRY |VM_FAULT_ERROR ))) {if (mm_fault_error (regs, error_code, address, fault))
Signature · 7 lines
1.7.10.4 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/2 x86:Instruments page fault trace event
--- arch/x86/mm/fault.c | 7 +++++++ mm/memory.c | 5 +++++ 2 files changed, 12 insertions(+)
arch/x86/mm/fault.c +7 -0
@@ -20,6 +20,9 @@#include <asm/fixmap.h> /* VSYSCALL_START */ #include <asm/context_tracking.h> /* exception_enter(), ... */ +#define CREATE_TRACE_POINTS +#include <trace/events/fault.h> /* trace_page_fault_*(), ... */ +/* * Page fault error code bits: *
@@ -754,12 +757,14 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,if (likely (show_unhandled_signals))show_signal_msg (regs, error_code, address, tsk); +trace_page_fault_entry (regs, address, error_code &PF_WRITE ); tsk->thread.cr2 = address; tsk->thread.error_code = error_code; tsk->thread.trap_nr =X86_TRAP_PF ;force_sig_info_fault (SIGSEGV , si_code, address, tsk,0 ); +trace_page_fault_exit (-1 );return ; }
@@ -1183,7 +1188,9 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault: */ +trace_page_fault_entry (regs, address, write); fault =handle_mm_fault (mm, vma, address, flags); +trace_page_fault_exit (fault);if (unlikely (fault & (VM_FAULT_RETRY |VM_FAULT_ERROR ))) {if (mm_fault_error (regs, error_code, address, fault))
mm/memory.c +5 -0
@@ -67,6 +67,8 @@#include <asm/tlbflush.h> #include <asm/pgtable.h> +#include <trace/events/fault.h> +#include "internal.h" #ifdef LAST_NID_NOT_IN_PAGE_FLAGS
@@ -1828,8 +1830,11 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,if (foll_flags &FOLL_NOWAIT ) fault_flags |= (FAULT_FLAG_ALLOW_RETRY |FAULT_FLAG_RETRY_NOWAIT ); +trace_page_fault_entry (0 , start, + foll_flags &FOLL_WRITE ); ret =handle_mm_fault (mm, vma, start, fault_flags); +trace_page_fault_exit (ret);if (ret &VM_FAULT_ERROR ) {if (ret &VM_FAULT_OOM )
Signature · 7 lines
1.7.10.4 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Mathieu Desnoyers
reviewerQuoted 22 lines · * Francis Deslauriers ([email protected]) wrote:
Signed-off-by Francis Deslauriers <[email protected]>Reviewed-by Raphaël Beamonte <[email protected]>--- arch/x86/mm/fault.c | 7 +++++++ mm/memory.c | 5 +++++ 2 files changed, 12 insertions(+)arch/x86/mm/fault.c +3
-0@@ -20,6 +20,9 @@#include <asm/fixmap.h> /* VSYSCALL_START */ #include <asm/context_tracking.h> /* exception_enter(), ... */ +#define CREATE_TRACE_POINTS +#include <trace/events/fault.h> /* trace_page_fault_*(), ... */ +/* * Page fault error code bits: *
arch/x86/mm/fault.c __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, · line 766
Quoted 10 lines
arch/x86/mm/fault.c +1
-0@@ -754,12 +757,14 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,if (likely (show_unhandled_signals))show_signal_msg (regs, error_code, address, tsk); +trace_page_fault_entry (regs, address, error_code &PF_WRITE ); tsk->thread.cr2 = address; tsk->thread.error_code = error_code; tsk->thread.trap_nr =X86_TRAP_PF ;force_sig_info_fault (SIGSEGV , si_code, address, tsk,0 );
maybe we should put a comment in the patch when sending to LKML, e.g.:
/*
* Using -1 here, since there is no VM_FAULT flag to identify
* user accesses triggering SIGSEGV.
*/
arch/x86/mm/fault.c __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, · line 767
Quoted 1 line
arch/x86/mm/fault.c +1
-0+trace_page_fault_exit (-1 );
And maybe interesting hints will come from LKML.
The rest looks good,
Thanks,
Mathieu
Quoted 46 lines
arch/x86/mm/fault.c +2
-0return ; }@@ -1183,7 +1188,9 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault: */ +trace_page_fault_entry (regs, address, write); fault =handle_mm_fault (mm, vma, address, flags); +trace_page_fault_exit (fault);if (unlikely (fault & (VM_FAULT_RETRY |VM_FAULT_ERROR ))) {if (mm_fault_error (regs, error_code, address, fault))mm/memory.c +5
-0@@ -67,6 +67,8 @@#include <asm/tlbflush.h> #include <asm/pgtable.h> +#include <trace/events/fault.h> +#include "internal.h" #ifdef LAST_NID_NOT_IN_PAGE_FLAGS @@ -1828,8 +1830,11 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,if (foll_flags &FOLL_NOWAIT ) fault_flags |= (FAULT_FLAG_ALLOW_RETRY |FAULT_FLAG_RETRY_NOWAIT ); +trace_page_fault_entry (0 , start, + foll_flags &FOLL_WRITE ); ret =handle_mm_fault (mm, vma, start, fault_flags); +trace_page_fault_exit (ret);if (ret &VM_FAULT_ERROR ) {if (ret &VM_FAULT_OOM )Signature · 7 lines
1.7.10.4 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Re: [RFC-Patch 1/2] Add page fault trace event definitions
In reply to a message not in the archiveQuoted 5 lines · * Francis Deslauriers ([email protected]) wrote:
Add
page_fault_entryandpage_fault_exitevent definitions. It will allow each architecture to instrument their page faults.Signed-off-by Francis Deslauriers <[email protected]>Reviewed-by Raphaël Beamonte <[email protected]>
Quoted 70 lines
--- include/trace/events/fault.h | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 include/trace/events/fault.hinclude/trace/events/fault.h new file +51
-0@@ -0,0 +1,51 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM fault + +#if !defined(_TRACE_FAULT_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_FAULT_H + +#include <linux/tracepoint.h> + +TRACE_EVENT (page_fault_entry, + + TP_PROTO(struct pt_regs *regs, unsigned long address, + int write_access), + +TP_ARGS (regs, address, write_access), + +TP_STRUCT__entry ( + __field( unsigned long, ip ) + __field( unsigned long, addr ) +__field ( uint8_t, write ) + ), + +TP_fast_assign ( + __entry->ip = regs ? instruction_pointer(regs) : 0UL; + __entry->addr = address; + __entry->write = !!write_access; + ), + +TP_printk ("ip=%lu addr=%lu write_access=%d" , + __entry->ip, __entry->addr, __entry->write) +); + +TRACE_EVENT (page_fault_exit, + + TP_PROTO(int result), + +TP_ARGS (result), + +TP_STRUCT__entry ( +__field ( int, res ) + ), + +TP_fast_assign ( + __entry->res = result; + ), + +TP_printk ("result=%d" , __entry->res) +); + +#endif /* _TRACE_FAULT_H */ +/* This part must be outside protection */ +#include <trace/define_trace.h> Signature · 7 lines
1.7.10.4 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com