All of lore.kernel.org
 help / color / mirror / Atom feed
From: Malcolm Crossley <malcolm.crossley@citrix.com>
To: ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com,
	ian.campbell@citrix.com, wei.liu2@citrix.com
Cc: Malcolm Crossley <malcolm.crossley@citrix.com>, xen-devel@lists.xen.org
Subject: [PATCH] xenpm: Add option to report average CPU frequency
Date: Tue, 19 Jan 2016 10:50:31 +0000	[thread overview]
Message-ID: <1453200631-11818-1-git-send-email-malcolm.crossley@citrix.com> (raw)

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 <malcolm.crossley@citrix.com>
---
 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 <cpuid> or all\n"
             " get-cpufreq-states    [cpuid]       list cpu freq info of CPU <cpuid> or all\n"
+            " get-cpufreq-average   [cpuid]       average cpu frequency since last invocation\n"
+            "                                     for CPU <cpuid> or all\n"
             " get-cpufreq-para      [cpuid]       list cpu freq parameter of CPU <cpuid> or all\n"
             " set-scaling-maxfreq   [cpuid] <HZ>  set max cpu frequency <HZ> on CPU <cpuid>\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 },
-- 
1.7.12.4

             reply	other threads:[~2016-01-19 10:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19 10:50 Malcolm Crossley [this message]
2016-01-19 11:06 ` [PATCH] xenpm: Add option to report average CPU frequency Ian Campbell
2016-01-19 11:10   ` Malcolm Crossley
2016-01-19 11:35     ` Ian Campbell
2016-01-19 11:39       ` Malcolm Crossley
2016-01-19 11:16 ` Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453200631-11818-1-git-send-email-malcolm.crossley@citrix.com \
    --to=malcolm.crossley@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.