[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] CPUIDLE: adjust cstate statistic interface



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1229697880 0
# Node ID 2312cc25232b6a22136cae46b164bbec11be3687
# Parent  d238101c1832ba178bfc00a20b461fcebe21d5df
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@xxxxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/misc/xenpm.c           |    2 +-
 xen/arch/x86/acpi/cpu_idle.c |   40 ++++++++++++++++++++++++++++------------
 xen/arch/x86/time.c          |   13 +++++++++++++
 xen/include/asm-x86/time.h   |    2 ++
 4 files changed, 44 insertions(+), 13 deletions(-)

diff -r d238101c1832 -r 2312cc25232b tools/misc/xenpm.c
--- a/tools/misc/xenpm.c        Fri Dec 19 13:42:04 2008 +0000
+++ b/tools/misc/xenpm.c        Fri Dec 19 14:44:40 2008 +0000
@@ -108,7 +108,7 @@ static int show_cx_cpuid(int xc_fd, int 
         printf("C%d                   : transition [%020"PRIu64"]\n",
                i, cxstat->triggers[i]);
         printf("                       residency  [%020"PRIu64" ms]\n",
-               cxstat->residencies[i]*1000000UL/3579/1000000UL);
+               cxstat->residencies[i]/1000000UL);
     }
 
     free(cxstat->triggers);
diff -r d238101c1832 -r 2312cc25232b xen/arch/x86/acpi/cpu_idle.c
--- a/xen/arch/x86/acpi/cpu_idle.c      Fri Dec 19 13:42:04 2008 +0000
+++ b/xen/arch/x86/acpi/cpu_idle.c      Fri Dec 19 14:44:40 2008 +0000
@@ -71,7 +71,8 @@ static struct acpi_processor_power *__re
 
 static void print_acpi_power(uint32_t cpu, struct acpi_processor_power *power)
 {
-    uint32_t i;
+    uint32_t i, idle_usage = 0;
+    uint64_t res, idle_res = 0;
 
     printk("==cpu%d==\n", cpu);
     printk("active state:\t\tC%d\n",
@@ -81,14 +82,21 @@ static void print_acpi_power(uint32_t cp
     
     for ( i = 1; i < power->count; i++ )
     {
+        res = acpi_pm_tick_to_ns(power->states[i].time);
+        idle_usage += power->states[i].usage;
+        idle_res += res;
+
         printk((power->last_state && power->last_state->idx == i) ?
                "   *" : "    ");
         printk("C%d:\t", i);
         printk("type[C%d] ", power->states[i].type);
         printk("latency[%03d] ", power->states[i].latency);
         printk("usage[%08d] ", power->states[i].usage);
-        printk("duration[%"PRId64"]\n", power->states[i].time);
-    }
+        printk("duration[%"PRId64"]\n", res);
+    }
+    printk("    C0:\tusage[%08d] duration[%"PRId64"]\n",
+           idle_usage, NOW() - idle_res);
+
 }
 
 static void dump_cx(unsigned char key)
@@ -749,7 +757,7 @@ int pmstat_get_cx_stat(uint32_t cpuid, s
 int pmstat_get_cx_stat(uint32_t cpuid, struct pm_cx_stat *stat)
 {
     const struct acpi_processor_power *power = processor_powers[cpuid];
-    uint64_t usage;
+    uint64_t usage, res, idle_usage = 0, idle_res = 0;
     int i;
 
     if ( power == NULL )
@@ -764,16 +772,24 @@ int pmstat_get_cx_stat(uint32_t cpuid, s
     stat->nr = power->count;
     stat->idle_time = get_cpu_idle_time(cpuid);
 
-    for ( i = 0; i < power->count; i++ )
-    {
-        usage = power->states[i].usage;
-        if ( copy_to_guest_offset(stat->triggers, i, &usage, 1) )
+    for ( i = power->count - 1; i >= 0; i-- )
+    {
+        if ( i != 0 )
+        {
+            usage = power->states[i].usage;
+            res = acpi_pm_tick_to_ns(power->states[i].time);
+            idle_usage += usage;
+            idle_res += res;
+        }
+        else
+        {
+            usage = idle_usage;
+            res = NOW() - idle_res;
+        }
+        if ( copy_to_guest_offset(stat->triggers, i, &usage, 1) ||
+             copy_to_guest_offset(stat->residencies, i, &res, 1) )
             return -EFAULT;
     }
-    for ( i = 0; i < power->count; i++ )
-        if ( copy_to_guest_offset(stat->residencies, i, 
-                                  &power->states[i].time, 1) )
-            return -EFAULT;
 
     return 0;
 }
diff -r d238101c1832 -r 2312cc25232b xen/arch/x86/time.c
--- a/xen/arch/x86/time.c       Fri Dec 19 13:42:04 2008 +0000
+++ b/xen/arch/x86/time.c       Fri Dec 19 14:44:40 2008 +0000
@@ -531,6 +531,19 @@ static struct platform_timesource plt_pm
     .init = init_pmtimer
 };
 
+static struct time_scale pmt_scale;
+static __init int init_pmtmr_scale(void)
+{
+    set_time_scale(&pmt_scale, ACPI_PM_FREQUENCY);
+    return 0;
+}
+__initcall(init_pmtmr_scale);
+
+uint64_t acpi_pm_tick_to_ns(uint64_t ticks)
+{
+    return scale_delta(ticks, &pmt_scale);
+}
+
 /************************************************************
  * GENERIC PLATFORM TIMER INFRASTRUCTURE
  */
diff -r d238101c1832 -r 2312cc25232b xen/include/asm-x86/time.h
--- a/xen/include/asm-x86/time.h        Fri Dec 19 13:42:04 2008 +0000
+++ b/xen/include/asm-x86/time.h        Fri Dec 19 14:44:40 2008 +0000
@@ -38,4 +38,6 @@ void pit_broadcast_exit(void);
 void pit_broadcast_exit(void);
 int pit_broadcast_is_available(void);
 
+uint64_t acpi_pm_tick_to_ns(uint64_t ticks);
+
 #endif /* __X86_TIME_H__ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.