xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@amd.com>
To: keir@xen.org
Cc: boris.ostrovsky@amd.com, xen-devel@lists.xensource.com
Subject: [PATCH] xenpm: Fix reporting of C0 residence times
Date: Tue, 29 May 2012 18:48:00 +0200	[thread overview]
Message-ID: <3d52d9fe62559ed6f90c.1338310080@wotan.osrc.amd.com> (raw)

# HG changeset patch
# User Boris Ostrovsky <boris.ostrovsky@amd.com>
# Date 1338309680 -7200
# Node ID 3d52d9fe62559ed6f90cb33a4b95f536ab5bc683
# Parent  53e0571f94e4bcc45270dcbd444c7c91166cef6d
xenpm: Fix reporting of C0 residence times

Idle state residence times as provided by pmstat_get_cx_stat() are not
reported precisely since remote core may be in idle state and therefore
has not updated its statistics at the time local core collected them.
This causes C0 residencies as calculated by xenpm to sometimes become
negative.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@amd.com>

diff -r 53e0571f94e4 -r 3d52d9fe6255 tools/misc/xenpm.c
--- a/tools/misc/xenpm.c	Fri May 25 08:21:25 2012 +0100
+++ b/tools/misc/xenpm.c	Tue May 29 18:41:20 2012 +0200
@@ -351,8 +351,12 @@ static void signal_int_handler(int signo
         for ( i = 0; i < max_cpu_nr; i++ )
             if ( !get_cxstat_by_cpuid(xc_handle, i, &cxstat_end[i]) )
                 for ( j = 0; j < cxstat_end[i].nr; j++ )
-                    sum_cx[i] += cxstat_end[i].residencies[j] -
-                                 cxstat_start[i].residencies[j];
+                {
+                    int64_t diff = (int64_t)cxstat_end[i].residencies[j] -
+                        (int64_t)cxstat_start[i].residencies[j];
+                    if ( diff >=0 )
+                        sum_cx[i] += diff;
+                }
     }
 
     if ( get_pxstat_by_cpuid(xc_handle, 0, NULL) != -ENODEV )
@@ -379,8 +383,10 @@ static void signal_int_handler(int signo
         {
             for ( j = 0; j < cxstat_end[i].nr; j++ )
             {
-                res = cxstat_end[i].residencies[j] -
-                    cxstat_start[i].residencies[j];
+                int64_t diff = (int64_t)cxstat_end[i].residencies[j] -
+                    (int64_t)cxstat_start[i].residencies[j];
+
+                res = ( diff >= 0 ) ? diff : 0;
                 triggers = cxstat_end[i].triggers[j] -
                     cxstat_start[i].triggers[j];
                 avg_res = (triggers==0) ? 0: (double)res/triggers/1000000.0;

                 reply	other threads:[~2012-05-29 16:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3d52d9fe62559ed6f90c.1338310080@wotan.osrc.amd.com \
    --to=boris.ostrovsky@amd.com \
    --cc=keir@xen.org \
    --cc=xen-devel@lists.xensource.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).