From patchwork Tue Jan 19 10:50:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Crossley X-Patchwork-Id: 8060491 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1AFDF9F8AA for ; Tue, 19 Jan 2016 10:53:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4411A202E6 for ; Tue, 19 Jan 2016 10:53:15 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B28C200F2 for ; Tue, 19 Jan 2016 10:53:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aLTrx-0002Kb-Mg; Tue, 19 Jan 2016 10:50:37 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aLTrw-0002KO-Qx for xen-devel@lists.xen.org; Tue, 19 Jan 2016 10:50:36 +0000 Received: from [193.109.254.147] by server-6.bemta-14.messagelabs.com id 27/15-16618-CF41E965; Tue, 19 Jan 2016 10:50:36 +0000 X-Env-Sender: prvs=819a4078d=malcolm.crossley@citrix.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1453200634!17777104!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 42914 invoked from network); 19 Jan 2016 10:50:35 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-14.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 19 Jan 2016 10:50:35 -0000 X-IronPort-AV: E=Sophos;i="5.22,316,1449532800"; d="scan'208";a="326089652" From: Malcolm Crossley To: , , , Date: Tue, 19 Jan 2016 10:50:31 +0000 Message-ID: <1453200631-11818-1-git-send-email-malcolm.crossley@citrix.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 X-DLP: MIA1 Cc: Malcolm Crossley , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH] xenpm: Add option to report average CPU frequency X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The average is calculated over the period of time from the last xenpm report of the average CPU frequency. Reporting the average CPU frequency helps confirm the level of turbo boost being achieved per CPU. Signed-off-by: Malcolm Crossley --- tools/misc/xenpm.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index 08f2242..40cdd55 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -45,6 +45,8 @@ void show_help(void) "xenpm command list:\n\n" " get-cpuidle-states [cpuid] list cpu idle info of CPU or all\n" " get-cpufreq-states [cpuid] list cpu freq info of CPU or all\n" + " get-cpufreq-average [cpuid] average cpu frequency since last invocation\n" + " for CPU or all\n" " get-cpufreq-para [cpuid] list cpu freq parameter of CPU or all\n" " set-scaling-maxfreq [cpuid] set max cpu frequency on CPU \n" " or all CPUs\n" @@ -296,6 +298,9 @@ static int get_pxstat_by_cpuid(xc_interface *xc_handle, int cpuid, struct xc_px_ return ret; } + +static int *avgfreq; + /* show cpu actual average freq information on CPU cpuid */ static int get_avgfreq_by_cpuid(xc_interface *xc_handle, int cpuid, int *avgfreq) { @@ -343,10 +348,44 @@ void pxstat_func(int argc, char *argv[]) show_pxstat_by_cpuid(xc_handle, cpuid); } +static int show_cpufreq_by_cpuid(xc_interface *xc_handle, int cpuid) +{ + int ret = 0; + + ret = get_avgfreq_by_cpuid(xc_handle, cpuid, &avgfreq[cpuid]); + if ( ret ) + return ret; + + printf("cpu id : %d\n", cpuid); + printf("average cpu frequency: %d\n", avgfreq[cpuid]); + printf("\n"); + return 0; +} + +void cpufreq_func(int argc, char *argv[]) +{ + int cpuid = -1; + + if ( argc > 0 ) + parse_cpuid(argv[0], &cpuid); + + avgfreq = calloc(max_cpu_nr, sizeof(*avgfreq)); + if ( cpuid < 0 ) + { + /* show average frequency on all cpus */ + int i; + for ( i = 0; i < max_cpu_nr; i++ ) + if ( show_cpufreq_by_cpuid(xc_handle, i) == -ENODEV ) + break; + } + else + show_cpufreq_by_cpuid(xc_handle, cpuid); + free(avgfreq); +} + static uint64_t usec_start, usec_end; static struct xc_cx_stat *cxstat, *cxstat_start, *cxstat_end; static struct xc_px_stat *pxstat, *pxstat_start, *pxstat_end; -static int *avgfreq; static uint64_t *sum, *sum_cx, *sum_px; static void signal_int_handler(int signo) @@ -1129,6 +1168,7 @@ struct { { "help", help_func }, { "get-cpuidle-states", cxstat_func }, { "get-cpufreq-states", pxstat_func }, + { "get-cpufreq-average", cpufreq_func }, { "start", start_gather_func }, { "get-cpufreq-para", cpufreq_para_func }, { "set-scaling-maxfreq", scaling_max_freq_func },