# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1214816379 -3600
# Node ID 0b4dbd9a9896980c8a298b0e289f75b8d8d93e1a
# Parent 469d9b00382db46fbeed3e092335c3fb168c402e
x86: Px statistic update for cpu idle time.
Update px statistic, subtract cx idle time from px residency time.
Signed-off-by: Liu Jinsong <jinsong.liu@xxxxxxxxx>
---
xen/arch/x86/acpi/cpufreq/cpufreq_ondemand.c | 2 +-
xen/arch/x86/acpi/cpufreq/utility.c | 17 +++++++++++++++++
xen/arch/x86/acpi/pmstat.c | 7 +++++++
xen/include/acpi/cpufreq/processor_perf.h | 5 +++++
4 files changed, 30 insertions(+), 1 deletion(-)
diff -r 469d9b00382d -r 0b4dbd9a9896
xen/arch/x86/acpi/cpufreq/cpufreq_ondemand.c
--- a/xen/arch/x86/acpi/cpufreq/cpufreq_ondemand.c Mon Jun 30 09:57:27
2008 +0100
+++ b/xen/arch/x86/acpi/cpufreq/cpufreq_ondemand.c Mon Jun 30 09:59:39
2008 +0100
@@ -52,7 +52,7 @@ static struct dbs_tuners {
static struct timer dbs_timer[NR_CPUS];
-static inline uint64_t get_cpu_idle_time(unsigned int cpu)
+inline uint64_t get_cpu_idle_time(unsigned int cpu)
{
uint64_t idle_ns;
struct vcpu *v;
diff -r 469d9b00382d -r 0b4dbd9a9896 xen/arch/x86/acpi/cpufreq/utility.c
--- a/xen/arch/x86/acpi/cpufreq/utility.c Mon Jun 30 09:57:27 2008 +0100
+++ b/xen/arch/x86/acpi/cpufreq/utility.c Mon Jun 30 09:59:39 2008 +0100
@@ -46,8 +46,15 @@ void px_statistic_suspend(void)
for_each_online_cpu(cpu) {
struct pm_px *pxpt = &px_statistic_data[cpu];
+ uint64_t total_idle_ns;
+ uint64_t tmp_idle_ns;
+
+ total_idle_ns = get_cpu_idle_time(cpu);
+ tmp_idle_ns = total_idle_ns - pxpt->prev_idle_wall;
+
pxpt->u.pt[pxpt->u.cur].residency +=
now - pxpt->prev_state_wall;
+ pxpt->u.pt[pxpt->u.cur].residency -= tmp_idle_ns;
}
}
@@ -61,6 +68,7 @@ void px_statistic_resume(void)
for_each_online_cpu(cpu) {
struct pm_px *pxpt = &px_statistic_data[cpu];
pxpt->prev_state_wall = now;
+ pxpt->prev_idle_wall = get_cpu_idle_time(cpu);
}
}
@@ -74,15 +82,22 @@ void px_statistic_update(cpumask_t cpuma
for_each_cpu_mask(i, cpumask) {
struct pm_px *pxpt = &px_statistic_data[i];
uint32_t statnum = processor_pminfo[i].perf.state_count;
+ uint64_t total_idle_ns;
+ uint64_t tmp_idle_ns;
+
+ total_idle_ns = get_cpu_idle_time(i);
+ tmp_idle_ns = total_idle_ns - pxpt->prev_idle_wall;
pxpt->u.last = from;
pxpt->u.cur = to;
pxpt->u.pt[to].count++;
pxpt->u.pt[from].residency += now - pxpt->prev_state_wall;
+ pxpt->u.pt[from].residency -= tmp_idle_ns;
(*(pxpt->u.trans_pt + from*statnum + to))++;
pxpt->prev_state_wall = now;
+ pxpt->prev_idle_wall = total_idle_ns;
}
}
@@ -114,6 +129,7 @@ int px_statistic_init(int cpuid)
pxpt->u.pt[i].freq = pmpt->perf.states[i].core_frequency;
pxpt->prev_state_wall = NOW();
+ pxpt->prev_idle_wall = get_cpu_idle_time(cpuid);
return 0;
}
@@ -134,6 +150,7 @@ void px_statistic_reset(int cpuid)
}
pxpt->prev_state_wall = NOW();
+ pxpt->prev_idle_wall = get_cpu_idle_time(cpuid);
}
diff -r 469d9b00382d -r 0b4dbd9a9896 xen/arch/x86/acpi/pmstat.c
--- a/xen/arch/x86/acpi/pmstat.c Mon Jun 30 09:57:27 2008 +0100
+++ b/xen/arch/x86/acpi/pmstat.c Mon Jun 30 09:59:39 2008 +0100
@@ -71,11 +71,18 @@ int do_get_pm_info(struct xen_sysctl_get
case PMSTAT_get_pxstat:
{
uint64_t now, ct;
+ uint64_t total_idle_ns;
+ uint64_t tmp_idle_ns;
+
+ total_idle_ns = get_cpu_idle_time(op->cpuid);
+ tmp_idle_ns = total_idle_ns - pxpt->prev_idle_wall;
now = NOW();
pxpt->u.usable = pmpt->perf.state_count - pmpt->perf.ppc;
pxpt->u.pt[pxpt->u.cur].residency += now - pxpt->prev_state_wall;
+ pxpt->u.pt[pxpt->u.cur].residency -= tmp_idle_ns;
pxpt->prev_state_wall = now;
+ pxpt->prev_idle_wall = total_idle_ns;
ct = pmpt->perf.state_count;
if ( copy_to_guest(op->u.getpx.trans_pt, pxpt->u.trans_pt, ct*ct) )
diff -r 469d9b00382d -r 0b4dbd9a9896 xen/include/acpi/cpufreq/processor_perf.h
--- a/xen/include/acpi/cpufreq/processor_perf.h Mon Jun 30 09:57:27 2008 +0100
+++ b/xen/include/acpi/cpufreq/processor_perf.h Mon Jun 30 09:59:39 2008 +0100
@@ -7,16 +7,20 @@ int get_cpu_id(u8);
int get_cpu_id(u8);
int acpi_cpufreq_init(void);
int powernow_cpufreq_init(void);
+
void px_statistic_update(cpumask_t, uint8_t, uint8_t);
int px_statistic_init(int);
void px_statistic_reset(int);
void px_statistic_suspend(void);
void px_statistic_resume(void);
+
void cpufreq_dom_exit(void);
int cpufreq_dom_init(void);
int cpufreq_dom_dbs(unsigned int);
void cpufreq_suspend(void);
int cpufreq_resume(void);
+
+inline uint64_t get_cpu_idle_time(unsigned int);
struct processor_performance {
uint32_t state;
@@ -52,6 +56,7 @@ struct pm_px {
struct pm_px {
struct px_stat u;
uint64_t prev_state_wall;
+ uint64_t prev_idle_wall;
};
extern struct pm_px px_statistic_data[NR_CPUS];
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|