ia64/xen-unstable

changeset 14903:8ff0df8ad587

[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>
author Tim Deegan <Tim.Deegan@xensource.com>
date Tue Apr 24 11:39:13 2007 +0100 (2007-04-24)
parents fe4784ff9fd3
children a7bd11fd5b1b
files xen/common/perfc.c
line diff
     1.1 --- a/xen/common/perfc.c	Tue Apr 24 10:34:47 2007 +0100
     1.2 +++ b/xen/common/perfc.c	Tue Apr 24 11:39:13 2007 +0100
     1.3 @@ -48,6 +48,8 @@ void perfc_printall(unsigned char key)
     1.4          case TYPE_S_SINGLE:
     1.5              for_each_online_cpu ( cpu )
     1.6                  sum += per_cpu(perfcounters, cpu)[j];
     1.7 +            if ( perfc_info[i].type == TYPE_S_SINGLE ) 
     1.8 +                sum = (perfc_t) sum;
     1.9              printk("TOTAL[%12Lu]", sum);
    1.10              if ( sum )
    1.11              {
    1.12 @@ -71,6 +73,8 @@ void perfc_printall(unsigned char key)
    1.13                  for ( k = 0; k < perfc_info[i].nr_elements; k++ )
    1.14                      sum += counters[k];
    1.15              }
    1.16 +            if ( perfc_info[i].type == TYPE_S_ARRAY ) 
    1.17 +                sum = (perfc_t) sum;
    1.18              printk("TOTAL[%12Lu]", sum);
    1.19              if (sum)
    1.20              {
    1.21 @@ -80,6 +84,8 @@ void perfc_printall(unsigned char key)
    1.22                      sum = 0;
    1.23                      for_each_online_cpu ( cpu )
    1.24                          sum += per_cpu(perfcounters, cpu)[j + k];
    1.25 +                    if ( perfc_info[i].type == TYPE_S_ARRAY ) 
    1.26 +                        sum = (perfc_t) sum;
    1.27                      if ( (k % 4) == 0 )
    1.28                          printk("\n%16s", "");
    1.29                      printk("  ARR%02u[%10Lu]", k, sum);
    1.30 @@ -94,6 +100,8 @@ void perfc_printall(unsigned char key)
    1.31                      sum = 0;
    1.32                      for ( n = 0; n < perfc_info[i].nr_elements; n++ )
    1.33                          sum += counters[n];
    1.34 +                    if ( perfc_info[i].type == TYPE_S_ARRAY ) 
    1.35 +                        sum = (perfc_t) sum;
    1.36                      if ( k > 0 && (k % 4) == 0 )
    1.37                          printk("\n%46s", "");
    1.38                      printk("  CPU%02u[%10Lu]", cpu, sum);