ia64/xen-unstable

changeset 9247:68915c4893ee

Add a 't' debug key to Xen for displaying info about cross-cpu clock jitter.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Mar 13 13:03:51 2006 +0100 (2006-03-13)
parents 2625000d3145
children 36cf47cfea4e
files xen/common/keyhandler.c
line diff
     1.1 --- a/xen/common/keyhandler.c	Mon Mar 13 13:03:18 2006 +0100
     1.2 +++ b/xen/common/keyhandler.c	Mon Mar 13 13:03:51 2006 +0100
     1.3 @@ -14,6 +14,7 @@
     1.4  #include <xen/rangeset.h>
     1.5  #include <asm/debugger.h>
     1.6  #include <asm/shadow.h>
     1.7 +#include <asm/div64.h>
     1.8  
     1.9  #define KEY_MAX 256
    1.10  #define STR_MAX  64
    1.11 @@ -168,6 +169,58 @@ static void dump_domains(unsigned char k
    1.12      read_unlock(&domlist_lock);
    1.13  }
    1.14  
    1.15 +static cpumask_t read_clocks_cpumask = CPU_MASK_NONE;
    1.16 +static s_time_t read_clocks_time[NR_CPUS];
    1.17 +
    1.18 +static void read_clocks_slave(void *unused)
    1.19 +{
    1.20 +    unsigned int cpu = smp_processor_id();
    1.21 +    while ( !cpu_isset(cpu, read_clocks_cpumask) )
    1.22 +        cpu_relax();
    1.23 +    read_clocks_time[cpu] = NOW();
    1.24 +    cpu_clear(cpu, read_clocks_cpumask);
    1.25 +}
    1.26 +
    1.27 +static void read_clocks(unsigned char key)
    1.28 +{
    1.29 +    unsigned int cpu = smp_processor_id(), min_cpu, max_cpu;
    1.30 +    u64 min, max, dif, difus;
    1.31 +    static DEFINE_SPINLOCK(lock);
    1.32 +
    1.33 +    spin_lock(&lock);
    1.34 +
    1.35 +    smp_call_function(read_clocks_slave, NULL, 0, 0);
    1.36 +
    1.37 +    local_irq_disable();
    1.38 +    read_clocks_cpumask = cpu_online_map;
    1.39 +    read_clocks_time[cpu] = NOW();
    1.40 +    cpu_clear(cpu, read_clocks_cpumask);
    1.41 +    local_irq_enable();
    1.42 +
    1.43 +    while ( !cpus_empty(read_clocks_cpumask) )
    1.44 +        cpu_relax();
    1.45 +
    1.46 +    min_cpu = max_cpu = cpu;
    1.47 +    for_each_online_cpu ( cpu )
    1.48 +    {
    1.49 +        if ( read_clocks_time[cpu] < read_clocks_time[min_cpu] )
    1.50 +            min_cpu = cpu;
    1.51 +        if ( read_clocks_time[cpu] > read_clocks_time[max_cpu] )
    1.52 +            max_cpu = cpu;
    1.53 +    }
    1.54 +
    1.55 +    min = read_clocks_time[min_cpu];
    1.56 +    max = read_clocks_time[max_cpu];
    1.57 +
    1.58 +    spin_unlock(&lock);
    1.59 +
    1.60 +    dif = difus = max - min;
    1.61 +    do_div(difus, 1000);
    1.62 +    printk("Min = %"PRIu64" ; Max = %"PRIu64" ; Diff = %"PRIu64
    1.63 +           " (%"PRIu64" microseconds)\n",
    1.64 +           min, max, dif, difus);
    1.65 +}
    1.66 +
    1.67  extern void dump_runq(unsigned char key);
    1.68  #ifndef NDEBUG
    1.69  extern void audit_domains_key(unsigned char key);
    1.70 @@ -178,7 +231,7 @@ extern void perfc_printall(unsigned char
    1.71  extern void perfc_reset(unsigned char key);
    1.72  #endif
    1.73  
    1.74 -void do_debug_key(unsigned char key, struct cpu_user_regs *regs)
    1.75 +static void do_debug_key(unsigned char key, struct cpu_user_regs *regs)
    1.76  {
    1.77      (void)debugger_trap_fatal(0xf001, regs);
    1.78      nop(); /* Prevent the compiler doing tail call
    1.79 @@ -187,7 +240,7 @@ void do_debug_key(unsigned char key, str
    1.80  }
    1.81  
    1.82  #ifndef NDEBUG
    1.83 -void debugtrace_key(unsigned char key)
    1.84 +static void debugtrace_key(unsigned char key)
    1.85  {
    1.86      debugtrace_send_to_console = !debugtrace_send_to_console;
    1.87      debugtrace_dump();
    1.88 @@ -211,6 +264,9 @@ void initialize_keytable(void)
    1.89      register_irq_keyhandler(
    1.90          'R', halt_machine,   "reboot machine"); 
    1.91  
    1.92 +    register_keyhandler(
    1.93 +        't', read_clocks, "display multi-cpu clock info");
    1.94 +
    1.95  #ifndef NDEBUG
    1.96      register_keyhandler(
    1.97          'o', audit_domains_key,  "audit domains >0 EXPERIMENTAL");