cpufreq: cpu-boost: Introduce scheduler assisted load based syncs

Previously, on getting a migration notification cpu-boost changed
the scaling min of the destination frequency to match that of the
source frequency or sync_threshold whichever was minimum.

If the scheduler migration notification is extended with task load
(cpu demand) information, the cpu boost driver can use this load to
compute a suitable frequency for the migrating task. The required
frequency for the task is calculated by taking the load percentage
of the max frequency and no sync is performed if the load is less
than a particular value (migration_load_threshold).This change is
beneficial for both perf and power as demand of a task is taken into
consideration while making cpufreq decisions and unnecessary syncs
for lightweight tasks are avoided.

The task load information provided by scheduler comes from a
window-based load collection mechanism which also normalizes the
load collected by the scheduler to the max possible frequency
across all CPUs.

Change-Id: Id2ba91cc4139c90602557f9b3801fb06b3c38992
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>

Dorimanx:
full commit here!
https://github.com/myfluxi/kernel_msm/commit/3f668b80c280a2fe3d4f9b3d9cf1935181832fb5

I already have the changes to kernel/sched and include
cpufreq: cpu-boost: Handle wakeup hints received for foreground tasks

A previous change modifies the notification conditions in the scheduler
to call the notifier chain even on foreground_thread wakeups for tasks
having load more than a threshold value.

If load_based_syncs is turned OFF then we do not need to perform
cpu boost for wakeup hints for foreground tasks from scheduler

Change-Id: Ifbdd3eccac5c9892dfc3a3c3edbfc0df766478ed
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
sched: Disable wakeup hints for foreground tasks by default

By default sched_wakeup_load_threshold is set to 60 and therefore
wakeup hints are sent out for those tasks whose loads are higher
that value. This might cause unnecessary wakeup boosts to happen
when load based syncing is turned ON for cpu-boost.
Disable the wake up hints by setting the sched_wakeup_load_threshold
to a value higher than 100 so that wakeup boost doesnt happen unless
it is explicitly turned ON from adb shell.

Change-Id: I9b8a594c2bfdf2e092cc645e50c0c21efc514c2f
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
sched: Window-based load stat improvements

Some tasks can have a sporadic load pattern such that they can suddenly
start running for longer intervals of time after running for shorter
durations. To recognize such sharp increase in tasks' demands, max
between the average of 5 window load samples and the most recent sample
is chosen as the task demand.

Make the window size (sched_ravg_window) configurable at boot up
time. To prevent users from setting inappropriate values for window
size, min and max limits are defined. As 'ravg' struct tracks load for
both real-time and non real-time tasks it is moved out of sched_entity
struct.

In order to prevent changing function signatures for move_tasks() and
move_one_task() per-cpu variables are defined to track the total load
moved. In case multiple tasks are selected to migrate in one load
balance operation, loads > 100 could be sent through migration notifiers.
Prevent this scenario by setting mnd.load to 100 in such cases.

Define wrapper functions to compute cpu demands for tasks and to change
rq->cumulative_runnable_avg.

Change-Id: I9abfbf3b5fe23ae615a6acd3db9580cfdeb515b4
Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org>
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>

Conflicts:
	kernel/sched/core.c
	kernel/sysctl.c
Disable SCHED CORE Trace CRAP.

Conflicts:
	kernel/sched/core.c
msm: rq_stats: Disable hotplug and stats by default

Userspace closed source mpdecision binary is nessecary for PowerHAL to work.
As it depends on rq_stats, let's at least disable hotplugging and stats
collection by default. /sys/devices/system/cpu/cpu0/rq-stats/hotplug_disable
is now writable, so hotplug can be reenabled.

Also, add some bits related to current cpu policy.

Conflicts:
	arch/arm/mach-msm/msm_rq_stats.c
msm: hotplug: On- and offline cpus only when enabled

I mean really, really enabled...
sched: Calculate max_possible_freq based on current policy->max
cpufreq: ondemand: Calculate load_at_max_freq based on current policy->max
cpufreq: Calculate load_at_max_freq based on current policy->max

fix by myfluxi!

https://github.com/myfluxi/kernel_msm/commit/4c5d76153015760f2cddedbc5f4751ccee668f28
MSM HotPlug: Correct enable to msm_enable :)
INTELLI HotPlug: Updates by @Faux123 bump to v3.5

Intelli_plug: add wakeup cpufreq boost for quicker wakeup
https://github.com/faux123/Nexus_5/commit/0934c4775aec8cfdbb992174e8b66737cf612a41

intelli_plug: add screen off max controls
https://github.com/faux123/Nexus_5/commit/8f3d3588fe6d8bf92675a1f05889b99b37d377cb
Merged rq_stats with the one existing in @Dorimanx repo.
Fixed msm_rq_stats disabling enabling.