Skip to content

Commit b0c51f1

Browse files
Jiri SlabyKAGA-KOKO
authored andcommitted
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 3599fe1. So do so also in the new infrastructure now. Fixes: 214d8ca ("stacktrace: Provide common infrastructure") Signed-off-by: Jiri Slaby <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Michal Suchanek <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent a99d808 commit b0c51f1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/stacktrace.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *tsk, unsigned long *store,
141141
struct stacktrace_cookie c = {
142142
.store = store,
143143
.size = size,
144-
.skip = skipnr + 1,
144+
/* skip this function if they are tracing us */
145+
.skip = skipnr + !!(current == tsk),
145146
};
146147

147148
if (!try_get_task_stack(tsk))
@@ -298,7 +299,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *task,
298299
struct stack_trace trace = {
299300
.entries = store,
300301
.max_entries = size,
301-
.skip = skipnr + 1,
302+
/* skip this function if they are tracing us */
303+
.skip = skipnr + !!(current == task),
302304
};
303305

304306
save_stack_trace_tsk(task, &trace);

0 commit comments

Comments
 (0)