diff options
author | Boris Ostrovsky <boris.ostrovsky@amd.com> | 2012-05-30 09:26:02 +0100 |
---|---|---|
committer | Boris Ostrovsky <boris.ostrovsky@amd.com> | 2012-05-30 09:26:02 +0100 |
commit | de0e85188ca9e240e774f4598139ba92ee5ce4f8 (patch) | |
tree | 473eb83d01440251f193f9514de95a14b6e4b724 | |
parent | 4af64160c580b02f28c992c09d55957cb20a9b91 (diff) | |
download | xen-de0e85188ca9e240e774f4598139ba92ee5ce4f8.tar.gz xen-de0e85188ca9e240e774f4598139ba92ee5ce4f8.tar.bz2 xen-de0e85188ca9e240e774f4598139ba92ee5ce4f8.zip |
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>
Committed-by: Keir Fraser <keir@xen.org>
-rw-r--r-- | tools/misc/xenpm.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index f07a53967f..65876fe370 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -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; |