lkml.org 
[lkml]   [2012]   [Sep]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [PATCH V2 3/3] workqueue: Schedule work on non-idle cpu instead of current one
From
On 27 September 2012 14:34, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Workqueues queues work on current cpu, if the caller haven't passed a preferred
> cpu. This may wake up an idle CPU, which is actually not required.
>
> This work can be processed by any CPU and so we must select a non-idle CPU here.
> This patch adds in support in workqueue framework to get preferred CPU details
> from the scheduler, instead of using current CPU.
>
> Most of the time when a work is queued, the current cpu isn't idle and so we
> will choose it only. There are cases when a cpu is idle when it queues some
> work. For example, consider following scenario:
> - A cpu has programmed a timer and is IDLE now.
> - CPU gets into interrupt handler due to timer and queues a work. As the CPU is
> currently IDLE, we can queue this work to some other CPU.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> kernel/workqueue.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 143fd8c..5fa4ba4 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -1238,7 +1238,7 @@ static void __queue_work(unsigned int cpu, struct workqueue_struct *wq,
> struct global_cwq *last_gcwq;
>
> if (cpu == WORK_CPU_UNBOUND)
> - cpu = raw_smp_processor_id();
> + cpu = sched_select_cpu(0);

Hi Tejun,

Following change is also required with this patch:


--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1383,7 +1383,7 @@ static void __queue_delayed_work(int cpu, struct
workqueue_struct *wq,
if (gcwq)
lcpu = gcwq->cpu;
if (lcpu == WORK_CPU_UNBOUND)
- lcpu = raw_smp_processor_id();
+ lcpu = sched_select_cpu(0);
} else {
lcpu = WORK_CPU_UNBOUND;
}
Otherwise, we will end up running the re-reentrancy check, which we are trying
to skip for delayed work.

--
viresh


\
 
 \ /
  Last update: 2012-09-28 09:01    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog