Skip to contentSkip to conversation

x86: adjust ptwr_eip_stat printing

PATCH New Jan Beulich 1 participant 1 message May 2, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: adjust ptwr_eip_stat printing

This patch changes to format in which EIP is printed to be consistent on 64-bit regardless of whether the addresses leading bits are set or clear. It additionally changes the formatting so that trailing spaces are avoided, and it suppresses the printing of empty records. It also prevents combining records with identical EIP but from different domains.

It further changes the type of some variables from plain int to unsigned int, as that is yielding more efficient code on x86-64 (signed 32-bit array indices require explicit sign extension, whereas in most cases an extra copy can be avoided when the index type is unsigned, since all 32-bit operations already zero-extend their results).

xen/arch/x86/mm.c renamed from xen/arch/x86/mm.c.0 +8 -8
@@ -2917,7 +2917,7 @@ static inline unsigned int ptwr_eip_stat
 
 static void ptwr_eip_stat_inc(u32 *n)
 {
-    int i, j;
+    unsigned int i, j;
 
     if ( ++(*n) != 0 )
         return;
@@ -2925,14 +2925,14 @@ static void ptwr_eip_stat_inc(u32 *n)
     *n = ~0;
 
     /* Re-scale all buckets. */
-    for ( i = 0; i <ptwr_eip_buckets; i++ )
+    for ( i = 0; i < ptwr_eip_buckets; i++ )
         for ( j = 0; j < ptwr_eip_stat_thresholdN; j++ )
             ptwr_eip_stats[i].val[j] >>= 1;
 }
 
 static void ptwr_eip_stat_update(unsigned long eip, domid_t id, int modified)
 {
-    int i, j, b;
+    unsigned int i, j, b;
 
     i = b = ptwr_eip_stat_hash(eip, id);
 
@@ -2946,7 +2946,7 @@ static void ptwr_eip_stat_update(unsigne
             memset(ptwr_eip_stats[i].val,0, sizeof(ptwr_eip_stats[i].val));
         }
 
-        if ( ptwr_eip_stats[i].eip == eip )
+        if ( ptwr_eip_stats[i].eip == eip && ptwr_eip_stats[i].id == id)
         {
             for ( j = 0; j < ptwr_eip_stat_thresholdN; j++ )
                 if ( modified <= ptwr_eip_stat_threshold[j] )
@@ -2975,7 +2975,7 @@ void ptwr_eip_stat_print(void)
 {
     struct domain *e;
     domid_t d;
-    int i, j;
+    unsigned int i, j;
 
     for_each_domain( e )
     {
@@ -2983,11 +2983,11 @@ void ptwr_eip_stat_print(void)
 
         for ( i = 0; i < ptwr_eip_buckets; i++ )
         {
-            if ( ptwr_eip_stats[i].eip && ptwr_eip_stats[i].id != d )
+            if ( !ptwr_eip_stats[i].eip || ptwr_eip_stats[i].id != d )
                 continue;
 
-            printk("D %d  eip %08lx ",
-                   ptwr_eip_stats[i].id, ptwr_eip_stats[i].eip);
+            printk("D %5d  eip %p ",
+                   ptwr_eip_stats[i].id, (void *)ptwr_eip_stats[i].eip);
 
             for ( j = 0; j < ptwr_eip_stat_thresholdN; j++ )
                 printk("<=%u %4u \t",

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel