sched: Create sched_select_non_idle_cpu() to give preferred CPU for power saving

In order to save power, it would be useful to schedule light weight work on cpus
that aren't IDLE instead of waking up an IDLE one.

By idle cpu (from scheduler's perspective) we mean:
- Current task is idle task
- nr_running == 0
- wake_list is empty

This is already implemented for timers as get_nohz_timer_target(). We can figure
out few more users of this feature, like workqueues.

This patch converts get_nohz_timer_target() into a generic API
sched_select_non_idle_cpu() so that other frameworks (like workqueue) can also
use it.

This routine returns the cpu which is non-idle. If the local CPU isn't idle OR
all cpus are idle, local cpu is returned back. If local cpu is idle, then we
must look for another CPU which isn't idle.

This patch reuses the code from get_nohz_timer_target() routine, which had
similar implementation.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Seongmin Park <r_data@naver.com>
Signed-off-by: scotthartbti <scott.hart.bti@gmail.com>

Conflicts:
	include/linux/sched.h
Conservative Updates

Change-Id: I49a280326aa528b192ae01c5fe1455edc2fa6fa5
Signed-off-by: scotthartbti <scott.hart.bti@gmail.com>

Conflicts:
	drivers/cpufreq/cpufreq_conservative.c
Disable bcmdhd debugging and disable nat keep alive.
Signed-off-by: scotthartbti <scott.hart.bti@gmail.com>
mutex: dynamically disable mutex spinning at high load
Signed-off-by: scotthartbti <scott.hart.bti@gmail.com>
lib/sha1: use the git implementation of SHA-1

For ChromiumOS, we use SHA-1 to verify the integrity of the root
filesystem.  The speed of the kernel sha-1 implementation has a major
impact on our boot performance.

To improve boot performance, we investigated using the heavily optimized
sha-1 implementation used in git.  With the git sha-1 implementation, we
see a 11.7% improvement in boot time.

10 reboots, remove slowest/fastest.

Before:

  Mean: 6.58 seconds Stdev: 0.14

After (with git sha-1, this patch):

  Mean: 5.89 seconds Stdev: 0.07

The other cool thing about the git SHA-1 implementation is that it only
needs 64 bytes of stack for the workspace while the original kernel
implementation needed 320 bytes.

Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Cc: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Cc: Nicolas Pitre <nico@cam.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David S. Miller <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Remove ARM sha1 routines - No longer work.
Signed-off-by: scotthartbti <scott.hart.bti@gmail.com>
Multiple mutex/hrtimer picks

* Mutex - Restrict mutex spinning to only one task per mutex
* hrtimer: Consider preemption when migrating hrtimer cpu_bases
* hrtimer: Prevent enqueue of hrtimer on dead CPU
* mutex: Make more scalable by doing less atomic operation
* mutex: dynamically disable mutex spinning at high load

Signed-off-by: scotthartbti <scott.hart.bti@gmail.com>
REVERT: Make more scalable by doing less atomic operation
Signed-off-by: scotthartbti <scott.hart.bti@gmail.com>