ia64/xen-unstable

changeset 18643:819ab49deef1

xentrace: trace power management events.

Signed-off-by: Guanqun Lu <guanqun.lu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Oct 16 09:51:42 2008 +0100 (2008-10-16)
parents 9404bcb6d32e
children 98ff908a91b7
files tools/xentrace/formats xen/arch/x86/acpi/cpu_idle.c xen/drivers/cpufreq/utility.c xen/include/public/trace.h
line diff
     1.1 --- a/tools/xentrace/formats	Thu Oct 16 09:50:18 2008 +0100
     1.2 +++ b/tools/xentrace/formats	Thu Oct 16 09:51:42 2008 +0100
     1.3 @@ -116,3 +116,7 @@ 0x0040f00e  CPU%(cpu)d  %(tsc)d (+%(relt
     1.4  0x0040f10e  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  shadow_emulate_resync_full        [ gfn = 0x%(1)16x ]
     1.5  0x0040f00f  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  shadow_emulate_resync_only        [ gfn = 0x%(1)08x ]
     1.6  0x0040f10f  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  shadow_emulate_resync_only        [ gfn = 0x%(1)16x ]
     1.7 +
     1.8 +0x00801001  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  cpu_freq_change [ %(1)dMHz -> %(2)dMHz ]
     1.9 +0x00802001  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  cpu_idle_entry  [ C0 -> C%(1)d ]
    1.10 +0x00802002  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  cpu_idle_exit   [ C%(1)d -> C0 ]
     2.1 --- a/xen/arch/x86/acpi/cpu_idle.c	Thu Oct 16 09:50:18 2008 +0100
     2.2 +++ b/xen/arch/x86/acpi/cpu_idle.c	Thu Oct 16 09:51:42 2008 +0100
     2.3 @@ -40,6 +40,7 @@
     2.4  #include <xen/guest_access.h>
     2.5  #include <xen/keyhandler.h>
     2.6  #include <xen/cpuidle.h>
     2.7 +#include <xen/trace.h>
     2.8  #include <asm/cache.h>
     2.9  #include <asm/io.h>
    2.10  #include <asm/hpet.h>
    2.11 @@ -251,6 +252,9 @@ static void acpi_processor_idle(void)
    2.12      switch ( cx->type )
    2.13      {
    2.14      case ACPI_STATE_C1:
    2.15 +        /* Trace cpu idle entry */
    2.16 +        TRACE_1D(TRC_PM_IDLE_ENTRY, 1);
    2.17 +
    2.18          /*
    2.19           * Invoke C1.
    2.20           * Use the appropriate idle routine, the one that would
    2.21 @@ -261,6 +265,9 @@ static void acpi_processor_idle(void)
    2.22          else 
    2.23              acpi_safe_halt();
    2.24  
    2.25 +        /* Trace cpu idle exit */
    2.26 +        TRACE_1D(TRC_PM_IDLE_EXIT, 1);
    2.27 +
    2.28          /*
    2.29           * TBD: Can't get time duration while in C1, as resumes
    2.30           *      go to an ISR rather than here.  Need to instrument
    2.31 @@ -272,12 +279,16 @@ static void acpi_processor_idle(void)
    2.32      case ACPI_STATE_C2:
    2.33          if ( local_apic_timer_c2_ok )
    2.34          {
    2.35 +            /* Trace cpu idle entry */
    2.36 +            TRACE_1D(TRC_PM_IDLE_ENTRY, 2);
    2.37              /* Get start time (ticks) */
    2.38              t1 = inl(pmtmr_ioport);
    2.39              /* Invoke C2 */
    2.40              acpi_idle_do_entry(cx);
    2.41              /* Get end time (ticks) */
    2.42              t2 = inl(pmtmr_ioport);
    2.43 +            /* Trace cpu idle exit */
    2.44 +            TRACE_1D(TRC_PM_IDLE_EXIT, 2);
    2.45  
    2.46              /* Re-enable interrupts */
    2.47              local_irq_enable();
    2.48 @@ -316,6 +327,8 @@ static void acpi_processor_idle(void)
    2.49              ACPI_FLUSH_CPU_CACHE();
    2.50          }
    2.51  
    2.52 +        /* Trace cpu idle entry */
    2.53 +        TRACE_1D(TRC_PM_IDLE_ENTRY, cx - &power->states[0]);
    2.54          /*
    2.55           * Before invoking C3, be aware that TSC/APIC timer may be 
    2.56           * stopped by H/W. Without carefully handling of TSC/APIC stop issues,
    2.57 @@ -335,6 +348,8 @@ static void acpi_processor_idle(void)
    2.58  
    2.59          /* recovering TSC */
    2.60          cstate_restore_tsc();
    2.61 +        /* Trace cpu idle exit */
    2.62 +        TRACE_1D(TRC_PM_IDLE_EXIT, cx - &power->states[0]);
    2.63  
    2.64          if ( power->flags.bm_check && power->flags.bm_control )
    2.65          {
     3.1 --- a/xen/drivers/cpufreq/utility.c	Thu Oct 16 09:50:18 2008 +0100
     3.2 +++ b/xen/drivers/cpufreq/utility.c	Thu Oct 16 09:51:42 2008 +0100
     3.3 @@ -27,6 +27,7 @@
     3.4  #include <xen/types.h>
     3.5  #include <xen/sched.h>
     3.6  #include <xen/timer.h>
     3.7 +#include <xen/trace.h>
     3.8  #include <asm/config.h>
     3.9  #include <acpi/cpufreq/cpufreq.h>
    3.10  #include <public/sysctl.h>
    3.11 @@ -293,7 +294,13 @@ int __cpufreq_driver_target(struct cpufr
    3.12      int retval = -EINVAL;
    3.13  
    3.14      if (cpu_online(policy->cpu) && cpufreq_driver->target)
    3.15 +    {
    3.16 +        unsigned int prev_freq = policy->cur;
    3.17 +
    3.18          retval = cpufreq_driver->target(policy, target_freq, relation);
    3.19 +        if ( retval == 0 )
    3.20 +            TRACE_2D(TRC_PM_FREQ_CHANGE, prev_freq/1000, policy->cur/1000);
    3.21 +    }
    3.22  
    3.23      return retval;
    3.24  }
     4.1 --- a/xen/include/public/trace.h	Thu Oct 16 09:50:18 2008 +0100
     4.2 +++ b/xen/include/public/trace.h	Thu Oct 16 09:51:42 2008 +0100
     4.3 @@ -38,6 +38,7 @@
     4.4  #define TRC_MEM      0x0010f000    /* Xen memory trace         */
     4.5  #define TRC_PV       0x0020f000    /* Xen PV traces            */
     4.6  #define TRC_SHADOW   0x0040f000    /* Xen shadow tracing       */
     4.7 +#define TRC_PM       0x0080f000    /* Xen power management trace */
     4.8  #define TRC_ALL      0x0ffff000
     4.9  #define TRC_HD_TO_EVENT(x) ((x)&0x0fffffff)
    4.10  #define TRC_HD_CYCLE_FLAG (1UL<<31)
    4.11 @@ -146,6 +147,15 @@
    4.12  #define TRC_HVM_LMSW            (TRC_HVM_HANDLER + 0x19)
    4.13  #define TRC_HVM_LMSW64          (TRC_HVM_HANDLER + TRC_64_FLAG + 0x19)
    4.14  
    4.15 +/* trace subclasses for power management */
    4.16 +#define TRC_PM_FREQ     0x00801000      /* xen cpu freq events */
    4.17 +#define TRC_PM_IDLE     0x00802000      /* xen cpu idle events */
    4.18 +
    4.19 +/* trace events for per class */
    4.20 +#define TRC_PM_FREQ_CHANGE      (TRC_PM_FREQ + 0x01)
    4.21 +#define TRC_PM_IDLE_ENTRY       (TRC_PM_IDLE + 0x01)
    4.22 +#define TRC_PM_IDLE_EXIT        (TRC_PM_IDLE + 0x02)
    4.23 +
    4.24  /* This structure represents a single trace buffer record. */
    4.25  struct t_rec {
    4.26      uint32_t event:28;