aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-sched.c
diff options
context:
space:
mode:
authorYunlong Song <yunlong.song@huawei.com>2015-03-31 09:46:36 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-04-08 08:07:27 -0400
commitff5f3bbd40bfb8632f826f1f83223d95363f36af (patch)
tree8b3329a04edab38bf9f048e2307249e1341f2bc3 /tools/perf/builtin-sched.c
parentf0dd330fdf07d295ac468660cf60341796d5d501 (diff)
perf sched replay: Use replay_repeat to calculate the runavg of cpu usage instead of the default value 10
Since sched->replay_repeat is set to 10 as default, the sched->run_avg, sched->runavg_cpu_usage, and sched->runavg_parent_cpu_usage all use 10 to calculate their value. However, the replay_repeat can be changed to other value by using -r option, so the calculation above should use replay_repeat to achieve more accurate results instead of the default value 10. Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1427809596-29559-10-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-sched.c')
-rw-r--r--tools/perf/builtin-sched.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 7b7b798b22b2..5275bab70313 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -607,13 +607,13 @@ static void wait_for_tasks(struct perf_sched *sched)
607 cpu_usage_1 = get_cpu_usage_nsec_parent(); 607 cpu_usage_1 = get_cpu_usage_nsec_parent();
608 if (!sched->runavg_cpu_usage) 608 if (!sched->runavg_cpu_usage)
609 sched->runavg_cpu_usage = sched->cpu_usage; 609 sched->runavg_cpu_usage = sched->cpu_usage;
610 sched->runavg_cpu_usage = (sched->runavg_cpu_usage * 9 + sched->cpu_usage) / 10; 610 sched->runavg_cpu_usage = (sched->runavg_cpu_usage * (sched->replay_repeat - 1) + sched->cpu_usage) / sched->replay_repeat;
611 611
612 sched->parent_cpu_usage = cpu_usage_1 - cpu_usage_0; 612 sched->parent_cpu_usage = cpu_usage_1 - cpu_usage_0;
613 if (!sched->runavg_parent_cpu_usage) 613 if (!sched->runavg_parent_cpu_usage)
614 sched->runavg_parent_cpu_usage = sched->parent_cpu_usage; 614 sched->runavg_parent_cpu_usage = sched->parent_cpu_usage;
615 sched->runavg_parent_cpu_usage = (sched->runavg_parent_cpu_usage * 9 + 615 sched->runavg_parent_cpu_usage = (sched->runavg_parent_cpu_usage * (sched->replay_repeat - 1) +
616 sched->parent_cpu_usage)/10; 616 sched->parent_cpu_usage)/sched->replay_repeat;
617 617
618 ret = pthread_mutex_lock(&sched->start_work_mutex); 618 ret = pthread_mutex_lock(&sched->start_work_mutex);
619 BUG_ON(ret); 619 BUG_ON(ret);
@@ -645,7 +645,7 @@ static void run_one_test(struct perf_sched *sched)
645 sched->sum_fluct += fluct; 645 sched->sum_fluct += fluct;
646 if (!sched->run_avg) 646 if (!sched->run_avg)
647 sched->run_avg = delta; 647 sched->run_avg = delta;
648 sched->run_avg = (sched->run_avg * 9 + delta) / 10; 648 sched->run_avg = (sched->run_avg * (sched->replay_repeat - 1) + delta) / sched->replay_repeat;
649 649
650 printf("#%-3ld: %0.3f, ", sched->nr_runs, (double)delta / 1000000.0); 650 printf("#%-3ld: %0.3f, ", sched->nr_runs, (double)delta / 1000000.0);
651 651