In order to save power, it would be useful to schedule work onto non-IDLE cpusinstead of waking up an IDLE one.

To achieve this, we need scheduler to guide kernel frameworks (like: timers &workqueues) on which is the most preferred CPU that must be used for thesetasks.

This patchset is about implementing this concept.

The first patch adds sched_select_cpu() routine which returns the preferred cpuwhich is non-idle. It accepts max level of sched domain, upto which we canchoose a CPU from. It can accept following options: SD_SIBLING, SD_MC, SD_BOOK,SD_CPU or SD_NUMA.

Second and Third patch are about adapting this change in workqueue framework.

CPU No. of works run by CPU----- -----------------------CPU0: 7CPU1: 445CPU2: 444CPU3: 315CPU4: 226

With my modifications:----------------------

CPU No. of works run by CPU---- -----------------------CPU0: 31CPU2: 797CPU3: 274CPU4: 86

Test case 2:-----------I have created a small module, which does following:- Create one work for each CPU (using queue_work_on(), so must schedule on that cpu)- Above work, will queue "n" works for each cpu with queue_work(). These works are tracked within the module and results are printed at the end.

This gave similar results, with n ranging from 10 to 1000.

Viresh Kumar (3): sched: Create sched_select_cpu() to give preferred CPU for power saving workqueue: create __flush_delayed_work to avoid duplicating code workqueue: Schedule work on non-idle cpu instead of current one