linux-stable/tools/perf
Andrew Vagin 26a031e136 perf inject: Merge sched_stat_* and sched_switch events
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>
2012-10-26 11:22:25 -02:00
..
arch perf tools: Try to find cross-built objdump path 2012-10-24 14:20:11 -02:00
bench perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
config perf tools: Always show CHK message when doing try-cc 2012-10-26 11:22:24 -02:00
Documentation perf inject: Merge sched_stat_* and sched_switch events 2012-10-26 11:22:25 -02:00
python perf python: Use attr.watermark in twatch.py 2012-01-30 18:38:23 -02:00
scripts perf scripts: Add event_analyzing_sample-record/report 2012-09-17 13:11:15 -03:00
ui Merge branch 'perf/urgent' into perf/core 2012-10-24 10:20:57 +02:00
util perf tools: Don't stop synthesizing threads when one vanishes 2012-10-25 10:37:15 -02:00
.gitignore perf tools: Ignore compiled python binaries 2012-09-07 12:10:58 -03:00
bash_completion perf tools: Complete tracepoint event names 2012-10-04 12:44:52 -03:00
builtin-annotate.c perf tools: Try to find cross-built objdump path 2012-10-24 14:20:11 -02:00
builtin-bench.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
builtin-buildid-cache.c perf buildid-cache: Don't use globals where not needed to 2012-10-02 18:36:35 -03:00
builtin-buildid-list.c perf buildid-list: Don't use globals where not needed to 2012-10-02 18:36:36 -03:00
builtin-diff.c perf event: No need to create a thread when handling PERF_RECORD_EXIT 2012-10-06 16:33:45 -03:00
builtin-evlist.c perf evlist: Don't use globals where not needed to 2012-10-02 18:36:39 -03:00
builtin-help.c perf help: Fix --help for builtins 2012-10-22 12:35:49 -02:00
builtin-inject.c perf inject: Merge sched_stat_* and sched_switch events 2012-10-26 11:22:25 -02:00
builtin-kmem.c perf kmem: Don't use globals where not needed to 2012-10-02 18:36:32 -03:00
builtin-kvm.c perf kvm: Add braces around multi-line statements 2012-10-08 17:15:54 -03:00
builtin-list.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
builtin-lock.c perf lock: Don't use globals where not needed to 2012-10-02 18:36:33 -03:00
builtin-probe.c perf probe: Don't use globals where not needed to 2012-10-02 18:36:37 -03:00
builtin-record.c perf tools: Give user better message if precise is not supported 2012-10-24 14:20:11 -02:00
builtin-report.c perf tools: Try to find cross-built objdump path 2012-10-24 14:20:11 -02:00
builtin-sched.c perf sched: Handle PERF_RECORD_EXIT events 2012-10-06 16:34:03 -03:00
builtin-script.c perf event: No need to create a thread when handling PERF_RECORD_EXIT 2012-10-06 16:33:45 -03:00
builtin-stat.c perf stat: Don't use globals where not needed to 2012-10-02 18:36:29 -03:00
builtin-test.c perf test: Align the 'Ok'/'FAILED!' test results 2012-10-24 15:44:41 -02:00
builtin-timechart.c perf timechart: Don't use globals where not needed to 2012-10-02 18:36:34 -03:00
builtin-top.c perf tools: Give user better message if precise is not supported 2012-10-24 14:20:11 -02:00
builtin-trace.c perf trace: Use sched:sched_stat_runtime to provide a thread summary 2012-10-25 10:57:43 -02:00
builtin.h perf trace: New tool 2012-09-26 20:42:23 -03:00
command-list.txt perf trace: New tool 2012-09-26 20:42:23 -03:00
CREDITS
design.txt perf tools: Update ioctl documentation for PERF_IOC_FLAG_GROUP 2012-05-31 11:38:42 -03:00
Makefile perf tools: Fix LIBELF_MMAP checking 2012-10-26 11:22:24 -02:00
MANIFEST perf kvm: Events analysis tool 2012-09-21 12:51:22 -03:00
perf-archive.sh perf archive: Make 'f' the last parameter for tar 2012-09-17 13:10:42 -03:00
perf.c perf tools: Have the page size value available for all tools 2012-10-06 16:33:14 -03:00
perf.h perf/urgent fixes: 2012-10-20 02:40:26 +02:00