Commit b0c51f15 authored by Jiri Slaby's avatar Jiri Slaby Committed by Thomas Gleixner

stacktrace: Don't skip first entry on noncurrent tasks

When doing cat /proc/<PID>/stack, the output is missing the first entry.
When the current code walks the stack starting in stack_trace_save_tsk,
it skips all scheduler functions (that's OK) plus one more function. But
this one function should be skipped only for the 'current' task as it is
stack_trace_save_tsk proper.

The original code (before the common infrastructure) skipped one
function only for the 'current' task -- see save_stack_trace_tsk before
3599fe12. So do so also in the new infrastructure now.

Fixes: 214d8ca6 ("stacktrace: Provide common infrastructure")
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Tested-by: default avatarMichal Suchanek <msuchanek@suse.de>
Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20191030072545.19462-1-jslaby@suse.cz
parent a99d8080
...@@ -141,7 +141,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *tsk, unsigned long *store, ...@@ -141,7 +141,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *tsk, unsigned long *store,
struct stacktrace_cookie c = { struct stacktrace_cookie c = {
.store = store, .store = store,
.size = size, .size = size,
.skip = skipnr + 1, /* skip this function if they are tracing us */
.skip = skipnr + !!(current == tsk),
}; };
if (!try_get_task_stack(tsk)) if (!try_get_task_stack(tsk))
...@@ -298,7 +299,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *task, ...@@ -298,7 +299,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *task,
struct stack_trace trace = { struct stack_trace trace = {
.entries = store, .entries = store,
.max_entries = size, .max_entries = size,
.skip = skipnr + 1, /* skip this function if they are tracing us */
.skip = skipnr + !!(current == task),
}; };
save_stack_trace_tsk(task, &trace); save_stack_trace_tsk(task, &trace);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment