Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 18 May 2010 15:49:13 +0000 (08:49 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 18 May 2010 15:49:13 +0000 (08:49 -0700)
* 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  x86, hypervisor: add missing <linux/module.h>
  Modify the VMware balloon driver for the new x86_hyper API
  x86, hypervisor: Export the x86_hyper* symbols
  x86: Clean up the hypervisor layer
  x86, HyperV: fix up the license to mshyperv.c
  x86: Detect running on a Microsoft HyperV system
  x86, cpu: Make APERF/MPERF a normal table-driven flag
  x86, k8: Fix build error when K8_NB is disabled
  x86, cacheinfo: Disable index in all four subcaches
  x86, cacheinfo: Make L3 cache info per node
  x86, cacheinfo: Reorganize AMD L3 cache structure
  x86, cacheinfo: Turn off L3 cache index disable feature in virtualized environments
  x86, cacheinfo: Unify AMD L3 cache index disable checking
  cpufreq: Unify sysfs attribute definition macros
  powernow-k8: Fix frequency reporting
  x86, cpufreq: Add APERF/MPERF support for AMD processors
  x86: Unify APERF/MPERF support
  powernow-k8: Add core performance boost support
  x86, cpu: Add AMD core boosting feature flag to /proc/cpuinfo

Fix up trivial conflicts in arch/x86/kernel/cpu/intel_cacheinfo.c and
drivers/cpufreq/cpufreq_ondemand.c

1  2 
arch/x86/include/asm/processor.h
arch/x86/kernel/cpu/intel.c
drivers/cpufreq/cpufreq_ondemand.c

@@@ -21,6 -21,7 +21,6 @@@ struct mm_struct
  #include <asm/msr.h>
  #include <asm/desc_defs.h>
  #include <asm/nops.h>
 -#include <asm/ds.h>
  
  #include <linux/personality.h>
  #include <linux/cpumask.h>
@@@ -28,7 -29,6 +28,7 @@@
  #include <linux/threads.h>
  #include <linux/math64.h>
  #include <linux/init.h>
 +#include <linux/err.h>
  
  #define HBP_NUM 4
  /*
@@@ -113,7 -113,6 +113,6 @@@ struct cpuinfo_x86 
        /* Index into per_cpu list: */
        u16                     cpu_index;
  #endif
-       unsigned int            x86_hyper_vendor;
  } __attribute__((__aligned__(SMP_CACHE_BYTES)));
  
  #define X86_VENDOR_INTEL      0
  
  #define X86_VENDOR_UNKNOWN    0xff
  
- #define X86_HYPER_VENDOR_NONE  0
- #define X86_HYPER_VENDOR_VMWARE 1
  /*
   * capabilities of CPUs
   */
@@@ -473,6 -469,10 +469,6 @@@ struct thread_struct 
        unsigned long           iopl;
        /* Max allowed port in the bitmap, in bytes: */
        unsigned                io_bitmap_max;
 -/* MSR_IA32_DEBUGCTLMSR value to switch in if TIF_DEBUGCTLMSR is set.  */
 -      unsigned long   debugctlmsr;
 -      /* Debug Store context; see asm/ds.h */
 -      struct ds_context       *ds_ctx;
  };
  
  static inline unsigned long native_get_debugreg(int regno)
@@@ -799,7 -799,7 +795,7 @@@ extern void cpu_init(void)
  
  static inline unsigned long get_debugctlmsr(void)
  {
 -    unsigned long debugctlmsr = 0;
 +      unsigned long debugctlmsr = 0;
  
  #ifndef CONFIG_X86_DEBUGCTLMSR
        if (boot_cpu_data.x86 < 6)
  #endif
        rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
  
 -    return debugctlmsr;
 -}
 -
 -static inline unsigned long get_debugctlmsr_on_cpu(int cpu)
 -{
 -      u64 debugctlmsr = 0;
 -      u32 val1, val2;
 -
 -#ifndef CONFIG_X86_DEBUGCTLMSR
 -      if (boot_cpu_data.x86 < 6)
 -              return 0;
 -#endif
 -      rdmsr_on_cpu(cpu, MSR_IA32_DEBUGCTLMSR, &val1, &val2);
 -      debugctlmsr = val1 | ((u64)val2 << 32);
 -
        return debugctlmsr;
  }
  
@@@ -819,6 -834,18 +815,6 @@@ static inline void update_debugctlmsr(u
        wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
  }
  
 -static inline void update_debugctlmsr_on_cpu(int cpu,
 -                                           unsigned long debugctlmsr)
 -{
 -#ifndef CONFIG_X86_DEBUGCTLMSR
 -      if (boot_cpu_data.x86 < 6)
 -              return;
 -#endif
 -      wrmsr_on_cpu(cpu, MSR_IA32_DEBUGCTLMSR,
 -                   (u32)((u64)debugctlmsr),
 -                   (u32)((u64)debugctlmsr >> 32));
 -}
 -
  /*
   * from system description table in BIOS. Mostly for MCA use, but
   * others may find it useful:
@@@ -12,6 -12,7 +12,6 @@@
  #include <asm/processor.h>
  #include <asm/pgtable.h>
  #include <asm/msr.h>
 -#include <asm/ds.h>
  #include <asm/bugs.h>
  #include <asm/cpu.h>
  
@@@ -372,12 -373,6 +372,6 @@@ static void __cpuinit init_intel(struc
                        set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON);
        }
  
-       if (c->cpuid_level > 6) {
-               unsigned ecx = cpuid_ecx(6);
-               if (ecx & 0x01)
-                       set_cpu_cap(c, X86_FEATURE_APERFMPERF);
-       }
        if (cpu_has_xmm2)
                set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
        if (cpu_has_ds) {
                        set_cpu_cap(c, X86_FEATURE_BTS);
                if (!(l1 & (1<<12)))
                        set_cpu_cap(c, X86_FEATURE_PEBS);
 -              ds_init_intel(c);
        }
  
        if (c->x86 == 6 && c->x86_model == 29 && cpu_has_clflush)
@@@ -73,7 -73,6 +73,7 @@@ enum {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE
  
  struct cpu_dbs_info_s {
        cputime64_t prev_cpu_idle;
 +      cputime64_t prev_cpu_iowait;
        cputime64_t prev_cpu_wall;
        cputime64_t prev_cpu_nice;
        struct cpufreq_policy *cur_policy;
@@@ -109,7 -108,6 +109,7 @@@ static struct dbs_tuners 
        unsigned int down_differential;
        unsigned int ignore_nice;
        unsigned int powersave_bias;
 +      unsigned int io_is_busy;
  } dbs_tuners_ins = {
        .up_threshold = DEF_FREQUENCY_UP_THRESHOLD,
        .down_differential = DEF_FREQUENCY_DOWN_DIFFERENTIAL,
@@@ -150,16 -148,6 +150,16 @@@ static inline cputime64_t get_cpu_idle_
        return idle_time;
  }
  
 +static inline cputime64_t get_cpu_iowait_time(unsigned int cpu, cputime64_t *wall)
 +{
 +      u64 iowait_time = get_cpu_iowait_time_us(cpu, wall);
 +
 +      if (iowait_time == -1ULL)
 +              return 0;
 +
 +      return iowait_time;
 +}
 +
  /*
   * Find right freq to be set now with powersave_bias on.
   * Returns the freq_hi to be used right now and will set freq_hi_jiffies,
@@@ -246,12 -234,8 +246,8 @@@ static ssize_t show_sampling_rate_min(s
        return sprintf(buf, "%u\n", min_sampling_rate);
  }
  
- #define define_one_ro(_name)          \
- static struct global_attr _name =     \
- __ATTR(_name, 0444, show_##_name, NULL)
- define_one_ro(sampling_rate_max);
- define_one_ro(sampling_rate_min);
+ define_one_global_ro(sampling_rate_max);
+ define_one_global_ro(sampling_rate_min);
  
  /* cpufreq_ondemand Governor Tunables */
  #define show_one(file_name, object)                                   \
@@@ -261,7 -245,6 +257,7 @@@ static ssize_t show_##file_name                                            
        return sprintf(buf, "%u\n", dbs_tuners_ins.object);             \
  }
  show_one(sampling_rate, sampling_rate);
 +show_one(io_is_busy, io_is_busy);
  show_one(up_threshold, up_threshold);
  show_one(ignore_nice_load, ignore_nice);
  show_one(powersave_bias, powersave_bias);
@@@ -287,12 -270,8 +283,8 @@@ show_one_old(powersave_bias)
  show_one_old(sampling_rate_min);
  show_one_old(sampling_rate_max);
  
- #define define_one_ro_old(object, _name)       \
- static struct freq_attr object =               \
- __ATTR(_name, 0444, show_##_name##_old, NULL)
- define_one_ro_old(sampling_rate_min_old, sampling_rate_min);
- define_one_ro_old(sampling_rate_max_old, sampling_rate_max);
+ cpufreq_freq_attr_ro_old(sampling_rate_min);
+ cpufreq_freq_attr_ro_old(sampling_rate_max);
  
  /*** delete after deprecation time ***/
  
@@@ -312,23 -291,6 +304,23 @@@ static ssize_t store_sampling_rate(stru
        return count;
  }
  
 +static ssize_t store_io_is_busy(struct kobject *a, struct attribute *b,
 +                                 const char *buf, size_t count)
 +{
 +      unsigned int input;
 +      int ret;
 +
 +      ret = sscanf(buf, "%u", &input);
 +      if (ret != 1)
 +              return -EINVAL;
 +
 +      mutex_lock(&dbs_mutex);
 +      dbs_tuners_ins.io_is_busy = !!input;
 +      mutex_unlock(&dbs_mutex);
 +
 +      return count;
 +}
 +
  static ssize_t store_up_threshold(struct kobject *a, struct attribute *b,
                                  const char *buf, size_t count)
  {
@@@ -406,15 -368,10 +398,11 @@@ static ssize_t store_powersave_bias(str
        return count;
  }
  
- #define define_one_rw(_name) \
- static struct global_attr _name = \
- __ATTR(_name, 0644, show_##_name, store_##_name)
- define_one_rw(sampling_rate);
- define_one_rw(io_is_busy);
- define_one_rw(up_threshold);
- define_one_rw(ignore_nice_load);
- define_one_rw(powersave_bias);
+ define_one_global_rw(sampling_rate);
++define_one_global_rw(io_is_busy);
+ define_one_global_rw(up_threshold);
+ define_one_global_rw(ignore_nice_load);
+ define_one_global_rw(powersave_bias);
  
  static struct attribute *dbs_attributes[] = {
        &sampling_rate_max.attr,
        &up_threshold.attr,
        &ignore_nice_load.attr,
        &powersave_bias.attr,
 +      &io_is_busy.attr,
        NULL
  };
  
@@@ -447,14 -403,10 +435,10 @@@ write_one_old(up_threshold)
  write_one_old(ignore_nice_load);
  write_one_old(powersave_bias);
  
- #define define_one_rw_old(object, _name)       \
- static struct freq_attr object =               \
- __ATTR(_name, 0644, show_##_name##_old, store_##_name##_old)
- define_one_rw_old(sampling_rate_old, sampling_rate);
- define_one_rw_old(up_threshold_old, up_threshold);
- define_one_rw_old(ignore_nice_load_old, ignore_nice_load);
- define_one_rw_old(powersave_bias_old, powersave_bias);
+ cpufreq_freq_attr_rw_old(sampling_rate);
+ cpufreq_freq_attr_rw_old(up_threshold);
+ cpufreq_freq_attr_rw_old(ignore_nice_load);
+ cpufreq_freq_attr_rw_old(powersave_bias);
  
  static struct attribute *dbs_attributes_old[] = {
         &sampling_rate_max_old.attr,
@@@ -502,15 -454,14 +486,15 @@@ static void dbs_check_cpu(struct cpu_db
  
        for_each_cpu(j, policy->cpus) {
                struct cpu_dbs_info_s *j_dbs_info;
 -              cputime64_t cur_wall_time, cur_idle_time;
 -              unsigned int idle_time, wall_time;
 +              cputime64_t cur_wall_time, cur_idle_time, cur_iowait_time;
 +              unsigned int idle_time, wall_time, iowait_time;
                unsigned int load, load_freq;
                int freq_avg;
  
                j_dbs_info = &per_cpu(od_cpu_dbs_info, j);
  
                cur_idle_time = get_cpu_idle_time(j, &cur_wall_time);
 +              cur_iowait_time = get_cpu_iowait_time(j, &cur_wall_time);
  
                wall_time = (unsigned int) cputime64_sub(cur_wall_time,
                                j_dbs_info->prev_cpu_wall);
                                j_dbs_info->prev_cpu_idle);
                j_dbs_info->prev_cpu_idle = cur_idle_time;
  
 +              iowait_time = (unsigned int) cputime64_sub(cur_iowait_time,
 +                              j_dbs_info->prev_cpu_iowait);
 +              j_dbs_info->prev_cpu_iowait = cur_iowait_time;
 +
                if (dbs_tuners_ins.ignore_nice) {
                        cputime64_t cur_nice;
                        unsigned long cur_nice_jiffies;
                        idle_time += jiffies_to_usecs(cur_nice_jiffies);
                }
  
 +              /*
 +               * For the purpose of ondemand, waiting for disk IO is an
 +               * indication that you're performance critical, and not that
 +               * the system is actually idle. So subtract the iowait time
 +               * from the cpu idle time.
 +               */
 +
 +              if (dbs_tuners_ins.io_is_busy && idle_time >= iowait_time)
 +                      idle_time -= iowait_time;
 +
                if (unlikely(!wall_time || wall_time < idle_time))
                        continue;
  
@@@ -664,29 -601,6 +648,29 @@@ static inline void dbs_timer_exit(struc
        cancel_delayed_work_sync(&dbs_info->work);
  }
  
 +/*
 + * Not all CPUs want IO time to be accounted as busy; this dependson how
 + * efficient idling at a higher frequency/voltage is.
 + * Pavel Machek says this is not so for various generations of AMD and old
 + * Intel systems.
 + * Mike Chan (androidlcom) calis this is also not true for ARM.
 + * Because of this, whitelist specific known (series) of CPUs by default, and
 + * leave all others up to the user.
 + */
 +static int should_io_be_busy(void)
 +{
 +#if defined(CONFIG_X86)
 +      /*
 +       * For Intel, Core 2 (model 15) andl later have an efficient idle.
 +       */
 +      if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
 +          boot_cpu_data.x86 == 6 &&
 +          boot_cpu_data.x86_model >= 15)
 +              return 1;
 +#endif
 +      return 0;
 +}
 +
  static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
                                   unsigned int event)
  {
                        dbs_tuners_ins.sampling_rate =
                                max(min_sampling_rate,
                                    latency * LATENCY_MULTIPLIER);
 +                      dbs_tuners_ins.io_is_busy = should_io_be_busy();
                }
                mutex_unlock(&dbs_mutex);