public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>
Subject: Re: [PATCH] tools lib traceevent: Fix prev/next_prio for deadline tasks
Date: Tue, 3 Jan 2017 11:46:23 -0300	[thread overview]
Message-ID: <20170103144623.GG27864@kernel.org> (raw)
In-Reply-To: <866ef75bcebf670ae91c6a96daa63597ba981f0d.1483443552.git.bristot@redhat.com>

Em Tue, Jan 03, 2017 at 12:42:42PM +0100, Daniel Bristot de Oliveira escreveu:
> From: Daniel Bristot de Oliveiva <bristot@redhat.com>
> 
> 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@redhat.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: linux-kernel@vger.kernel.org

you missed the delimiter here:

---

Without it, I get:

[acme@jouet linux]$ am /wb/1.patch 
Applying: tools lib traceevent: Fix prev/next_prio for deadline tasks
fatal: patch with only garbage at line 3
Patch failed at 0001 tools lib traceevent: Fix prev/next_prio for deadline tasks
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
[acme@jouet linux]$ git am --abort

I added it manually and applied, please consider using 'git format-patch' next time :-)
> 
> diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c
> index f1ce600..ec30c2f 100644
> --- a/tools/lib/traceevent/plugin_sched_switch.c
> +++ b/tools/lib/traceevent/plugin_sched_switch.c
> @@ -111,7 +111,7 @@ static int sched_switch_handler(struct trace_seq *s,
>  	trace_seq_printf(s, "%lld ", val);
>  
>  	if (pevent_get_field_val(s, event, "prev_prio", record, &val, 0) == 0)
> -		trace_seq_printf(s, "[%lld] ", val);
> +		trace_seq_printf(s, "[%d] ", (int) val);
>  
>  	if (pevent_get_field_val(s,  event, "prev_state", record, &val, 0) == 0)
>  		write_state(s, val);
> @@ -129,7 +129,7 @@ static int sched_switch_handler(struct trace_seq *s,
>  	trace_seq_printf(s, "%lld", val);
>  
>  	if (pevent_get_field_val(s, event, "next_prio", record, &val, 0) == 0)
> -		trace_seq_printf(s, " [%lld]", val);
> +		trace_seq_printf(s, " [%d]", (int) val);
>  
>  	return 0;
>  }
> -- 
> 2.9.3

  reply	other threads:[~2017-01-03 14:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-03 11:42 [PATCH] tools lib traceevent: Fix prev/next_prio for deadline tasks Daniel Bristot de Oliveira
2017-01-03 14:46 ` Arnaldo Carvalho de Melo [this message]
2017-01-03 15:01   ` Daniel Bristot de Oliveira
2017-01-03 15:12     ` Arnaldo Carvalho de Melo
2017-01-03 15:29       ` Daniel Bristot de Oliveira
2017-01-03 15:00 ` Steven Rostedt
2017-01-05  7:52 ` [tip:perf/urgent] " tip-bot for Daniel Bristot de Oliveira

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170103144623.GG27864@kernel.org \
    --to=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bristot@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox