ia64/xen-unstable

changeset 18616:bf78a531eb66

xenpm: Fix logic when Hyperthreading is enabled.

Signed-off-by: Guanqun Lu <guanqun.lu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Oct 13 10:06:33 2008 +0100 (2008-10-13)
parents 0c64c5fe261b
children 0d1875d2e5f2
files tools/misc/xenpm.c
line diff
     1.1 --- a/tools/misc/xenpm.c	Mon Oct 13 10:03:36 2008 +0100
     1.2 +++ b/tools/misc/xenpm.c	Mon Oct 13 10:06:33 2008 +0100
     1.3 @@ -81,11 +81,15 @@ int main(int argc, char **argv)
     1.4              if ( ret )
     1.5              {
     1.6                  if ( errno == ENODEV )
     1.7 +                {
     1.8                      fprintf(stderr, "Xen cpuidle is not enabled!\n");
     1.9 +                    break;
    1.10 +                }
    1.11                  else
    1.12 -                    fprintf(stderr, "failed to get max C-state\n");
    1.13 -
    1.14 -                break;
    1.15 +                {
    1.16 +                    fprintf(stderr, "[CPU%d] failed to get max C-state\n", i);
    1.17 +                    continue;
    1.18 +                }
    1.19              }
    1.20  
    1.21              cxstat->triggers = malloc(max_cx_num * sizeof(uint64_t));
    1.22 @@ -105,15 +109,17 @@ int main(int argc, char **argv)
    1.23              ret = xc_pm_get_cxstat(xc_fd, i, cxstat);
    1.24              if( ret )
    1.25              {
    1.26 -                fprintf(stderr, "failed to get C-states statistics information\n");
    1.27 +                fprintf(stderr, "[CPU%d] failed to get C-states statistics "
    1.28 +                        "information\n", i);
    1.29                  free(cxstat->triggers);
    1.30                  free(cxstat->residencies);
    1.31 -                break;
    1.32 +                continue;
    1.33              }
    1.34  
    1.35              printf("cpu id               : %d\n", i);
    1.36              printf("total C-states       : %d\n", cxstat->nr);
    1.37 -            printf("idle time(ms)        : %"PRIu64"\n", cxstat->idle_time/1000000UL);
    1.38 +            printf("idle time(ms)        : %"PRIu64"\n",
    1.39 +                   cxstat->idle_time/1000000UL);
    1.40              for ( j = 0; j < cxstat->nr; j++ )
    1.41              {
    1.42                  printf("C%d                   : transition [%020"PRIu64"]\n",
    1.43 @@ -138,19 +144,26 @@ int main(int argc, char **argv)
    1.44          for ( i = 0; i < physinfo.nr_cpus; i++ )
    1.45          {
    1.46              ret = xc_pm_get_max_px(xc_fd, i, &max_px_num);
    1.47 -            if ( ret ) {
    1.48 +            if ( ret )
    1.49 +            {
    1.50                  if ( errno == ENODEV )
    1.51 +                {
    1.52                      printf("Xen cpufreq is not enabled!\n");
    1.53 +                    break;
    1.54 +                }
    1.55                  else
    1.56 -                    fprintf(stderr, "failed to get max P-state\n");
    1.57 -
    1.58 -                break;
    1.59 +                {
    1.60 +                    fprintf(stderr, "[CPU%d] failed to get max P-state\n", i);
    1.61 +                    continue;
    1.62 +                }
    1.63              }
    1.64  
    1.65 -            pxstat->trans_pt = malloc(max_px_num * max_px_num * sizeof(uint64_t));
    1.66 +            pxstat->trans_pt = malloc(max_px_num * max_px_num *
    1.67 +                                      sizeof(uint64_t));
    1.68              if ( !pxstat->trans_pt )
    1.69              {
    1.70 -                fprintf(stderr, "failed to malloc for P-states transition table\n");
    1.71 +                fprintf(stderr, "failed to malloc for P-states "
    1.72 +                        "transition table\n");
    1.73                  break;
    1.74              }
    1.75              pxstat->pt = malloc(max_px_num * sizeof(struct xc_px_val));
    1.76 @@ -162,26 +175,32 @@ int main(int argc, char **argv)
    1.77              }
    1.78  
    1.79              ret = xc_pm_get_pxstat(xc_fd, i, pxstat);
    1.80 -            if( ret ) {
    1.81 -                fprintf(stderr, "failed to get P-states statistics information\n");
    1.82 +            if( ret )
    1.83 +            {
    1.84 +                fprintf(stderr, "[CPU%d] failed to get P-states "
    1.85 +                        "statistics information\n", i);
    1.86                  free(pxstat->trans_pt);
    1.87                  free(pxstat->pt);
    1.88 -                break;
    1.89 +                continue;
    1.90              }
    1.91  
    1.92              printf("cpu id               : %d\n", i);
    1.93              printf("total P-states       : %d\n", pxstat->total);
    1.94              printf("usable P-states      : %d\n", pxstat->usable);
    1.95 -            printf("current frequency    : %"PRIu64" MHz\n", pxstat->pt[pxstat->cur].freq);
    1.96 +            printf("current frequency    : %"PRIu64" MHz\n",
    1.97 +                   pxstat->pt[pxstat->cur].freq);
    1.98              for ( j = 0; j < pxstat->total; j++ )
    1.99              {
   1.100                  if ( pxstat->cur == j )
   1.101                      printf("*P%d", j);
   1.102                  else
   1.103                      printf("P%d ", j);
   1.104 -                printf("                  : freq       [%04"PRIu64" MHz]\n", pxstat->pt[j].freq);
   1.105 -                printf("                       transition [%020"PRIu64"]\n", pxstat->pt[j].count);
   1.106 -                printf("                       residency  [%020"PRIu64" ms]\n", pxstat->pt[j].residency/1000000UL);
   1.107 +                printf("                  : freq       [%04"PRIu64" MHz]\n",
   1.108 +                       pxstat->pt[j].freq);
   1.109 +                printf("                       transition [%020"PRIu64"]\n",
   1.110 +                       pxstat->pt[j].count);
   1.111 +                printf("                       residency  [%020"PRIu64" ms]\n",
   1.112 +                       pxstat->pt[j].residency/1000000UL);
   1.113              }
   1.114  
   1.115              free(pxstat->trans_pt);