perf sched: Fix for getting task's execution time
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Wed, 9 Dec 2009 09:51:30 +0000 (17:51 +0800)
committerIngo Molnar <mingo@elte.hu>
Wed, 9 Dec 2009 09:59:12 +0000 (10:59 +0100)
commitc0c9e72150c07b4a6766cd24a6f685ec2dc9c343
tree1672baebe9ef71d560820e70e3f6865bc6aaaf5b
parent822a6961112f0c9101d3359d8524604c3309ee6c
perf sched: Fix for getting task's execution time

In current code, task's execute time is got by reading
'/proc/<pid>/sched' file, it's wrong if the task is created
by pthread_create(), because every thread task has same pid.

This way also has two demerits:

 1: 'perf sched replay' can't work if the kernel is not
    compiled with the 'CONFIG_SCHED_DEBUG' option

 2: perf tool should depend on proc file system

So, this patch uses PERF_COUNT_SW_TASK_CLOCK to get task's
execution time instead of reading /proc file.

Changelog v2 -> v3:
use PERF_COUNT_SW_TASK_CLOCK instead of rusage() as Ingo's
suggestion

Reported-by: Torok Edwin <edwintorok@gmail.com>
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Cc: Xiao Guangrong <ericxiao.gr@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <4B1F7322.80103@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/builtin-sched.c