workqueue: Add helpers to schedule work on any cpu

queue_work() queues work on current cpu. This may wake up an idle CPU, which is
actually not required.

Some of these works can be processed by any CPU and so we must select a non-idle
CPU here. The initial idea was to modify implementation of queue_work(), but
that may end up breaking lots of kernel code that would be a nightmare to debug.

So, we finalized to adding new workqueue interfaces, for works that don't depend
on a cpu to execute them.

This patch adds following new routines:
- queue_work_on_any_cpu
- queue_delayed_work_on_any_cpu

These routines would look for the closest (via scheduling domains) non-idle cpu
(non-idle from schedulers perspective). If the current cpu is not idle or all
cpus are idle, work will be scheduled on local cpu.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Revert "sched: Create sched_select_cpu() to give preferred CPU for power saving"

This reverts commit 9f7c2050bc3e709a8fd39023413e42fe4e017655.
Revert "timer: hrtimer: Don't check idle_cpu() before calling get_nohz_timer_target()"

This reverts commit da31783bd1d6fbb350631c20a246251b45106a3c.
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>