ia64/xen-unstable

changeset 17926:0b4dbd9a9896

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@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jun 30 09:59:39 2008 +0100 (2008-06-30)
parents 469d9b00382d
children fbccdd7e2a86
files xen/arch/x86/acpi/cpufreq/cpufreq_ondemand.c xen/arch/x86/acpi/cpufreq/utility.c xen/arch/x86/acpi/pmstat.c xen/include/acpi/cpufreq/processor_perf.h
line diff
     1.1 --- a/xen/arch/x86/acpi/cpufreq/cpufreq_ondemand.c	Mon Jun 30 09:57:27 2008 +0100
     1.2 +++ b/xen/arch/x86/acpi/cpufreq/cpufreq_ondemand.c	Mon Jun 30 09:59:39 2008 +0100
     1.3 @@ -52,7 +52,7 @@ static struct dbs_tuners {
     1.4  
     1.5  static struct timer dbs_timer[NR_CPUS];
     1.6  
     1.7 -static inline uint64_t get_cpu_idle_time(unsigned int cpu)
     1.8 +inline uint64_t get_cpu_idle_time(unsigned int cpu)
     1.9  {
    1.10      uint64_t idle_ns;
    1.11      struct vcpu *v;
     2.1 --- a/xen/arch/x86/acpi/cpufreq/utility.c	Mon Jun 30 09:57:27 2008 +0100
     2.2 +++ b/xen/arch/x86/acpi/cpufreq/utility.c	Mon Jun 30 09:59:39 2008 +0100
     2.3 @@ -46,8 +46,15 @@ void px_statistic_suspend(void)
     2.4  
     2.5      for_each_online_cpu(cpu) {
     2.6          struct pm_px *pxpt = &px_statistic_data[cpu];
     2.7 +        uint64_t total_idle_ns;
     2.8 +        uint64_t tmp_idle_ns;
     2.9 +
    2.10 +        total_idle_ns = get_cpu_idle_time(cpu);
    2.11 +        tmp_idle_ns = total_idle_ns - pxpt->prev_idle_wall;
    2.12 +
    2.13          pxpt->u.pt[pxpt->u.cur].residency +=
    2.14                      now - pxpt->prev_state_wall;
    2.15 +        pxpt->u.pt[pxpt->u.cur].residency -= tmp_idle_ns;
    2.16      }
    2.17  }
    2.18  
    2.19 @@ -61,6 +68,7 @@ void px_statistic_resume(void)
    2.20      for_each_online_cpu(cpu) {
    2.21          struct pm_px *pxpt = &px_statistic_data[cpu];
    2.22          pxpt->prev_state_wall = now;
    2.23 +        pxpt->prev_idle_wall = get_cpu_idle_time(cpu);
    2.24      }
    2.25  }
    2.26  
    2.27 @@ -74,15 +82,22 @@ void px_statistic_update(cpumask_t cpuma
    2.28      for_each_cpu_mask(i, cpumask) {
    2.29          struct pm_px *pxpt = &px_statistic_data[i];
    2.30          uint32_t statnum = processor_pminfo[i].perf.state_count;
    2.31 +        uint64_t total_idle_ns;
    2.32 +        uint64_t tmp_idle_ns;
    2.33 +
    2.34 +        total_idle_ns = get_cpu_idle_time(i);
    2.35 +        tmp_idle_ns = total_idle_ns - pxpt->prev_idle_wall;
    2.36  
    2.37          pxpt->u.last = from;
    2.38          pxpt->u.cur = to;
    2.39          pxpt->u.pt[to].count++;
    2.40          pxpt->u.pt[from].residency += now - pxpt->prev_state_wall;
    2.41 +        pxpt->u.pt[from].residency -= tmp_idle_ns;
    2.42  
    2.43          (*(pxpt->u.trans_pt + from*statnum + to))++;
    2.44  
    2.45          pxpt->prev_state_wall = now;
    2.46 +        pxpt->prev_idle_wall = total_idle_ns;
    2.47      }
    2.48  }
    2.49  
    2.50 @@ -114,6 +129,7 @@ int px_statistic_init(int cpuid)
    2.51          pxpt->u.pt[i].freq = pmpt->perf.states[i].core_frequency;
    2.52  
    2.53      pxpt->prev_state_wall = NOW();
    2.54 +    pxpt->prev_idle_wall = get_cpu_idle_time(cpuid);
    2.55  
    2.56      return 0;
    2.57  }
    2.58 @@ -134,6 +150,7 @@ void px_statistic_reset(int cpuid)
    2.59      }
    2.60  
    2.61      pxpt->prev_state_wall = NOW();
    2.62 +    pxpt->prev_idle_wall = get_cpu_idle_time(cpuid);
    2.63  }
    2.64  
    2.65  
     3.1 --- a/xen/arch/x86/acpi/pmstat.c	Mon Jun 30 09:57:27 2008 +0100
     3.2 +++ b/xen/arch/x86/acpi/pmstat.c	Mon Jun 30 09:59:39 2008 +0100
     3.3 @@ -71,11 +71,18 @@ int do_get_pm_info(struct xen_sysctl_get
     3.4      case PMSTAT_get_pxstat:
     3.5      {
     3.6          uint64_t now, ct;
     3.7 +        uint64_t total_idle_ns;
     3.8 +        uint64_t tmp_idle_ns;
     3.9 +
    3.10 +        total_idle_ns = get_cpu_idle_time(op->cpuid);
    3.11 +        tmp_idle_ns = total_idle_ns - pxpt->prev_idle_wall;
    3.12  
    3.13          now = NOW();
    3.14          pxpt->u.usable = pmpt->perf.state_count - pmpt->perf.ppc;
    3.15          pxpt->u.pt[pxpt->u.cur].residency += now - pxpt->prev_state_wall;
    3.16 +        pxpt->u.pt[pxpt->u.cur].residency -= tmp_idle_ns;
    3.17          pxpt->prev_state_wall = now;
    3.18 +        pxpt->prev_idle_wall = total_idle_ns;
    3.19  
    3.20          ct = pmpt->perf.state_count;
    3.21          if ( copy_to_guest(op->u.getpx.trans_pt, pxpt->u.trans_pt, ct*ct) )
     4.1 --- a/xen/include/acpi/cpufreq/processor_perf.h	Mon Jun 30 09:57:27 2008 +0100
     4.2 +++ b/xen/include/acpi/cpufreq/processor_perf.h	Mon Jun 30 09:59:39 2008 +0100
     4.3 @@ -7,17 +7,21 @@
     4.4  int get_cpu_id(u8);
     4.5  int acpi_cpufreq_init(void);
     4.6  int powernow_cpufreq_init(void);
     4.7 +
     4.8  void px_statistic_update(cpumask_t, uint8_t, uint8_t);
     4.9  int  px_statistic_init(int);
    4.10  void px_statistic_reset(int);
    4.11  void px_statistic_suspend(void);
    4.12  void px_statistic_resume(void);
    4.13 +
    4.14  void cpufreq_dom_exit(void);
    4.15  int  cpufreq_dom_init(void);
    4.16  int  cpufreq_dom_dbs(unsigned int);
    4.17  void cpufreq_suspend(void);
    4.18  int  cpufreq_resume(void);
    4.19  
    4.20 +inline uint64_t get_cpu_idle_time(unsigned int);
    4.21 +
    4.22  struct processor_performance {
    4.23      uint32_t state;
    4.24      uint32_t ppc;
    4.25 @@ -52,6 +56,7 @@ struct px_stat {
    4.26  struct pm_px {
    4.27      struct px_stat u;
    4.28      uint64_t prev_state_wall;
    4.29 +    uint64_t prev_idle_wall;
    4.30  };
    4.31  
    4.32  extern struct pm_px px_statistic_data[NR_CPUS];