ia64/xen-unstable

changeset 19608:674e4d43955f

x86, cpufreq: fix ondemand governor to take aperf/mperf feedback

APERF/MPERF MSRs provides feedback about actual freq in
eplased time, which could be different from requested freq by
governor. However currently ondemand governor only takes that
feedback at freq down path. We should do that for scale up too.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 19 01:31:26 2009 +0100 (2009-05-19)
parents b5522741f6b5
children 4d6029814742
files xen/drivers/cpufreq/cpufreq_ondemand.c
line diff
     1.1 --- a/xen/drivers/cpufreq/cpufreq_ondemand.c	Tue May 19 01:27:36 2009 +0100
     1.2 +++ b/xen/drivers/cpufreq/cpufreq_ondemand.c	Tue May 19 01:31:26 2009 +0100
     1.3 @@ -97,9 +97,8 @@ int get_cpufreq_ondemand_para(uint32_t *
     1.4  
     1.5  static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
     1.6  {
     1.7 -    unsigned int load = 0;
     1.8 -    uint64_t cur_ns, idle_ns, total_ns;
     1.9 -
    1.10 +    uint64_t cur_ns, total_ns;
    1.11 +    uint64_t max_load_freq = 0;
    1.12      struct cpufreq_policy *policy;
    1.13      unsigned int j;
    1.14  
    1.15 @@ -121,30 +120,34 @@ static void dbs_check_cpu(struct cpu_dbs
    1.16          return;
    1.17  
    1.18      /* Get Idle Time */
    1.19 -    idle_ns = UINT_MAX;
    1.20      for_each_cpu_mask(j, policy->cpus) {
    1.21 -        uint64_t total_idle_ns;
    1.22 -        unsigned int tmp_idle_ns;
    1.23 +        uint64_t idle_ns, total_idle_ns;
    1.24 +        uint64_t load, load_freq, freq_avg;
    1.25          struct cpu_dbs_info_s *j_dbs_info;
    1.26  
    1.27          j_dbs_info = &per_cpu(cpu_dbs_info, j);
    1.28          total_idle_ns = get_cpu_idle_time(j);
    1.29 -        tmp_idle_ns = total_idle_ns - j_dbs_info->prev_cpu_idle;
    1.30 +        idle_ns = total_idle_ns - j_dbs_info->prev_cpu_idle;
    1.31          j_dbs_info->prev_cpu_idle = total_idle_ns;
    1.32  
    1.33 -        if (tmp_idle_ns < idle_ns)
    1.34 -            idle_ns = tmp_idle_ns;
    1.35 +        if (unlikely(total_ns < idle_ns))
    1.36 +            continue;
    1.37 +
    1.38 +        load = 100 * (total_ns - idle_ns) / total_ns;
    1.39 +
    1.40 +        freq_avg = cpufreq_driver_getavg(j, GOV_GETAVG);
    1.41 +
    1.42 +        load_freq = load * freq_avg;
    1.43 +        if (load_freq > max_load_freq)
    1.44 +            max_load_freq = load_freq;
    1.45      }
    1.46  
    1.47 -    if (likely(total_ns > idle_ns))
    1.48 -        load = (100 * (total_ns - idle_ns)) / total_ns;
    1.49 -
    1.50      /* Check for frequency increase */
    1.51 -    if (load > dbs_tuners_ins.up_threshold) {
    1.52 +    if (max_load_freq > dbs_tuners_ins.up_threshold * policy->cur) {
    1.53          /* if we are already at full speed then break out early */
    1.54          if (policy->cur == policy->max)
    1.55              return;
    1.56 -        __cpufreq_driver_target(policy, policy->max,CPUFREQ_RELATION_H);
    1.57 +        __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
    1.58          return;
    1.59      }
    1.60  
    1.61 @@ -158,12 +161,10 @@ static void dbs_check_cpu(struct cpu_dbs
    1.62       * can support the current CPU usage without triggering the up
    1.63       * policy. To be safe, we focus 10 points under the threshold.
    1.64       */
    1.65 -    if (load < (dbs_tuners_ins.up_threshold - 10)) {
    1.66 -        unsigned int freq_next, freq_cur;
    1.67 +    if (max_load_freq < (dbs_tuners_ins.up_threshold - 10) * policy->cur) {
    1.68 +        uint64_t freq_next;
    1.69  
    1.70 -        freq_cur = cpufreq_driver_getavg(policy->cpu, GOV_GETAVG);
    1.71 -
    1.72 -        freq_next = (freq_cur * load) / (dbs_tuners_ins.up_threshold - 10);
    1.73 +        freq_next = max_load_freq / (dbs_tuners_ins.up_threshold - 10);
    1.74  
    1.75          __cpufreq_driver_target(policy, freq_next, CPUFREQ_RELATION_L);
    1.76      }