From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932469AbbDHPOU (ORCPT ); Wed, 8 Apr 2015 11:14:20 -0400 Received: from terminus.zytor.com ([198.137.202.10]:40337 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932109AbbDHPOP (ORCPT ); Wed, 8 Apr 2015 11:14:15 -0400 Date: Wed, 8 Apr 2015 08:13:56 -0700 From: tip-bot for Yunlong Song Message-ID: Cc: mingo@kernel.org, wangnan0@huawei.com, paulus@samba.org, a.p.zijlstra@chello.nl, yunlong.song@huawei.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, acme@redhat.com, hpa@zytor.com Reply-To: yunlong.song@huawei.com, wangnan0@huawei.com, paulus@samba.org, mingo@kernel.org, a.p.zijlstra@chello.nl, acme@redhat.com, hpa@zytor.com, tglx@linutronix.de, linux-kernel@vger.kernel.org In-Reply-To: <1427809596-29559-10-git-send-email-yunlong.song@huawei.com> References: <1427809596-29559-10-git-send-email-yunlong.song@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf sched replay: Use replay_repeat to calculate the runavg of cpu usage instead of the default value 10 Git-Commit-ID: ff5f3bbd40bfb8632f826f1f83223d95363f36af X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: ff5f3bbd40bfb8632f826f1f83223d95363f36af Gitweb: http://git.kernel.org/tip/ff5f3bbd40bfb8632f826f1f83223d95363f36af Author: Yunlong Song AuthorDate: Tue, 31 Mar 2015 21:46:36 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 8 Apr 2015 09:07:27 -0300 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 Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1427809596-29559-10-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-sched.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 7b7b798..5275bab 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) cpu_usage_1 = get_cpu_usage_nsec_parent(); if (!sched->runavg_cpu_usage) sched->runavg_cpu_usage = sched->cpu_usage; - sched->runavg_cpu_usage = (sched->runavg_cpu_usage * 9 + sched->cpu_usage) / 10; + sched->runavg_cpu_usage = (sched->runavg_cpu_usage * (sched->replay_repeat - 1) + sched->cpu_usage) / sched->replay_repeat; sched->parent_cpu_usage = cpu_usage_1 - cpu_usage_0; if (!sched->runavg_parent_cpu_usage) sched->runavg_parent_cpu_usage = sched->parent_cpu_usage; - sched->runavg_parent_cpu_usage = (sched->runavg_parent_cpu_usage * 9 + - sched->parent_cpu_usage)/10; + sched->runavg_parent_cpu_usage = (sched->runavg_parent_cpu_usage * (sched->replay_repeat - 1) + + sched->parent_cpu_usage)/sched->replay_repeat; ret = pthread_mutex_lock(&sched->start_work_mutex); BUG_ON(ret); @@ -645,7 +645,7 @@ static void run_one_test(struct perf_sched *sched) sched->sum_fluct += fluct; if (!sched->run_avg) sched->run_avg = delta; - sched->run_avg = (sched->run_avg * 9 + delta) / 10; + sched->run_avg = (sched->run_avg * (sched->replay_repeat - 1) + delta) / sched->replay_repeat; printf("#%-3ld: %0.3f, ", sched->nr_runs, (double)delta / 1000000.0);