direct-io.hg

changeset 12401:9d88f224b7f1

[XENPERF] Pretty-print hypercall stats.
From: Yoshihiko Yaegashi <y.yaegashi@jp.fujitsu.com>
From: Ken Hironaka <kenny@logos.ic.i.u-tokyo.ac.jp>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Nov 14 11:55:58 2006 +0000 (2006-11-14)
parents bcebb04c65c8
children ade94aa072c5
files tools/misc/xenperf.c
line diff
     1.1 --- a/tools/misc/xenperf.c	Tue Nov 14 11:52:38 2006 +0000
     1.2 +++ b/tools/misc/xenperf.c	Tue Nov 14 11:55:58 2006 +0000
     1.3 @@ -10,7 +10,6 @@
     1.4   * Description: 
     1.5   */
     1.6  
     1.7 -
     1.8  #include <xenctrl.h>
     1.9  #include <stdio.h>
    1.10  #include <stdlib.h>
    1.11 @@ -18,6 +17,57 @@
    1.12  #include <errno.h>
    1.13  #include <string.h>
    1.14  
    1.15 +#define X(name) [__HYPERVISOR_##name] = #name
    1.16 +const char *hypercall_name_table[64] =
    1.17 +{
    1.18 +    X(set_trap_table),
    1.19 +    X(mmu_update),
    1.20 +    X(set_gdt),
    1.21 +    X(stack_switch),
    1.22 +    X(set_callbacks),
    1.23 +    X(fpu_taskswitch),
    1.24 +    X(sched_op_compat),
    1.25 +    X(platform_op),
    1.26 +    X(set_debugreg),
    1.27 +    X(get_debugreg),
    1.28 +    X(update_descriptor),
    1.29 +    X(memory_op),
    1.30 +    X(multicall),
    1.31 +    X(update_va_mapping),
    1.32 +    X(set_timer_op),
    1.33 +    X(event_channel_op_compat),
    1.34 +    X(xen_version),
    1.35 +    X(console_io),
    1.36 +    X(physdev_op_compat),
    1.37 +    X(grant_table_op),
    1.38 +    X(vm_assist),
    1.39 +    X(update_va_mapping_otherdomain),
    1.40 +    X(iret),
    1.41 +    X(vcpu_op),
    1.42 +    X(set_segment_base),
    1.43 +    X(mmuext_op),
    1.44 +    X(acm_op),
    1.45 +    X(nmi_op),
    1.46 +    X(sched_op),
    1.47 +    X(callback_op),
    1.48 +    X(xenoprof_op),
    1.49 +    X(event_channel_op),
    1.50 +    X(physdev_op),
    1.51 +    X(hvm_op),
    1.52 +    X(sysctl),
    1.53 +    X(domctl),
    1.54 +    X(kexec_op),
    1.55 +    X(arch_0),
    1.56 +    X(arch_1),
    1.57 +    X(arch_2),
    1.58 +    X(arch_3),
    1.59 +    X(arch_4),
    1.60 +    X(arch_5),
    1.61 +    X(arch_6),
    1.62 +    X(arch_7),
    1.63 +};
    1.64 +#undef X
    1.65 +
    1.66  int lock_pages(void *addr, size_t len)
    1.67  {
    1.68      int e = 0;
    1.69 @@ -30,7 +80,7 @@ int lock_pages(void *addr, size_t len)
    1.70  void unlock_pages(void *addr, size_t len)
    1.71  {
    1.72  #ifndef __sun__
    1.73 -	munlock(addr, len);
    1.74 +    munlock(addr, len);
    1.75  #endif
    1.76  }
    1.77  
    1.78 @@ -38,10 +88,11 @@ int main(int argc, char *argv[])
    1.79  {
    1.80      int              i, j, xc_handle;
    1.81      xc_perfc_desc_t *pcd;
    1.82 -	xc_perfc_val_t  *pcv;
    1.83 -	xc_perfc_val_t  *val;
    1.84 -	int num_desc, num_val;
    1.85 -    unsigned int    sum, reset = 0, full = 0;
    1.86 +    xc_perfc_val_t  *pcv;
    1.87 +    xc_perfc_val_t  *val;
    1.88 +    int num_desc, num_val;
    1.89 +    unsigned int    sum, reset = 0, full = 0, pretty = 0;
    1.90 +    char hypercall_name[36];
    1.91  
    1.92      if ( argc > 1 )
    1.93      {
    1.94 @@ -53,6 +104,10 @@ int main(int argc, char *argv[])
    1.95              case 'f':
    1.96                  full = 1;
    1.97                  break;
    1.98 +            case 'p':
    1.99 +                full = 1;
   1.100 +                pretty = 1;
   1.101 +                break;
   1.102              case 'r':
   1.103                  reset = 1;
   1.104                  break;
   1.105 @@ -66,6 +121,7 @@ int main(int argc, char *argv[])
   1.106              printf("%s: [-r]\n", argv[0]);
   1.107              printf("no args: print digested counters\n");
   1.108              printf("    -f : print full arrays/histograms\n");
   1.109 +            printf("    -p : print full arrays/histograms in pretty format\n");
   1.110              printf("    -r : reset counters\n");
   1.111              return 0;
   1.112          }
   1.113 @@ -91,21 +147,21 @@ int main(int argc, char *argv[])
   1.114          return 0;
   1.115      }
   1.116  
   1.117 -	if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_query,
   1.118 -						  NULL, NULL, &num_desc, &num_val) != 0 )
   1.119 -        {
   1.120 -            fprintf(stderr, "Error getting number of perf counters: %d (%s)\n",
   1.121 -                    errno, strerror(errno));
   1.122 -            return 1;
   1.123 -        }
   1.124 +    if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_query,
   1.125 +                          NULL, NULL, &num_desc, &num_val) != 0 )
   1.126 +    {
   1.127 +        fprintf(stderr, "Error getting number of perf counters: %d (%s)\n",
   1.128 +                errno, strerror(errno));
   1.129 +        return 1;
   1.130 +    }
   1.131  
   1.132      pcd = malloc(sizeof(*pcd) * num_desc);
   1.133 -	pcv = malloc(sizeof(*pcv) * num_val);
   1.134 +    pcv = malloc(sizeof(*pcv) * num_val);
   1.135  
   1.136      if ( pcd == NULL
   1.137 -		 || lock_pages(pcd, sizeof(*pcd) * num_desc) != 0
   1.138 -		 || pcv == NULL
   1.139 -		 || lock_pages(pcd, sizeof(*pcv) * num_val) != 0)
   1.140 +         || lock_pages(pcd, sizeof(*pcd) * num_desc) != 0
   1.141 +         || pcv == NULL
   1.142 +         || lock_pages(pcd, sizeof(*pcv) * num_val) != 0)
   1.143      {
   1.144          fprintf(stderr, "Could not alloc or lock buffers: %d (%s)\n",
   1.145                  errno, strerror(errno));
   1.146 @@ -113,7 +169,7 @@ int main(int argc, char *argv[])
   1.147      }
   1.148  
   1.149      if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_query,
   1.150 -						  pcd, pcv, NULL, NULL) != 0 )
   1.151 +                          pcd, pcv, NULL, NULL) != 0 )
   1.152      {
   1.153          fprintf(stderr, "Error getting perf counter: %d (%s)\n",
   1.154                  errno, strerror(errno));
   1.155 @@ -123,7 +179,7 @@ int main(int argc, char *argv[])
   1.156      unlock_pages(pcd, sizeof(*pcd) * num_desc);
   1.157      unlock_pages(pcv, sizeof(*pcv) * num_val);
   1.158  
   1.159 -	val = pcv;
   1.160 +    val = pcv;
   1.161      for ( i = 0; i < num_desc; i++ )
   1.162      {
   1.163          printf ("%-35s ", pcd[i].name);
   1.164 @@ -134,11 +190,37 @@ int main(int argc, char *argv[])
   1.165          printf ("T=%10u ", (unsigned int)sum);
   1.166  
   1.167          if ( full || (pcd[i].nr_vals <= 4) )
   1.168 -            for ( j = 0; j < pcd[i].nr_vals; j++ )
   1.169 -                printf(" %10u", (unsigned int)val[j]);
   1.170 +        {
   1.171 +            if ( pretty && (strcmp(pcd[i].name, "hypercalls") == 0) )
   1.172 +            {
   1.173 +                printf("\n");
   1.174 +                for( j = 0; j < pcd[i].nr_vals; j++ )
   1.175 +                {
   1.176 +                    if ( val[j] == 0 )
   1.177 +                        continue;
   1.178 +                    if ( (j < 64) && hypercall_name_table[j] )
   1.179 +                        strncpy(hypercall_name, hypercall_name_table[j],
   1.180 +                                sizeof(hypercall_name));
   1.181 +                    else
   1.182 +                        sprintf(hypercall_name, "[%d]", j);
   1.183 +                    hypercall_name[sizeof(hypercall_name)-1]='\0';
   1.184 +                    printf("%-35s ", hypercall_name);
   1.185 +                    printf("%12u\n", (unsigned int)val[j]);
   1.186 +                }
   1.187 +            }
   1.188 +            else
   1.189 +            {
   1.190 +                for ( j = 0; j < pcd[i].nr_vals; j++ )
   1.191 +                    printf(" %10u", (unsigned int)val[j]);
   1.192 +                printf("\n");
   1.193 +            }
   1.194 +        }
   1.195 +        else
   1.196 +        {
   1.197 +            printf("\n");
   1.198 +        }
   1.199  
   1.200 -        printf("\n");
   1.201 -		val += pcd[i].nr_vals;
   1.202 +        val += pcd[i].nr_vals;
   1.203      }
   1.204  
   1.205      return 0;