ia64/xen-unstable

changeset 216:65d6d97ffcfb

bitkeeper revision 1.64.1.1 (3e54c38ebC53Nz1rWkbaiI8fc1aa6g)

Add performance counters.
Change keyboard handler keys
Hit 'p' to print performance counters
Hit 'R' to reboot rather than 'r'
Hit 'F1' to toggle keyboard echo
author iap10@labyrinth.cl.cam.ac.uk
date Thu Feb 20 12:01:18 2003 +0000 (2003-02-20)
parents 6cdebb6f9876
children 48f852d4241d
files .rootkeys xen-2.4.16/common/keyhandler.c xen-2.4.16/common/perfc.c xen-2.4.16/drivers/block/xen_block.c xen-2.4.16/drivers/char/xen_kbd.c xen-2.4.16/include/xeno/perfc.h xen-2.4.16/include/xeno/perfc_defn.h
line diff
     1.1 --- a/.rootkeys	Mon Feb 17 13:35:17 2003 +0000
     1.2 +++ b/.rootkeys	Thu Feb 20 12:01:18 2003 +0000
     1.3 @@ -58,6 +58,7 @@ 3ddb79bduhSEZI8xa7IbGQCpap5y2A xen-2.4.1
     1.4  3ddb79bdS39UXxUtZnaScie83-7VTQ xen-2.4.16/common/memory.c
     1.5  3ddb79bdN51qpRC-6bOH-v5hl_AK6A xen-2.4.16/common/network.c
     1.6  3ddb79bdD4SLmmdMD7yLW5HcUWucXw xen-2.4.16/common/page_alloc.c
     1.7 +3e54c38dkHAev597bPr71-hGzTdocg xen-2.4.16/common/perfc.c
     1.8  3ddb79bdHqdQpATqC0rmUZNbsb6L6A xen-2.4.16/common/resource.c
     1.9  3e397e6619PgAfBbw2XFbXkewvUWgw xen-2.4.16/common/schedule.c
    1.10  3ddb79bdB9RNMnkQnUyZ5C9hhMSQQw xen-2.4.16/common/slab.c
    1.11 @@ -241,6 +242,8 @@ 3ddb79c0CLfAlJLg1ohdPD-Jjn-jxg xen-2.4.1
    1.12  3e4540ccaugeWGdOuphJKj6WFw1jkw xen-2.4.16/include/xeno/notifier.h
    1.13  3ddb79c2Fg44_PBPVxHSC0gTOMq4Ow xen-2.4.16/include/xeno/pci.h
    1.14  3ddb79c0MOVXq8qZDQRGb6z64_xAwg xen-2.4.16/include/xeno/pci_ids.h
    1.15 +3e54c38dlSCVdyVM4PKcrSfzLLxWUQ xen-2.4.16/include/xeno/perfc.h
    1.16 +3e54c38de9SUSYSAwxDf_DwkpAnQFA xen-2.4.16/include/xeno/perfc_defn.h
    1.17  3ddb79c2byJwwNNkiES__A9H4Cvc4g xen-2.4.16/include/xeno/pkt_sched.h
    1.18  3ddb79c04nQVR3EYM5L4zxDV_MCo1g xen-2.4.16/include/xeno/prefetch.h
    1.19  3e4540ccU1sgCx8seIMGlahmMfv7yQ xen-2.4.16/include/xeno/reboot.h
     2.1 --- a/xen-2.4.16/common/keyhandler.c	Mon Feb 17 13:35:17 2003 +0000
     2.2 +++ b/xen-2.4.16/common/keyhandler.c	Thu Feb 20 12:01:18 2003 +0000
     2.3 @@ -1,6 +1,8 @@
     2.4  #include <xeno/keyhandler.h> 
     2.5  #include <xeno/reboot.h>
     2.6  
     2.7 +extern void perfc_printall (u_char key, void *dev_id, struct pt_regs *regs);
     2.8 +
     2.9  #define KEY_MAX 256
    2.10  #define STR_MAX  64
    2.11  
    2.12 @@ -120,8 +122,9 @@ void initialize_keytable()
    2.13      /* setup own handlers */
    2.14      add_key_handler('d', dump_registers, "dump registers"); 
    2.15      add_key_handler('h', show_handlers, "show this message");
    2.16 +    add_key_handler('p', perfc_printall, "print performance counters"); 
    2.17      add_key_handler('q', do_task_queues, "dump task queues + guest state");
    2.18 -    add_key_handler('r', halt_machine, "reboot machine ungracefully"); 
    2.19 +    add_key_handler('R', halt_machine, "reboot machine ungracefully"); 
    2.20      
    2.21      return; 
    2.22  }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xen-2.4.16/common/perfc.c	Thu Feb 20 12:01:18 2003 +0000
     3.3 @@ -0,0 +1,81 @@
     3.4 +/*
     3.5 + * xen performance counters
     3.6 + */
     3.7 +
     3.8 +#include <xeno/perfc.h>
     3.9 +#include <xeno/keyhandler.h> 
    3.10 +
    3.11 +#define PERFCOUNTER( var, name ) "[0]"name"\0",
    3.12 +#define PERFCOUNTER_ARRAY( var, name, size )  "["#size"]"name"\0",
    3.13 +
    3.14 +char* perfc_name[] = {
    3.15 +#include <xeno/perfc_defn.h>
    3.16 +};
    3.17 +
    3.18 +struct perfcounter_t perfcounters;
    3.19 +
    3.20 +void __perfc_print (unsigned long counter[], int offset)
    3.21 +{
    3.22 +  int loop;
    3.23 +  int total_size = 0;
    3.24 +  int element_size = 0;
    3.25 +  int num;
    3.26 +
    3.27 +  for (loop = 0; loop < sizeof(perfc_name) / sizeof(char *); loop++)
    3.28 +  {
    3.29 +    num = sscanf (perfc_name[loop], "[%d]", &element_size);
    3.30 +    total_size += element_size == 0 ? 1 : element_size;
    3.31 +    if (total_size > offset) break;
    3.32 +  }
    3.33 +  if (loop == sizeof(perfc_name) / sizeof(char *))
    3.34 +  {
    3.35 +    printf ("error: couldn't find variable\n"); 
    3.36 +    return;
    3.37 +  }
    3.38 +  if (element_size == 0)                                   /* single counter */
    3.39 +  {
    3.40 +    printf ("%10ld  0x%08lx  %s\n", counter[0], counter[0],
    3.41 +	    perfc_name[loop] + 2 + num);
    3.42 +  }
    3.43 +  else                                                  /* show entire array */
    3.44 +  {
    3.45 +    for (loop = 0; loop < element_size; loop++)
    3.46 +    {
    3.47 +      printf ("%10ld  0x%08lx  %s:%d\n", 
    3.48 +	      counter[loop], counter[loop], 
    3.49 +	      perfc_name[loop] + 2 + num, loop);
    3.50 +    }
    3.51 +  }
    3.52 +  return;
    3.53 +}
    3.54 +
    3.55 +void perfc_printall (u_char key, void *dev_id, struct pt_regs *regs)
    3.56 +{
    3.57 +  int loop, idx;
    3.58 +  int element_size;
    3.59 +  int num;
    3.60 +  unsigned long *counters = (unsigned long *)&perfcounters;
    3.61 +
    3.62 +  printf ("xen performance counters\n");
    3.63 +  for (loop = 0; loop < sizeof(perfc_name) / sizeof(char *); loop++)
    3.64 +  {
    3.65 +    num = sscanf (perfc_name[loop], "[%d]", &element_size);
    3.66 +    
    3.67 +    for (idx = 0; idx < (element_size ? element_size : 1); idx++)
    3.68 +    {
    3.69 +      if (element_size)
    3.70 +      {
    3.71 +	printf ("%10ld  0x%08lx  %s:%d\n", 
    3.72 +		*counters, *counters, perfc_name[loop] + num + 2, idx);
    3.73 +      }
    3.74 +      else
    3.75 +      {
    3.76 +	printf ("%10ld  0x%08lx  %s\n", 
    3.77 +		*counters, *counters, perfc_name[loop] + num + 2);
    3.78 +      }
    3.79 +      counters++;
    3.80 +    }
    3.81 +  }
    3.82 +
    3.83 +  return;
    3.84 +}
     4.1 --- a/xen-2.4.16/drivers/block/xen_block.c	Mon Feb 17 13:35:17 2003 +0000
     4.2 +++ b/xen-2.4.16/drivers/block/xen_block.c	Thu Feb 20 12:01:18 2003 +0000
     4.3 @@ -14,6 +14,7 @@
     4.4  #include <hypervisor-ifs/hypervisor-if.h>
     4.5  #include <asm-i386/io.h>
     4.6  #include <asm/spinlock.h>
     4.7 +#include <xeno/perfc.h>                              /* performance counters */
     4.8  
     4.9  #include <xeno/keyhandler.h>
    4.10  
    4.11 @@ -118,6 +119,8 @@ void flush_blk_queue(void)
    4.12  	blk_request = list_entry(io_done_queue.next, blk_request_t, queue);
    4.13  	list_del (&blk_request->queue);
    4.14  	spin_unlock_irqrestore(&io_done_queue_lock, flags);
    4.15 +
    4.16 +	perf_incr(blockio_rx);
    4.17  	
    4.18  	/* place on ring for guest os */ 
    4.19  	blk_ring = blk_request->domain->blk_ring_base;
    4.20 @@ -211,6 +214,7 @@ long do_block_io_op_domain (struct task_
    4.21  	 loop != blk_ring->btx_prod; 
    4.22  	 loop = BLK_TX_RING_INC(loop)) {
    4.23  
    4.24 +	perf_incr(blockio_tx);
    4.25  	status = 1;
    4.26  
    4.27  	switch (blk_ring->btx_ring[loop].operation) {
     5.1 --- a/xen-2.4.16/drivers/char/xen_kbd.c	Mon Feb 17 13:35:17 2003 +0000
     5.2 +++ b/xen-2.4.16/drivers/char/xen_kbd.c	Thu Feb 20 12:01:18 2003 +0000
     5.3 @@ -25,6 +25,7 @@
     5.4  
     5.5  static int keyboard_shift = 0;
     5.6  static int keyboard_control = 0;
     5.7 +static int keyboard_echo = 0;
     5.8  
     5.9  /* the following is pretty gross... 
    5.10   * stop reading if you don't want to throw up!
    5.11 @@ -107,6 +108,10 @@ static unsigned char convert_scancode (u
    5.12  
    5.13      switch (scancode) {
    5.14  
    5.15 +    case 0xbb: /* F1 */
    5.16 +	keyboard_echo = !keyboard_echo;
    5.17 +	break;
    5.18 +
    5.19      case 0xba: /* caps lock UP */
    5.20      case 0x9d: /* ctrl (left) UP */
    5.21  	keyboard_control = 0;
    5.22 @@ -137,7 +142,7 @@ static unsigned char convert_scancode (u
    5.23  
    5.24      }
    5.25  
    5.26 -    if (value) printk ("%c", value);
    5.27 +    if (value && keyboard_echo) printk ("%c", value);
    5.28  
    5.29      return value;
    5.30  }
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/xen-2.4.16/include/xeno/perfc.h	Thu Feb 20 12:01:18 2003 +0000
     6.3 @@ -0,0 +1,43 @@
     6.4 +/*
     6.5 + * xen performance counters
     6.6 + */
     6.7 +
     6.8 +/* 
     6.9 + * NOTE: new counters must be defined in xen_perf_defn.h
    6.10 + * 
    6.11 + * PERFCOUNTER (counter, string)              define a new performance counter
    6.12 + * PERFCOUNTER_ARRY (counter, string, size)   define an array of counters
    6.13 + * 
    6.14 + * unsigned long perfc_value  (counter)        get value of a counter  
    6.15 + * unsigned long perfc_valuea (counter, index) get value of an array counter
    6.16 + * void perfc_incr   (counter)                 increment a counter          
    6.17 + * void perfc_incra  (counter, index)          increment an array counter   
    6.18 + * void perfc_add    (counter, value)          add a value to a counter     
    6.19 + * void perfc_adda   (counter, index, value)   add a value to array counter 
    6.20 + * void perfc_print  (counter)                 print out the counter
    6.21 + */
    6.22 +
    6.23 +#define PERFCOUNTER( var, name ) \
    6.24 +unsigned long var[1];
    6.25 +#define PERFCOUNTER_ARRAY( var, name, size ) \
    6.26 +unsigned long var[size];
    6.27 +
    6.28 +struct perfcounter_t 
    6.29 +{
    6.30 +#include <xeno/perfc_defn.h>
    6.31 +};
    6.32 +
    6.33 +extern struct perfcounter_t perfcounters;
    6.34 +extern char *perfc_name[];
    6.35 +
    6.36 +#define perf_value(x)    perfcounters.x[0]
    6.37 +#define perf_valuea(x,y) perfcounters.x[y]
    6.38 +#define perf_incr(x)     perfcounters.x[0]++
    6.39 +#define perf_incra(x,y)  perfcounters.x[y]++
    6.40 +#define perf_add(x,y)    perfcounters.x[0]+=(y)
    6.41 +#define perf_adda(x,y,z) perfcounters.x[y]+=(z)
    6.42 +
    6.43 +#define perf_print(x) \
    6.44 +  __perfc_print(perfcounters.x, \
    6.45 +	        &perfcounters.x[0] - ((unsigned long *)&perfcounters))
    6.46 +
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/xen-2.4.16/include/xeno/perfc_defn.h	Thu Feb 20 12:01:18 2003 +0000
     7.3 @@ -0,0 +1,4 @@
     7.4 +
     7.5 +PERFCOUNTER( blockio_tx, "block io: messages received from tx queue" )
     7.6 +PERFCOUNTER( blockio_rx, "block io: messages sent on rx queue" )
     7.7 +