Re: Unable to use tools/perf sched and timechart correctly

From: Peter Zijlstra
Date: Sun Dec 06 2009 - 05:55:23 EST


On Sun, 2009-12-06 at 18:41 +0800, Xiao Guangrong wrote:

> You should enable "CONFIG_SCHED_DEBUG", because we use
> "/proc/<pid>/sched" file to get the task's cpu usage.
>
> Ingo, I think we do better show the reason about this error,
> just like:
>
> ---
> tools/perf/builtin-sched.c | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index 26b782f..f823631 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -427,7 +427,11 @@ static u64 get_cpu_usage_nsec_self(void)
>
> sprintf(filename, "/proc/%d/sched", getpid());
> file = fopen(filename, "r");
> - BUG_ON(!file);
> + if (!file)
> + {
> + printf("You should compile your kernel with CONFIG_SCHED_DEBUG option\n");
> + BUG_ON(1);
> + }
>
> while ((chars = getline(&line, &len, file)) != -1) {
> ret = sscanf(line, "se.sum_exec_runtime : %ld.%06ld\n",

Hrmm, we shouldn't be using a proc file at all, the best solution is to
remove this dependency.



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/