debuggers.hg
changeset 18973:2312cc25232b
CPUIDLE: adjust cstate statistic interface
1. change unit of residency, PM ticks -> ns.
2. output C0 usage & residency.
Signed-off-by: Wei Gang <gang.wei@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
1. change unit of residency, PM ticks -> ns.
2. output C0 usage & residency.
Signed-off-by: Wei Gang <gang.wei@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Fri Dec 19 14:44:40 2008 +0000 (2008-12-19) |
parents | d238101c1832 |
children | 738513b106fa |
files | tools/misc/xenpm.c xen/arch/x86/acpi/cpu_idle.c xen/arch/x86/time.c xen/include/asm-x86/time.h |
line diff
1.1 --- a/tools/misc/xenpm.c Fri Dec 19 13:42:04 2008 +0000 1.2 +++ b/tools/misc/xenpm.c Fri Dec 19 14:44:40 2008 +0000 1.3 @@ -108,7 +108,7 @@ static int show_cx_cpuid(int xc_fd, int 1.4 printf("C%d : transition [%020"PRIu64"]\n", 1.5 i, cxstat->triggers[i]); 1.6 printf(" residency [%020"PRIu64" ms]\n", 1.7 - cxstat->residencies[i]*1000000UL/3579/1000000UL); 1.8 + cxstat->residencies[i]/1000000UL); 1.9 } 1.10 1.11 free(cxstat->triggers);
2.1 --- a/xen/arch/x86/acpi/cpu_idle.c Fri Dec 19 13:42:04 2008 +0000 2.2 +++ b/xen/arch/x86/acpi/cpu_idle.c Fri Dec 19 14:44:40 2008 +0000 2.3 @@ -71,7 +71,8 @@ static struct acpi_processor_power *__re 2.4 2.5 static void print_acpi_power(uint32_t cpu, struct acpi_processor_power *power) 2.6 { 2.7 - uint32_t i; 2.8 + uint32_t i, idle_usage = 0; 2.9 + uint64_t res, idle_res = 0; 2.10 2.11 printk("==cpu%d==\n", cpu); 2.12 printk("active state:\t\tC%d\n", 2.13 @@ -81,14 +82,21 @@ static void print_acpi_power(uint32_t cp 2.14 2.15 for ( i = 1; i < power->count; i++ ) 2.16 { 2.17 + res = acpi_pm_tick_to_ns(power->states[i].time); 2.18 + idle_usage += power->states[i].usage; 2.19 + idle_res += res; 2.20 + 2.21 printk((power->last_state && power->last_state->idx == i) ? 2.22 " *" : " "); 2.23 printk("C%d:\t", i); 2.24 printk("type[C%d] ", power->states[i].type); 2.25 printk("latency[%03d] ", power->states[i].latency); 2.26 printk("usage[%08d] ", power->states[i].usage); 2.27 - printk("duration[%"PRId64"]\n", power->states[i].time); 2.28 + printk("duration[%"PRId64"]\n", res); 2.29 } 2.30 + printk(" C0:\tusage[%08d] duration[%"PRId64"]\n", 2.31 + idle_usage, NOW() - idle_res); 2.32 + 2.33 } 2.34 2.35 static void dump_cx(unsigned char key) 2.36 @@ -749,7 +757,7 @@ uint32_t pmstat_get_cx_nr(uint32_t cpuid 2.37 int pmstat_get_cx_stat(uint32_t cpuid, struct pm_cx_stat *stat) 2.38 { 2.39 const struct acpi_processor_power *power = processor_powers[cpuid]; 2.40 - uint64_t usage; 2.41 + uint64_t usage, res, idle_usage = 0, idle_res = 0; 2.42 int i; 2.43 2.44 if ( power == NULL ) 2.45 @@ -764,16 +772,24 @@ int pmstat_get_cx_stat(uint32_t cpuid, s 2.46 stat->nr = power->count; 2.47 stat->idle_time = get_cpu_idle_time(cpuid); 2.48 2.49 - for ( i = 0; i < power->count; i++ ) 2.50 + for ( i = power->count - 1; i >= 0; i-- ) 2.51 { 2.52 - usage = power->states[i].usage; 2.53 - if ( copy_to_guest_offset(stat->triggers, i, &usage, 1) ) 2.54 + if ( i != 0 ) 2.55 + { 2.56 + usage = power->states[i].usage; 2.57 + res = acpi_pm_tick_to_ns(power->states[i].time); 2.58 + idle_usage += usage; 2.59 + idle_res += res; 2.60 + } 2.61 + else 2.62 + { 2.63 + usage = idle_usage; 2.64 + res = NOW() - idle_res; 2.65 + } 2.66 + if ( copy_to_guest_offset(stat->triggers, i, &usage, 1) || 2.67 + copy_to_guest_offset(stat->residencies, i, &res, 1) ) 2.68 return -EFAULT; 2.69 } 2.70 - for ( i = 0; i < power->count; i++ ) 2.71 - if ( copy_to_guest_offset(stat->residencies, i, 2.72 - &power->states[i].time, 1) ) 2.73 - return -EFAULT; 2.74 2.75 return 0; 2.76 }
3.1 --- a/xen/arch/x86/time.c Fri Dec 19 13:42:04 2008 +0000 3.2 +++ b/xen/arch/x86/time.c Fri Dec 19 14:44:40 2008 +0000 3.3 @@ -531,6 +531,19 @@ static struct platform_timesource plt_pm 3.4 .init = init_pmtimer 3.5 }; 3.6 3.7 +static struct time_scale pmt_scale; 3.8 +static __init int init_pmtmr_scale(void) 3.9 +{ 3.10 + set_time_scale(&pmt_scale, ACPI_PM_FREQUENCY); 3.11 + return 0; 3.12 +} 3.13 +__initcall(init_pmtmr_scale); 3.14 + 3.15 +uint64_t acpi_pm_tick_to_ns(uint64_t ticks) 3.16 +{ 3.17 + return scale_delta(ticks, &pmt_scale); 3.18 +} 3.19 + 3.20 /************************************************************ 3.21 * GENERIC PLATFORM TIMER INFRASTRUCTURE 3.22 */
4.1 --- a/xen/include/asm-x86/time.h Fri Dec 19 13:42:04 2008 +0000 4.2 +++ b/xen/include/asm-x86/time.h Fri Dec 19 14:44:40 2008 +0000 4.3 @@ -38,4 +38,6 @@ void pit_broadcast_enter(void); 4.4 void pit_broadcast_exit(void); 4.5 int pit_broadcast_is_available(void); 4.6 4.7 +uint64_t acpi_pm_tick_to_ns(uint64_t ticks); 4.8 + 4.9 #endif /* __X86_TIME_H__ */