[Devel] [PATCH RHEL7 COMMIT] trace: fix frame skip when saving event stacktrace

Vasily Averin vvs at virtuozzo.com
Thu Sep 2 20:21:03 MSK 2021


The commit is pushed to "branch-rh7-3.10.0-1160.41.1.vz7.183.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.41.1.vz7.183.1
------>
commit c93e9f190c2c1bfc5fb79f1ceba1b37a495270b4
Author: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
Date:   Thu Sep 2 20:21:02 2021 +0300

    trace: fix frame skip when saving event stacktrace
    
    When saving stacktraces, some frames are skipped because they correspond
    to calls of internal functions of the tracing subsystem.
    
    The number of frames to skip went out of sync with the current codebase,
    leading to skipping some caller's frames. Fix that.
    
    https://jira.sw.ru/browse/PSBM-92088
    Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 kernel/trace/trace.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 94f2825..4828f7c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1588,6 +1588,15 @@ __buffer_unlock_commit(struct ring_buffer *buffer, struct ring_buffer_event *eve
 	ring_buffer_unlock_commit(buffer, event);
 }
 
+/*
+ * Skip 3:
+ *
+ *   __ftrace_trace_stack()
+ *   trace_buffer_unlock_commit()
+ *   ftrace_raw_event_xxx()
+ */
+#define STACK_SKIP 3
+
 static inline void
 __trace_buffer_unlock_commit(struct ring_buffer *buffer,
 			     struct ring_buffer_event *event,
@@ -1595,7 +1604,7 @@ __trace_buffer_unlock_commit(struct ring_buffer *buffer,
 {
 	__buffer_unlock_commit(buffer, event);
 
-	ftrace_trace_stack(buffer, flags, 6, pc);
+	ftrace_trace_stack(buffer, flags, STACK_SKIP, pc);
 	ftrace_trace_userstack(buffer, flags, pc);
 }
 


More information about the Devel mailing list