kernel: sched: LOAD_FREQ (4*HZ+61) avoids loadavg Moire [AndreiLux]

LOAD_FREQ is (5*HZ+1) to avoid high load average when idle: http://kerneltrap.org/mailarchive/linux-kernel/2007/10/3/328568

I suggest (4*HZ+61) for a better distribution.

With some seconds based load (like SSL heartbeats) and LOAD_FREQ at (5*HZ+1) I see Moire patterns like inverse sawtooth, since 2 or 3 probes hit the jobs (load increases quickly), followed by several probes missing it.

A 4.61 sec interval gives optimal distribution over when within a second a probe is taken, as .61 is close to golden ratio phi 1.618... (test in http://ripke.com/goldenratio.c).

12*4.61 = 55.32 secs is still close to a minute, and 13*4.61=59.93 is even closer than the current 12*5.01=60.12 (with exponents EXP_x adjusted to a ratio of 13 instead of 12).
sched: LOAD_FREQ (4*HZ+122) avoids loadavg Moire [halaszk]

From http://ripke.com/loadavg/moire but corrected for 200HZ.
beautyfied last commit: changed some spaces back to tabs again.
cpufreq: tidy up
scheduler: BFQ-v7r4 for 3.4.0 [Paolo Valente]
scheduler: update BFQ-v7r4 to BFQ-v7r5 for 3.4.0 [Paolo Valente]
bfq-iosched: tuning for SSD [anarkia1976]
workqueue: add system wide power_efficient workqueues (squash commits)

7. workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues

Adapted for 3.4 from lsk-v3.10

Workqueues can be performance or power-oriented. Currently, most workqueues are
bound to the CPU they were created on. This gives good performance (due to cache

effects) at the cost of potentially waking up otherwise idle cores (Idle from

scheduler's perspective. Which may or may not be physically idle) just to

process some work. To save power, we can allow the work to be rescheduled on a

core that is already awake.

Workqueues created with the WQ_UNBOUND flag will allow some power savings.

However, we don't change the default behaviour of the system.  To enable

power-saving behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT needs to

be turned on. This option can also be overridden by the

workqueue.power_efficient boot parameter.

tj: Updated config description and comments.  Renamed

    CONFIG_WQ_POWER_EFFICIENT to CONFIG_WQ_POWER_EFFICIENT_DEFAULT.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>

Signed-off-by: Tejun Heo <tj@kernel.org>

(cherry picked from commit cee22a1)

Signed-off-by: Mark Brown <broonie@linaro.org>

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

Signed-off-by: poondog <markj338@gmail.com>

6. regulator: core: Use the power efficient workqueue for delayed powerdown

Adapted for 3.4 from lsk-v3.10

There is no need to use a normal per-CPU workqueue for delayed power downs

as they're not timing or performance critical and waking up a core for them

would defeat some of the point.

Signed-off-by: Mark Brown <broonie@linaro.org>

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>

Acked-by: Liam Girdwood <liam.r.girdwood@intel.com>

(cherry picked from commit 070260f07c7daec311f2466eb9d1df475d5a46f8)

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

Signed-off-by: poondog <markj338@gmail.com>

5. ASoC: jack: Use power efficient workqueue

Adapted for 3.4 from lsk-v3.10

The accessory detect debounce work is not performance sensitive so let

the scheduler run it wherever is most efficient rather than in a per CPU

workqueue by using the system power efficient workqueue.

Signed-off-by: Mark Brown <broonie@linaro.org>

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

(cherry picked from commit e6058aaadcd473e5827720dc143af56aabbeecc7)

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

Signed-off-by: poondog <markj338@gmail.com>

4. ASoC: pcm: Use the power efficient workqueue for delayed powerdown

Adapted for 3.4 from lsk-v3.10

There is no need to use a normal per-CPU workqueue for delayed power downs

as they're not timing or performance critical and waking up a core for them

would defeat some of the point.

Signed-off-by: Mark Brown <broonie@linaro.org>

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>

(cherry picked from commit d4e1a73acd4e894f8332f2093bceaef585cfab67)

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

Signed-off-by: poondog <markj338@gmail.com>

3. PHYLIB: queue work on system_power_efficient_wq

Adapted for 3.4 from lsk-v3.10

Phylib uses workqueues for multiple purposes. There is no real dependency of

scheduling these on the cpu which scheduled them.

On a idle system, it is observed that and idle cpu wakes up many times just to

service this work. It would be better if we can schedule it on a cpu which the

scheduler believes to be the most appropriate one.

This patch replaces system_wq with system_power_efficient_wq for PHYLIB.

Cc: David S. Miller <davem@davemloft.net>

Cc: netdev@vger.kernel.org

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Acked-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Tejun Heo <tj@kernel.org>

(cherry picked from commit bbb47bdeae756f04b896b55b51f230f3eb21f207)

Signed-off-by: Mark Brown <broonie@linaro.org>

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

Signed-off-by: poondog <markj338@gmail.com>

2. block: queue work on power efficient wq

Adapted for 3.4 from lsk-v3.10

Block layer uses workqueues for multiple purposes. There is no real dependency

of scheduling these on the cpu which scheduled them.

On a idle system, it is observed that and idle cpu wakes up many times just to

service this work. It would be better if we can schedule it on a cpu which the

scheduler believes to be the most appropriate one.

This patch replaces normal workqueues with power efficient versions.

Cc: Jens Axboe <axboe@kernel.dk>

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Signed-off-by: Tejun Heo <tj@kernel.org>

(cherry picked from commit 695588f9454bdbc7c1a2fbb8a6bfdcfba6183348)

Signed-off-by: Mark Brown <broonie@linaro.org>

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

Signed-off-by: poondog <markj338@gmail.com>

1. workqueue: add system wide power_efficient workqueues

Adapted for 3.4 from lsk-v3.10

This patch adds system wide workqueues aligned towards power saving. This is

done by allocating them with WQ_UNBOUND flag if 'wq_power_efficient' is set to

'true'.

tj: updated comments a bit.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Signed-off-by: Tejun Heo <tj@kernel.org>

(cherry picked from commit 0668106ca3865ba945e155097fb042bf66d364d3)

Signed-off-by: Mark Brown <broonie@linaro.org>

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
CPUFREQ: ondemand: use power efficient wq! [halaszk]
workqueue: fix permission for power_efficient [neobuddy89]
enabled bfq iomscheduler.
set permissions of block/bfq*[ch] to 0644.