Skip to content

Commit

Permalink
stacktrace: Don't skip first entry on noncurrent tasks
Browse files Browse the repository at this point in the history
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
3599fe1. So do so also in the new infrastructure now.

Fixes: 214d8ca ("stacktrace: Provide common infrastructure")
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michal Suchanek <msuchanek@suse.de>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20191030072545.19462-1-jslaby@suse.cz
  • Loading branch information
Jiri Slaby authored and Thomas Gleixner committed Nov 4, 2019
1 parent a99d808 commit b0c51f1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kernel/stacktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *tsk, unsigned long *store,
struct stacktrace_cookie c = {
.store = store,
.size = size,
.skip = skipnr + 1,
/* skip this function if they are tracing us */
.skip = skipnr + !!(current == tsk),
};

if (!try_get_task_stack(tsk))
Expand Down Expand Up @@ -298,7 +299,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *task,
struct stack_trace trace = {
.entries = store,
.max_entries = size,
.skip = skipnr + 1,
/* skip this function if they are tracing us */
.skip = skipnr + !!(current == task),
};

save_stack_trace_tsk(task, &trace);
Expand Down

0 comments on commit b0c51f1

Please sign in to comment.