diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2009-06-29 11:01:50 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2009-06-29 11:01:50 +0100 |
commit | 71eb0dfc66b858528a97b9fbc92d55f13d378cf5 (patch) | |
tree | 8574a4f699cb0d40fcd2b7c2bcd1c3266cb5e487 | |
parent | c18a0f7d6da1c477a0c3fa363499aad9082afaa3 (diff) | |
download | xen-71eb0dfc66b858528a97b9fbc92d55f13d378cf5.tar.gz xen-71eb0dfc66b858528a97b9fbc92d55f13d378cf5.tar.bz2 xen-71eb0dfc66b858528a97b9fbc92d55f13d378cf5.zip |
x86 Cx tracing: export the Cx exit reason (pending interrupt during Cx)
Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
-rw-r--r-- | tools/xentrace/formats | 2 | ||||
-rw-r--r-- | xen/arch/x86/acpi/cpu_idle.c | 32 | ||||
-rw-r--r-- | xen/include/xen/trace.h | 15 |
3 files changed, 45 insertions, 4 deletions
diff --git a/tools/xentrace/formats b/tools/xentrace/formats index db82a09250..976f3f8986 100644 --- a/tools/xentrace/formats +++ b/tools/xentrace/formats @@ -122,4 +122,4 @@ 0x00801001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) cpu_freq_change [ %(1)dMHz -> %(2)dMHz ] 0x00802001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) cpu_idle_entry [ C0 -> C%(1)d, acpi_pm_tick = %(2)d, expected = %(3)dus, predicted = %(4)dus ] -0x00802002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) cpu_idle_exit [ C%(1)d -> C0, acpi_pm_tick = %(2)d ] +0x00802002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) cpu_idle_exit [ C%(1)d -> C0, acpi_pm_tick = %(2)d, irq = %(3)d %(4)d %(5)d %(6)d ] diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c index e98ef6a693..4d591c857e 100644 --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -190,6 +190,28 @@ static struct { unsigned int count; } c3_cpu_status = { .lock = SPIN_LOCK_UNLOCKED }; +static inline void trace_exit_reason(u32 *irq_traced) +{ +#ifdef DEBUG + if ( unlikely(tb_init_done) ) + { + int i, curbit; + u32 irr_status[8] = { 0 }; + + /* Get local apic IRR register */ + for ( i = 0; i < 8; i++ ) + irr_status[i] = apic_read(APIC_IRR + (i << 4)); + i = 0; + curbit = find_first_bit((const unsigned long *)irr_status, 256); + while ( i < 4 && curbit < 256 ) + { + irq_traced[i++] = curbit; + curbit = find_next_bit((const unsigned long *)irr_status, 256, curbit + 1); + } + } +#endif +} + static void acpi_processor_idle(void) { struct acpi_processor_power *power = processor_powers[smp_processor_id()]; @@ -198,6 +220,7 @@ static void acpi_processor_idle(void) int sleep_ticks = 0; u32 t1, t2 = 0; u32 exp = 0, pred = 0; + u32 irq_traced[4] = { 0 }; cpufreq_dbs_timer_suspend(); @@ -267,9 +290,10 @@ static void acpi_processor_idle(void) acpi_idle_do_entry(cx); /* Get end time (ticks) */ t2 = inl(pmtmr_ioport); + trace_exit_reason(irq_traced); /* Trace cpu idle exit */ - TRACE_2D(TRC_PM_IDLE_EXIT, cx->idx, t2); - + TRACE_6D(TRC_PM_IDLE_EXIT, cx->idx, t2, + irq_traced[0], irq_traced[1], irq_traced[2], irq_traced[3]); /* Re-enable interrupts */ local_irq_enable(); /* Compute time (ticks) that we were actually asleep */ @@ -326,8 +350,10 @@ static void acpi_processor_idle(void) /* recovering TSC */ cstate_restore_tsc(); + trace_exit_reason(irq_traced); /* Trace cpu idle exit */ - TRACE_2D(TRC_PM_IDLE_EXIT, cx->idx, t2); + TRACE_6D(TRC_PM_IDLE_EXIT, cx->idx, t2, + irq_traced[0], irq_traced[1], irq_traced[2], irq_traced[3]); if ( power->flags.bm_check && power->flags.bm_control ) { diff --git a/xen/include/xen/trace.h b/xen/include/xen/trace.h index 1ca52fc633..797fb75658 100644 --- a/xen/include/xen/trace.h +++ b/xen/include/xen/trace.h @@ -111,4 +111,19 @@ static inline void trace_var(u32 event, int cycles, int extra, } \ } while ( 0 ) +#define TRACE_6D(_e,d1,d2,d3,d4,d5,d6) \ + do { \ + if ( unlikely(tb_init_done) ) \ + { \ + u32 _d[6]; \ + _d[0] = d1; \ + _d[1] = d2; \ + _d[2] = d3; \ + _d[3] = d4; \ + _d[4] = d5; \ + _d[5] = d6; \ + __trace_var(_e, 1, sizeof(*_d)*6, (unsigned char *)_d); \ + } \ + } while ( 0 ) + #endif /* __XEN_TRACE_H__ */ |