From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: "Kornievskaia, Olga" <Olga.Kornievskaia@netapp.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: timing information with perf
Date: Thu, 12 Nov 2015 19:04:17 -0300 [thread overview]
Message-ID: <20151112220417.GE7160@kernel.org> (raw)
In-Reply-To: <20151112215728.GD7160@kernel.org>
Em Thu, Nov 12, 2015 at 06:57:28PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Thu, Nov 12, 2015 at 09:07:20PM +0000, Kornievskaia, Olga escreveu:
> > Can somebody tell me if perf can do “timing-of-operation” type of
> > measurement? By that I mean, say there are two tracepoints
> > “foobar_enter” and “foobar_exit”. Each tracepoint logs a timestamp.
> > I’d like to be able to say that on average it takes that many
> > time-units between “enter” and “exit” tracepoints. I haven’t been
> > able to find something like that with “perf”.
> Well, you can do:
>
> # perf record -a -e sched:*waking*,sched:*wakeup* sleep 2
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.199 MB perf.data (156 samples) ]
> # perf script -g python
> generated Python script: perf-script.py
> # grep '^def ' perf-script.py
> def trace_begin():
> def trace_end():
> def sched__sched_wakeup_new(event_name, context, common_cpu,
> def sched__sched_wakeup(event_name, context, common_cpu,
> def sched__sched_waking(event_name, context, common_cpu,
> def trace_unhandled(event_name, context, event_fields_dict):
> def print_header(event_name, cpu, secs, nsecs, pid, comm):
> #
>
> The prototype for sched__sched_wakeup(), for instance is:
>
> def sched__sched_wakeup(event_name, context, common_cpu,
> common_secs, common_nsecs, common_pid, common_comm,
> common_callchain, comm, pid, prio, success,
> target_cpu):
>
> Then do some minimal coding for what you want, because you need
> to match it using some key, i.e. same pid is enough for some cases, for
> others you need pid + fd, etc.
If you do not change that script, then running it will produce:
# perf script -s perf-script.p
in trace_begin
sched__sched_waking 2 09156.170326579 16181 perf comm=perf, pid=16182, prio=120, success=1, target_cpu=3
sched__sched_wakeup 2 09156.170329797 16181 perf comm=perf, pid=16182, prio=120, success=1, target_cpu=3
sched__sched_waking 3 09156.170446653 16182 perf comm=migration/3, pid=28, prio=0, success=1, target_cpu=3
<SNIP>
in trace_end
- Arnaldo
next prev parent reply other threads:[~2015-11-12 22:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-12 21:07 timing information with perf Kornievskaia, Olga
2015-11-12 21:57 ` Arnaldo Carvalho de Melo
2015-11-12 22:04 ` Arnaldo Carvalho de Melo [this message]
2015-11-12 23:19 ` David Ahern
2015-11-12 23:09 ` Kornievskaia, Olga
2015-11-12 23:22 ` David Ahern
2015-11-12 23:34 ` Arnaldo Carvalho de Melo
2015-11-13 17:01 ` Kornievskaia, Olga
2015-11-13 19:47 ` Arnaldo Carvalho de Melo
2015-11-13 21:57 ` Kornievskaia, Olga
2015-11-16 18:08 ` Frank Ch. Eigler
2015-11-17 0:12 ` Arnaldo Carvalho de Melo
2015-11-17 0:30 ` Frank Ch. Eigler
2015-11-17 1:31 ` Arnaldo Carvalho de Melo
2015-11-17 3:57 ` David Ahern
2015-11-17 13:31 ` Frank Ch. Eigler
2015-11-17 13:39 ` Arnaldo Carvalho de Melo
2015-11-17 14:04 ` Frank Ch. Eigler
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=20151112220417.GE7160@kernel.org \
--to=acme@kernel.org \
--cc=Olga.Kornievskaia@netapp.com \
--cc=linux-perf-users@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).