Re: [PATCH] tools lib traceevent: Fix prev/next_prio for deadline tasks

From: Steven Rostedt
Date: Tue Jan 03 2017 - 10:02:34 EST


On Tue, 3 Jan 2017 12:42:42 +0100
Daniel Bristot de Oliveira <bristot@xxxxxxxxxx> wrote:

> From: Daniel Bristot de Oliveiva <bristot@xxxxxxxxxx>
>
> Currently, the sched:sched_switch tracepoint reports deadline tasks
> with priority -1. But when reading the trace via perf script I've
> got the following output:
>
> # ./d & # (d is a deadline task, see [1])
> # perf record -e sched:sched_switch -a sleep 1
> # perf script
> ...
> swapper 0 [000] 2146.962441: sched:sched_switch: swapper/0:0 [120] R ==> d:2593 [4294967295]
> d 2593 [000] 2146.972472: sched:sched_switch: d:2593 [4294967295] R ==> g:2590 [4294967295]
>
> The task d reports the wrong priority [4294967295]. This happens because
> the "int prio" is stored in an unsigned long long val. Although it is
> set as a %lld, as int is shorter than unsigned long long,
> trace_seq_printf prints it as a positive number.
>
> The fix is just to cast the val as an int, and print it as a %d,
> as in the sched:sched_switch tracepoint's "format".
>
> The output with the fix is:
>
> # ./d &
> # perf record -e sched:sched_switch -a sleep 1
> # perf script
> ...
> swapper 0 [000] 4306.374037: sched:sched_switch: swapper/0:0 [120] R ==> d:10941 [-1]
> d 10941 [000] 4306.383823: sched:sched_switch: d:10941 [-1] R ==> swapper/0:0 [120]
>
> [1] gcc -o d d.c - from http://bristot.me/lkml/d.c
>
> Signed-off-by: Daniel Bristot de Oliveira <bristot@xxxxxxxxxx>
> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: linux-kernel@xxxxxxxxxxxxxxx
>
Acked-by: Steven Rostedt <rostedt@xxxxxxxxxxx>

---
:-)

-- Steve