aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/perfc.c
diff options
context:
space:
mode:
authorTim Deegan <Tim.Deegan@xensource.com>2007-04-24 11:39:13 +0100
committerTim Deegan <Tim.Deegan@xensource.com>2007-04-24 11:39:13 +0100
commitd2158ada297628242fb87863c11bf25e1031193e (patch)
treec24ee98cdf964799b94be5e6380b6d3c81283256 /xen/common/perfc.c
parent7f804c918cc7078909c50917cd1b89c9264f344a (diff)
downloadxen-d2158ada297628242fb87863c11bf25e1031193e.tar.gz
xen-d2158ada297628242fb87863c11bf25e1031193e.tar.bz2
xen-d2158ada297628242fb87863c11bf25e1031193e.zip
[XEN] Truncate arithmetic for PERFSTATUS counters to the width of perfc_t.
Since these are all calculated per-cpu now, a status counter that is incremented on one cpu and decremented on another will underflow on the decrement. When we add the per-cpu values to get the total, if we don't truncate the sum it will be max-perfc + 1 instead of zero. Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
Diffstat (limited to 'xen/common/perfc.c')
-rw-r--r--xen/common/perfc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/xen/common/perfc.c b/xen/common/perfc.c
index 11e445a0fc..535a1c7092 100644
--- a/xen/common/perfc.c
+++ b/xen/common/perfc.c
@@ -48,6 +48,8 @@ void perfc_printall(unsigned char key)
case TYPE_S_SINGLE:
for_each_online_cpu ( cpu )
sum += per_cpu(perfcounters, cpu)[j];
+ if ( perfc_info[i].type == TYPE_S_SINGLE )
+ sum = (perfc_t) sum;
printk("TOTAL[%12Lu]", sum);
if ( sum )
{
@@ -71,6 +73,8 @@ void perfc_printall(unsigned char key)
for ( k = 0; k < perfc_info[i].nr_elements; k++ )
sum += counters[k];
}
+ if ( perfc_info[i].type == TYPE_S_ARRAY )
+ sum = (perfc_t) sum;
printk("TOTAL[%12Lu]", sum);
if (sum)
{
@@ -80,6 +84,8 @@ void perfc_printall(unsigned char key)
sum = 0;
for_each_online_cpu ( cpu )
sum += per_cpu(perfcounters, cpu)[j + k];
+ if ( perfc_info[i].type == TYPE_S_ARRAY )
+ sum = (perfc_t) sum;
if ( (k % 4) == 0 )
printk("\n%16s", "");
printk(" ARR%02u[%10Lu]", k, sum);
@@ -94,6 +100,8 @@ void perfc_printall(unsigned char key)
sum = 0;
for ( n = 0; n < perfc_info[i].nr_elements; n++ )
sum += counters[n];
+ if ( perfc_info[i].type == TYPE_S_ARRAY )
+ sum = (perfc_t) sum;
if ( k > 0 && (k % 4) == 0 )
printk("\n%46s", "");
printk(" CPU%02u[%10Lu]", cpu, sum);