Merge branches 'pm-sleep', 'pm-cpufreq' and 'pm-cpuidle'
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 11 Aug 2014 21:19:48 +0000 (23:19 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 11 Aug 2014 21:19:48 +0000 (23:19 +0200)
* pm-sleep:
  PM / hibernate: avoid unsafe pages in e820 reserved regions

* pm-cpufreq:
  cpufreq: arm_big_little: fix module license spec
  cpufreq: speedstep-smi: fix decimal printf specifiers
  cpufreq: OPP: Avoid sleeping while atomic
  cpufreq: cpu0: Do not print error message when deferring
  cpufreq: integrator: Use set_cpus_allowed_ptr

* pm-cpuidle:
  cpuidle: menu: Lookup CPU runqueues less
  cpuidle: menu: Call nr_iowait_cpu less times
  cpuidle: menu: Use ktime_to_us instead of reinventing the wheel
  cpuidle: menu: Use shifts when calculating averages where possible

drivers/cpufreq/arm_big_little.c
drivers/cpufreq/arm_big_little_dt.c
drivers/cpufreq/cpufreq-cpu0.c
drivers/cpufreq/cpufreq_opp.c
drivers/cpufreq/integrator-cpufreq.c
drivers/cpufreq/speedstep-smi.c
drivers/cpuidle/governors/menu.c
include/linux/sched.h
kernel/power/snapshot.c
kernel/sched/core.c
kernel/sched/proc.c

index 1f4d4e31505746db9e2cc5565710d4180349245b..a46c223c2506283fa0636b3c24013c3a8a76d094 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/cpufreq.h>
 #include <linux/cpumask.h>
 #include <linux/export.h>
+#include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/of_platform.h>
 #include <linux/pm_opp.h>
@@ -593,3 +594,7 @@ void bL_cpufreq_unregister(struct cpufreq_arm_bL_ops *ops)
        arm_bL_ops = NULL;
 }
 EXPORT_SYMBOL_GPL(bL_cpufreq_unregister);
+
+MODULE_AUTHOR("Viresh Kumar <viresh.kumar@linaro.org>");
+MODULE_DESCRIPTION("Generic ARM big LITTLE cpufreq driver");
+MODULE_LICENSE("GPL v2");
index 8d9d5910890689e58d5994d6aeebfccf03215c59..4550f6976768ac83706b76e1fb29ea18a124abe5 100644 (file)
@@ -114,4 +114,4 @@ module_platform_driver(generic_bL_platdrv);
 
 MODULE_AUTHOR("Viresh Kumar <viresh.kumar@linaro.org>");
 MODULE_DESCRIPTION("Generic ARM big LITTLE cpufreq driver via DT");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
index 86beda9f950b7a8b3620b458f8d42b231fdde624..0d2172b077651e3b5d3340d925210b201e416e84 100644 (file)
@@ -137,7 +137,7 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
                 * not yet registered, we should try defering probe.
                 */
                if (PTR_ERR(cpu_reg) == -EPROBE_DEFER) {
-                       dev_err(cpu_dev, "cpu0 regulator not ready, retry\n");
+                       dev_dbg(cpu_dev, "cpu0 regulator not ready, retry\n");
                        ret = -EPROBE_DEFER;
                        goto out_put_node;
                }
index c0c6f4a4eccf540aa43a1508cfd10a304674bdea..f7a32d2326c6428f4f4e8b1000381b7dc4301e5f 100644 (file)
@@ -60,7 +60,7 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev,
                goto out;
        }
 
-       freq_table = kzalloc(sizeof(*freq_table) * (max_opps + 1), GFP_KERNEL);
+       freq_table = kcalloc(sizeof(*freq_table), (max_opps + 1), GFP_ATOMIC);
        if (!freq_table) {
                ret = -ENOMEM;
                goto out;
index e5122f1bfe78ca8f9d37881053b85cd02b94c881..c1320528b9d0c0060247b4d025bc35116701996a 100644 (file)
@@ -92,7 +92,7 @@ static int integrator_set_target(struct cpufreq_policy *policy,
         * Bind to the specified CPU.  When this call returns,
         * we should be running on the right CPU.
         */
-       set_cpus_allowed(current, cpumask_of_cpu(cpu));
+       set_cpus_allowed_ptr(current, cpumask_of(cpu));
        BUG_ON(cpu != smp_processor_id());
 
        /* get current setting */
@@ -118,7 +118,7 @@ static int integrator_set_target(struct cpufreq_policy *policy,
        freqs.new = icst_hz(&cclk_params, vco) / 1000;
 
        if (freqs.old == freqs.new) {
-               set_cpus_allowed(current, cpus_allowed);
+               set_cpus_allowed_ptr(current, &cpus_allowed);
                return 0;
        }
 
@@ -141,7 +141,7 @@ static int integrator_set_target(struct cpufreq_policy *policy,
        /*
         * Restore the CPUs allowed mask.
         */
-       set_cpus_allowed(current, cpus_allowed);
+       set_cpus_allowed_ptr(current, &cpus_allowed);
 
        cpufreq_freq_transition_end(policy, &freqs, 0);
 
@@ -157,7 +157,7 @@ static unsigned int integrator_get(unsigned int cpu)
 
        cpus_allowed = current->cpus_allowed;
 
-       set_cpus_allowed(current, cpumask_of_cpu(cpu));
+       set_cpus_allowed_ptr(current, cpumask_of(cpu));
        BUG_ON(cpu != smp_processor_id());
 
        /* detect memory etc. */
@@ -173,7 +173,7 @@ static unsigned int integrator_get(unsigned int cpu)
 
        current_freq = icst_hz(&cclk_params, vco) / 1000; /* current freq */
 
-       set_cpus_allowed(current, cpus_allowed);
+       set_cpus_allowed_ptr(current, &cpus_allowed);
 
        return current_freq;
 }
index 8635eec96da5c3c7f210467a497b20b53eb52c32..5fc96d5d656bafc251293d753be52326257a6c0b 100644 (file)
@@ -324,8 +324,8 @@ static int __init speedstep_init(void)
                return -ENODEV;
        }
 
-       pr_debug("signature:0x%.8ulx, command:0x%.8ulx, "
-               "event:0x%.8ulx, perf_level:0x%.8ulx.\n",
+       pr_debug("signature:0x%.8x, command:0x%.8x, "
+               "event:0x%.8x, perf_level:0x%.8x.\n",
                ist_info.signature, ist_info.command,
                ist_info.event, ist_info.perf_level);
 
index c3732fa74f828b61172bd8a10e2953c8226b6689..27702742b31922e5508ad86347b1884b30d5c281 100644 (file)
@@ -31,7 +31,8 @@
  * The default values do not overflow.
  */
 #define BUCKETS 12
-#define INTERVALS 8
+#define INTERVAL_SHIFT 3
+#define INTERVALS (1UL << INTERVAL_SHIFT)
 #define RESOLUTION 1024
 #define DECAY 8
 #define MAX_INTERESTING 50000
@@ -133,15 +134,12 @@ struct menu_device {
 #define LOAD_INT(x) ((x) >> FSHIFT)
 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
 
-static int get_loadavg(void)
+static inline int get_loadavg(unsigned long load)
 {
-       unsigned long this = this_cpu_load();
-
-
-       return LOAD_INT(this) * 10 + LOAD_FRAC(this) / 10;
+       return LOAD_INT(load) * 10 + LOAD_FRAC(load) / 10;
 }
 
-static inline int which_bucket(unsigned int duration)
+static inline int which_bucket(unsigned int duration, unsigned long nr_iowaiters)
 {
        int bucket = 0;
 
@@ -151,7 +149,7 @@ static inline int which_bucket(unsigned int duration)
         * This allows us to calculate
         * E(duration)|iowait
         */
-       if (nr_iowait_cpu(smp_processor_id()))
+       if (nr_iowaiters)
                bucket = BUCKETS/2;
 
        if (duration < 10)
@@ -174,16 +172,16 @@ static inline int which_bucket(unsigned int duration)
  * to be, the higher this multiplier, and thus the higher
  * the barrier to go to an expensive C state.
  */
-static inline int performance_multiplier(void)
+static inline int performance_multiplier(unsigned long nr_iowaiters, unsigned long load)
 {
        int mult = 1;
 
        /* for higher loadavg, we are more reluctant */
 
-       mult += 2 * get_loadavg();
+       mult += 2 * get_loadavg(load);
 
        /* for IO wait tasks (per cpu!) we add 5x each */
-       mult += 10 * nr_iowait_cpu(smp_processor_id());
+       mult += 10 * nr_iowaiters;
 
        return mult;
 }
@@ -227,7 +225,10 @@ again:
                                max = value;
                }
        }
-       do_div(avg, divisor);
+       if (divisor == INTERVALS)
+               avg >>= INTERVAL_SHIFT;
+       else
+               do_div(avg, divisor);
 
        /* Then try to determine standard deviation */
        stddev = 0;
@@ -238,7 +239,11 @@ again:
                        stddev += diff * diff;
                }
        }
-       do_div(stddev, divisor);
+       if (divisor == INTERVALS)
+               stddev >>= INTERVAL_SHIFT;
+       else
+               do_div(stddev, divisor);
+
        /*
         * The typical interval is obtained when standard deviation is small
         * or standard deviation is small compared to the average interval.
@@ -288,7 +293,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
        int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
        int i;
        unsigned int interactivity_req;
-       struct timespec t;
+       unsigned long nr_iowaiters, cpu_load;
 
        if (data->needs_update) {
                menu_update(drv, dev);
@@ -302,12 +307,10 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
                return 0;
 
        /* determine the expected residency time, round up */
-       t = ktime_to_timespec(tick_nohz_get_sleep_length());
-       data->next_timer_us =
-               t.tv_sec * USEC_PER_SEC + t.tv_nsec / NSEC_PER_USEC;
-
+       data->next_timer_us = ktime_to_us(tick_nohz_get_sleep_length());
 
-       data->bucket = which_bucket(data->next_timer_us);
+       get_iowait_load(&nr_iowaiters, &cpu_load);
+       data->bucket = which_bucket(data->next_timer_us, nr_iowaiters);
 
        /*
         * Force the result of multiplication to be 64 bits even if both
@@ -325,7 +328,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
         * duration / latency ratio. Adjust the latency limit if
         * necessary.
         */
-       interactivity_req = data->predicted_us / performance_multiplier();
+       interactivity_req = data->predicted_us / performance_multiplier(nr_iowaiters, cpu_load);
        if (latency_req > interactivity_req)
                latency_req = interactivity_req;
 
index 7c19d552dc3f734d44741cae25b6df60fe52336f..84729f7c472cd15136fa5f34a013104c34820a27 100644 (file)
@@ -168,8 +168,7 @@ extern int nr_processes(void);
 extern unsigned long nr_running(void);
 extern unsigned long nr_iowait(void);
 extern unsigned long nr_iowait_cpu(int cpu);
-extern unsigned long this_cpu_load(void);
-
+extern void get_iowait_load(unsigned long *nr_waiters, unsigned long *load);
 
 extern void calc_global_load(unsigned long ticks);
 extern void update_cpu_load_nohz(void);
index 4fc5c32422b39db0e509ea35e675b3852db895eb..c4b8093c80b3bad9b6f9cd56a086df5a4c159508 100644 (file)
@@ -954,6 +954,25 @@ static void mark_nosave_pages(struct memory_bitmap *bm)
        }
 }
 
+static bool is_nosave_page(unsigned long pfn)
+{
+       struct nosave_region *region;
+
+       list_for_each_entry(region, &nosave_regions, list) {
+               if (pfn >= region->start_pfn && pfn < region->end_pfn) {
+                       pr_err("PM: %#010llx in e820 nosave region: "
+                              "[mem %#010llx-%#010llx]\n",
+                              (unsigned long long) pfn << PAGE_SHIFT,
+                              (unsigned long long) region->start_pfn << PAGE_SHIFT,
+                              ((unsigned long long) region->end_pfn << PAGE_SHIFT)
+                                       - 1);
+                       return true;
+               }
+       }
+
+       return false;
+}
+
 /**
  *     create_basic_memory_bitmaps - create bitmaps needed for marking page
  *     frames that should not be saved and free page frames.  The pointers
@@ -2015,7 +2034,7 @@ static int mark_unsafe_pages(struct memory_bitmap *bm)
        do {
                pfn = memory_bm_next_pfn(bm);
                if (likely(pfn != BM_END_OF_MAP)) {
-                       if (likely(pfn_valid(pfn)))
+                       if (likely(pfn_valid(pfn)) && !is_nosave_page(pfn))
                                swsusp_set_page_free(pfn_to_page(pfn));
                        else
                                return -EFAULT;
index 1211575a220895dab1c9c2eba9fa20bf688420ff..ec1a286684a56047a4352350edf4c0686e4ba70e 100644 (file)
@@ -2393,6 +2393,13 @@ unsigned long nr_iowait_cpu(int cpu)
        return atomic_read(&this->nr_iowait);
 }
 
+void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
+{
+       struct rq *this = this_rq();
+       *nr_waiters = atomic_read(&this->nr_iowait);
+       *load = this->cpu_load[0];
+}
+
 #ifdef CONFIG_SMP
 
 /*
index 16f5a30f9c888fe46d2055ffb2dc0771f0554e63..8ecd552fe4f2229eacabe8d1e9bb1941078fb577 100644 (file)
@@ -8,13 +8,6 @@
 
 #include "sched.h"
 
-unsigned long this_cpu_load(void)
-{
-       struct rq *this = this_rq();
-       return this->cpu_load[0];
-}
-
-
 /*
  * Global load-average calculations
  *