aboutsummaryrefslogtreecommitdiffstats
path: root/tools/misc
diff options
context:
space:
mode:
authorBoris Ostrovsky <boris.ostrovsky@amd.com>2012-06-06 16:34:53 +0100
committerBoris Ostrovsky <boris.ostrovsky@amd.com>2012-06-06 16:34:53 +0100
commitdb48465811a8d983a349d7b8a96c16f6adf942dc (patch)
tree4bf04732ef38011c3013bc4684dcd4643041a7f9 /tools/misc
parentbf3ffa30a023fed127fa5cfc0d52f6844e244561 (diff)
downloadxen-db48465811a8d983a349d7b8a96c16f6adf942dc.tar.gz
xen-db48465811a8d983a349d7b8a96c16f6adf942dc.tar.bz2
xen-db48465811a8d983a349d7b8a96c16f6adf942dc.zip
xenpm, x86: Fix reporting of idle state average residency times
If CPU stays in the same idle state for the full duration of xenpm sample then average residency may not be reported correctly since usage counter will not be incremented. In addition, in order to calculate averages correctly residence time and usage counter should be read and written atomically. Signed-off-by: Boris Ostrovsky <boris.ostrovsky@amd.com> Committed-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'tools/misc')
-rw-r--r--tools/misc/xenpm.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c
index 65876fe370..e6fa942828 100644
--- a/tools/misc/xenpm.c
+++ b/tools/misc/xenpm.c
@@ -389,7 +389,14 @@ static void signal_int_handler(int signo)
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;
+ /*
+ * triggers may be zero if the CPU has been in this state for
+ * the whole sample or if it never entered the state
+ */
+ if ( triggers == 0 && cxstat_end[i].last == j )
+ avg_res = (double)sum_cx[i]/1000000.0;
+ else
+ avg_res = (triggers==0) ? 0: (double)res/triggers/1000000.0;
printf(" C%d\t%"PRIu64"\t(%5.2f%%)\t%.2f\n", j, res/1000000UL,
100 * res / (double)sum_cx[i], avg_res );
}