u8500_hotplug: update cpufreq policies and hotplug cpus more appropriately

It is not guaranteed that cpu1 will be offline on suspend, etc. Also only online cpu1 after update cpufreq policy to follow suspend operations.

Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
u8500_hotplug: notify cpufreq only when actually updating

Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
Revert "cpufreq: interactive: eliminate dead band effect in low load"

This reverts commit 49fe6eadab50018bc53b84b5c93471e3a715ac25.

We are not using extended cpufreq steps. We have only around 5 cpufreq steps to cover.
As this commit makes the governor more sensitive to load changes and thus scale cpufreqs more evenly,
we will most likely end up on higher frequencies than actually needed.

Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
cpufreq: interactive: choose the highest frequency at or below target frequency

Due to our limited frequency steps, the closest frequency to target is usually higher than needed.

Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
cpufreq: conservative: add support for micro idle accounting

Originally, mininum sample rate calculations assume that micro idle accounting is non-existent. This is incorrect. Thus, we can afford to set the minimum sample rate to lower levels. This should improve performance on conservative governor by a respectable amount.

With a more accurate and sensitive sample rates, we can afford to loosen up on frequency thresholds.

Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
nohz: Fix update_ts_time_stat idle accounting

update_ts_time_stat currently updates idle time even if we are in
iowait loop at the moment. The only real users of the idle counter
(via get_cpu_idle_time_us) are CPU governors and they expect to get
cumulative time for both idle and iowait times.
The value (idle_sleeptime) is also printed to userspace by print_cpu
but it prints both idle and iowait times so the idle part is misleading.

Let's clean this up and fix update_ts_time_stat to account both counters
properly and update consumers of idle to consider iowait time as well.
If we do this we might use get_cpu_{idle,iowait}_time_us from other
contexts as well and we will get expected values.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
Cc: Dave Jones <davej@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Link: http://lkml.kernel.org/r/e9c909c221a8da402c4da07e4cd968c3218f8eb1.1314172057.git.mhocko@suse.cz
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
cpufreq: conservative: Break out earlier on the lowest frequency

If we're on the lowest frequency, no need to calculate new freq.
Break out even earlier in this case.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[zwliew: adapt for 3.0]
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
cpufreq: conservative: Fix relation when decreasing frequency

The relation should be CPUFREQ_RELATION_L to find optimal frequency
when decreasing.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[zwliew: Adapt for 3.0]
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
cpufreq: conservative: Fix the logic in frequency decrease checking

When we evaluate the CPU load for frequency decrease we have to compare
the load against down_threshold. There is no need to subtract 10 points
from down_threshold.

Instead, we have to use the default down_threshold or user's selection
unmodified.

Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[zwliew: Adapt for 3.0]
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
cpufreq: Add cpu utilization statistics to aid decisions made by userspace.

Understanding system load as seen by cpufreq can help userspace
algorithms make better decisions to improve system responsiveness.
One such example would be the MP decision algorithm which mines
various system info to make decisions on hotplugging in/out
the additional cores.

Change-Id: I277db7e1a7803a3822b61e7befa25131487cfe17
Signed-off-by: Anitha Anand <anithas@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
[zwliew: use userspace max freq instead to account for overclocking]
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
cpufreq: Create a helper function to get CPU utilization

Use the new cpufreq_quick_get_util function in dyn_hotplug driver

Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
[zwliew: only take the cpufreq driver specific parts]
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
cpufreq: interactive: update CPU utilisation

To be used in u8500_hotplug

Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
cpufreq: Initial CPU utilization should be 0

Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>