arm: Add auto hotplug driver

This driver is simple and cheap and aims to avoid unnecessary hotplug
events and unnecessary task migrations. The design is simple. The value
of nr_running() (which is the current number of runnable threads) is
averaged over X samples by a ringbuffer. If the value is over a
dynamically calculated value, all CPUs are onlined. When the value falls
under another dynamically calculated value, the CPUs are offlined with a
2 second delay. If there is persistent load on the system, the CPUs will
not continually thrash between onlining and offlining and continually
migrate tasks. The number of online CPUs will remain constant until the
load has dropped below the dynamically calculated value. The online and
offline values are dynamically scaled based on the number of CPUs
online, as is the sampling rate of the driver. This aims to reduce the
expense of the driver and also reduce the number of unless hotplug
transitions which could have been avoided had cpufreq been given the
chance to ramp the online CPUs up and deal with the load. This driver
will also offline secondary cores when the screen is turned off,
providing earlysuspend is available.

It also has a module param to set
the minimum number of online CPUs:
/sys/module/auto_hotplug/parameters/min_online_cpus
This value is ignored when the device enters earlysuspend, as the
secondary CPUs are all offlined, but is set again when the screen is
turned back on.
Change dependencies to allow kernel to be built with ARM hotplug,
and without MSM_RUN_QUEUE_STATS. These are only needed for proprietary
mpdecision.
arm: auto hotplug - wrap all pr_info into the existing debug mode so we
don't spam the kernel log
auto_hotplug: enhancements

1) added module params so tuning an be adjusted in userspace and
debugging can easliy be enabled/disabled

/sys/module/auto_hotplug/parameters/debug
(N/Y - turn off/on debugging)

/sys/module/auto_hotplug/parameters/disable_load_threshold
(integer - load at which a CPU is disabled)

/sys/module/auto_hotplug/parameters/enable_load_threshold (integer -
load at which an extra CPU is enabled)

/sys/module/auto_hotplug/parameters/enable_all_load_threshold (integer -
load at wich all CPU's are enabled)

/sys/module/auto_hotplug/parameters/min_sampling_rate
(milliseconds, converted to jiffies at runtime)

2) lowered enable_load_threshold from 225 to 200 for a little more pep.

To-do: add get/set routines to keep values safe and in acceptable ranges
auto_hotplug: enhancements (rev 2)

1) Added ability to change the number of sampling_periods on the fly via
sysfs (while preserving past history).

2) Added get/set for module parameters so user's can't set incorrect or
unreasonable values.

3) Tweaked defaults

4) Don't wait as long to start auto_hotplug (referenced franco's
git). Today's devices are much faster to boot however
if this code is ported to a slower core device, it may need to be
raised.

5) Debug mode tweaks
-Organize and reduce the number of line output.
-Attempt to make output more user friendly for those that aren't
reading the code.
auto_hotplug: enable the min_online_cpus value

Use a module_param_cb to set the minimum number of online CPUs when the
screen is on.

The values are between 1-4.

usage:
echo '1' < /sys/module/auto_hotplug/parameters/min_online_cpus
auto_hotplug: enhancements (rev 3)

1) Added max_online_cpus (1-4) and exposed to sysfs via a module
parameter. Once set, only allow the chosen number of cores to be
online and make sure we compensate for it in the boostpulse function.

2) Make minor tweaks to mathkid's min_online_cpus

-Don't schedule work in the parameter set, just let it be done on the
next poll iteration.

-Misc style changes so that it matches the other code I have been
adding the module.
auto_hotplug: parameter validation for max_online_cpus

If validation fails, set max_online_cpus = CPUS_AVAILABLE instead of
"1"
auto_hotplug: stack the deck on auto_hotplug_late_resume to get things
moving quickly again
auto_hotplug: rev 4 - let's lean a little more towards performance.

This includes:

1) Set DEFAULT_SAMPLING_PERIODS back to 10 (from 12)

2) Set DEFAULT_ENABLE_ALL_LOAD_THRESHOLD to (100 * CPUS)

3) Finally came back and fixed "stack the deck" like I had originally
intended after the quick test.

4) Updated to revision to 4.
cpufreq: interactive: marry governor boostpulse with auto_hotplug
boostpulse.

Limit boosted cores to 2 since that matches with what auto_hotplug
boostpulse brings online. We will boost no more than 2 cores.

Also tweaked some other defaults

Conflicts:

	drivers/cpufreq/cpufreq_interactive.c
smp: patches from mainline 3.5 to hopefully help with hotplug
efficiency

Thomas Gleixner's generic-idle patches:

smp: Add task_struct argument to __cpu_up()
Preparatory patch to make the idle thread allocation for secondary
cpus generic.
http://git.kernel.org/?p=linux/kernel/git/tip/tip.git;a=commit;h=8239c25f47d2b318156993b15f33900a86ea5e17

smp: Add generic smpboot facility
Start a new file, which will hold SMP and CPU hotplug related generic
infrastructure.
http://git.kernel.org/?p=linux/kernel/git/tip/tip.git;a=commit;h=38498a67aa2cf8c80754b8d304bfacc10bc582b5

smp: Provide generic idle thread allocation
All SMP architectures have magic to fork the idle task and to store it
for reusage when cpu hotplug is enabled. Provide a generic
infrastructure for it.
Create/reinit the idle thread for the cpu which is brought up in the
generic code and hand the thread pointer to the architecture code via
__cpu_up().
Note, that fork_idle() is called via a workqueue, because this
guarantees that the idle thread does not get a reference to a user
space VM. This can happen when the boot process did not bring up all
possible cpus and a later cpu_up() is initiated via the sysfs
interface. In that case fork_idle() would be called in the context of
the user space task and take a reference on the user space VM.
http://git.kernel.org/?p=linux/kernel/git/tip/tip.git;a=commit;h=29d5e0476e1c4a513859e7858845ad172f560389

arm: Use generic idle thread allocation
http://git.kernel.org/?p=linux/kernel/git/tip/tip.git;a=commit;h=84ec6d5796e095e2f8698bd2b5d33849ed26d9e2
auto_hotplug: remove no-op code for dual core devices
- when we enable our secondary core, we are already enabling them all; so we don't necessarily need an instance for when we 'online all cores'
Signed-off-by: Luis Cruz <ljc2491@gmail.com>

fix error
Auto hotplug: some fix ups for Linux 3.4 to stop jitter

Conflicts:

	arch/arm/kernel/auto_hotplug.c

Signed-off-by: Luis Cruz <ljc2491@gmail.com>

fix
auto_hotplug: make things less aggressive
Hoping to save some battery with these adjustments, because we aren't hotplugging so much when unnecessary
- more sampling
- require less workload to enable CPU
- disable CPU at a lower latency
Signed-off-by: Luis Cruz <ljc2491@gmail.com>
auto_hotplug: adjustments based on morfic's 3.4 kernel
- with a bit of adjusting based on my own testing
- clean up whitespace
Signed-off-by: Luis Cruz <ljc2491@gmail.com>
zen-tune: Implement zen-tune ([more] simplified version)

* creates tuning header based off of zen kernel's so that it is easy to
switch between defaults and tunings; also allows for tuning to be done all in
one place.

Conflicts:
	kernel/sched/bfs.c
	init/Kconfig

Conflicts:

	kernel/sched/bfs.c
	mm/page-writeback.c

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
zen-tune: add custom configuration for cpufreq ondemand down sampling factor

Conflicts:
	drivers/cpufreq/cpufreq_ondemand.c

Conflicts:

	drivers/cpufreq/cpufreq_ondemand.c

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
zen-tune: set dirty_ratio / dirty_background_ratio to 50 / 20

Conflicts:

	init/Kconfig

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
zen-tune: add more custom values to zentune.h

More values are changed to reduce average time slice and increase opportunities
for kernel preemption.

Conflicts:

	include/linux/zentune.h

Signed-off-by: Luis Cruz <ljc2491@gmail.com>