[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xenpm: Fix logic when Hyperthreading is enabled.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1223888793 -3600
# Node ID bf78a531eb66420ed4119a9bc695de3a76e9a9ce
# Parent  0c64c5fe261b336997e45b444469320d4835f9dc
xenpm: Fix logic when Hyperthreading is enabled.

Signed-off-by: Guanqun Lu <guanqun.lu@xxxxxxxxx>
---
 tools/misc/xenpm.c |   65 ++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 42 insertions(+), 23 deletions(-)

diff -r 0c64c5fe261b -r bf78a531eb66 tools/misc/xenpm.c
--- a/tools/misc/xenpm.c        Mon Oct 13 10:03:36 2008 +0100
+++ b/tools/misc/xenpm.c        Mon Oct 13 10:06:33 2008 +0100
@@ -81,11 +81,15 @@ int main(int argc, char **argv)
             if ( ret )
             {
                 if ( errno == ENODEV )
+                {
                     fprintf(stderr, "Xen cpuidle is not enabled!\n");
-                else
-                    fprintf(stderr, "failed to get max C-state\n");
-
-                break;
+                    break;
+                }
+                else
+                {
+                    fprintf(stderr, "[CPU%d] failed to get max C-state\n", i);
+                    continue;
+                }
             }
 
             cxstat->triggers = malloc(max_cx_num * sizeof(uint64_t));
@@ -105,15 +109,17 @@ int main(int argc, char **argv)
             ret = xc_pm_get_cxstat(xc_fd, i, cxstat);
             if( ret )
             {
-                fprintf(stderr, "failed to get C-states statistics 
information\n");
+                fprintf(stderr, "[CPU%d] failed to get C-states statistics "
+                        "information\n", i);
                 free(cxstat->triggers);
                 free(cxstat->residencies);
-                break;
+                continue;
             }
 
             printf("cpu id               : %d\n", i);
             printf("total C-states       : %d\n", cxstat->nr);
-            printf("idle time(ms)        : %"PRIu64"\n", 
cxstat->idle_time/1000000UL);
+            printf("idle time(ms)        : %"PRIu64"\n",
+                   cxstat->idle_time/1000000UL);
             for ( j = 0; j < cxstat->nr; j++ )
             {
                 printf("C%d                   : transition [%020"PRIu64"]\n",
@@ -138,19 +144,26 @@ int main(int argc, char **argv)
         for ( i = 0; i < physinfo.nr_cpus; i++ )
         {
             ret = xc_pm_get_max_px(xc_fd, i, &max_px_num);
-            if ( ret ) {
+            if ( ret )
+            {
                 if ( errno == ENODEV )
+                {
                     printf("Xen cpufreq is not enabled!\n");
-                else
-                    fprintf(stderr, "failed to get max P-state\n");
-
-                break;
-            }
-
-            pxstat->trans_pt = malloc(max_px_num * max_px_num * 
sizeof(uint64_t));
+                    break;
+                }
+                else
+                {
+                    fprintf(stderr, "[CPU%d] failed to get max P-state\n", i);
+                    continue;
+                }
+            }
+
+            pxstat->trans_pt = malloc(max_px_num * max_px_num *
+                                      sizeof(uint64_t));
             if ( !pxstat->trans_pt )
             {
-                fprintf(stderr, "failed to malloc for P-states transition 
table\n");
+                fprintf(stderr, "failed to malloc for P-states "
+                        "transition table\n");
                 break;
             }
             pxstat->pt = malloc(max_px_num * sizeof(struct xc_px_val));
@@ -162,26 +175,32 @@ int main(int argc, char **argv)
             }
 
             ret = xc_pm_get_pxstat(xc_fd, i, pxstat);
-            if( ret ) {
-                fprintf(stderr, "failed to get P-states statistics 
information\n");
+            if( ret )
+            {
+                fprintf(stderr, "[CPU%d] failed to get P-states "
+                        "statistics information\n", i);
                 free(pxstat->trans_pt);
                 free(pxstat->pt);
-                break;
+                continue;
             }
 
             printf("cpu id               : %d\n", i);
             printf("total P-states       : %d\n", pxstat->total);
             printf("usable P-states      : %d\n", pxstat->usable);
-            printf("current frequency    : %"PRIu64" MHz\n", 
pxstat->pt[pxstat->cur].freq);
+            printf("current frequency    : %"PRIu64" MHz\n",
+                   pxstat->pt[pxstat->cur].freq);
             for ( j = 0; j < pxstat->total; j++ )
             {
                 if ( pxstat->cur == j )
                     printf("*P%d", j);
                 else
                     printf("P%d ", j);
-                printf("                  : freq       [%04"PRIu64" MHz]\n", 
pxstat->pt[j].freq);
-                printf("                       transition [%020"PRIu64"]\n", 
pxstat->pt[j].count);
-                printf("                       residency  [%020"PRIu64" 
ms]\n", pxstat->pt[j].residency/1000000UL);
+                printf("                  : freq       [%04"PRIu64" MHz]\n",
+                       pxstat->pt[j].freq);
+                printf("                       transition [%020"PRIu64"]\n",
+                       pxstat->pt[j].count);
+                printf("                       residency  [%020"PRIu64" ms]\n",
+                       pxstat->pt[j].residency/1000000UL);
             }
 
             free(pxstat->trans_pt);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.