26a031e136
You may want to know where and how long a task is sleeping. A callchain may be found in sched_switch and a time slice in stat_iowait, so I add handler in perf inject for merging this events. My code saves sched_switch event for each process and when it meets stat_iowait, it reports the sched_switch event, because this event contains a correct callchain. By another words it replaces all stat_iowait events on proper sched_switch events. I use the next sequence of commands for testing: perf record -e sched:sched_stat_sleep -e sched:sched_switch \ -e sched:sched_process_exit -g -o ~/perf.data.raw \ ~/test-program perf inject -v -s -i ~/perf.data.raw -o ~/perf.data perf report --stdio -i ~/perf.data 100.00% foo [kernel.kallsyms] [k] __schedule | --- __schedule schedule | |--79.75%-- schedule_hrtimeout_range_clock | schedule_hrtimeout_range | poll_schedule_timeout | do_select | core_sys_select | sys_select | system_call_fastpath | __select | __libc_start_main | --20.25%-- do_nanosleep hrtimer_nanosleep sys_nanosleep system_call_fastpath __GI___libc_nanosleep __libc_start_main And here is test-program.c: #include<unistd.h> #include<time.h> #include<sys/select.h> int main() { struct timespec ts1; struct timeval tv1; int i; long s; for (i = 0; i < 10; i++) { ts1.tv_sec = 0; ts1.tv_nsec = 10000000; nanosleep(&ts1, NULL); tv1.tv_sec = 0; tv1.tv_usec = 40000; select(0, NULL, NULL, NULL,&tv1); } return 1; } Signed-off-by: Andrew Vagin <avagin@openvz.org> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1344344165-369636-4-git-send-email-avagin@openvz.org [ committer note: Made it use evsel->handler ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
47 lines
1.1 KiB
Plaintext
47 lines
1.1 KiB
Plaintext
perf-inject(1)
|
|
==============
|
|
|
|
NAME
|
|
----
|
|
perf-inject - Filter to augment the events stream with additional information
|
|
|
|
SYNOPSIS
|
|
--------
|
|
[verse]
|
|
'perf inject <options>'
|
|
|
|
DESCRIPTION
|
|
-----------
|
|
perf-inject reads a perf-record event stream and repipes it to stdout. At any
|
|
point the processing code can inject other events into the event stream - in
|
|
this case build-ids (-b option) are read and injected as needed into the event
|
|
stream.
|
|
|
|
Build-ids are just the first user of perf-inject - potentially anything that
|
|
needs userspace processing to augment the events stream with additional
|
|
information could make use of this facility.
|
|
|
|
OPTIONS
|
|
-------
|
|
-b::
|
|
--build-ids=::
|
|
Inject build-ids into the output stream
|
|
-v::
|
|
--verbose::
|
|
Be more verbose.
|
|
-i::
|
|
--input=::
|
|
Input file name. (default: stdin)
|
|
-o::
|
|
--output=::
|
|
Output file name. (default: stdout)
|
|
-s::
|
|
--sched-stat::
|
|
Merge sched_stat and sched_switch for getting events where and how long
|
|
tasks slept. sched_switch contains a callchain where a task slept and
|
|
sched_stat contains a timeslice how long a task slept.
|
|
|
|
SEE ALSO
|
|
--------
|
|
linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-archive[1]
|