Re: [GIT pull] core/urgent for v5.4-rc7

From: Joe Perches
Date: Sun Nov 10 2019 - 17:03:21 EST


On Sun, 2019-11-10 at 10:21 +0000, Thomas Gleixner wrote:
> A small fix for a stacktrace regression. Saving a stacktrace for a foreign
> task skipped an extra entry which makes e.g. the output of /proc/$PID/stack
> incomplete.
[]
> ------------------>
> Jiri Slaby (1):
> stacktrace: Don't skip first entry on noncurrent tasks
[]
> diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
[]
> @@ -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),

trivia:

This idiom '!!(logical test)' is odd and redundant.
Logical test result is already 0 or 1, no !! is unnecessary.

> };
>
> if (!try_get_task_stack(tsk))
> @@ -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);
>
>