diff options
author | Joonsoo Kim <js1304@gmail.com> | 2012-08-15 10:25:38 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2012-08-16 17:21:15 -0400 |
commit | e42986de481238204f6e0b0f4434da428895c20b (patch) | |
tree | 613150adf76500507ca69d59d5448fa05affbc98 /kernel/workqueue.c | |
parent | b75cac9368fa91636e17d0f7950b35d837154e14 (diff) |
workqueue: change value of lcpu in __queue_delayed_work_on()
We assign cpu id into work struct's data field in __queue_delayed_work_on().
In current implementation, when work is come in first time,
current running cpu id is assigned.
If we do __queue_delayed_work_on() with CPU A on CPU B,
__queue_work() invoked in delayed_work_timer_fn() go into
the following sub-optimal path in case of WQ_NON_REENTRANT.
gcwq = get_gcwq(cpu);
if (wq->flags & WQ_NON_REENTRANT &&
(last_gcwq = get_work_gcwq(work)) && last_gcwq != gcwq) {
Change lcpu to @cpu and rechange lcpu to local cpu if lcpu is WORK_CPU_UNBOUND.
It is sufficient to prevent to go into sub-optimal path.
tj: Slightly rephrased the comment.
Signed-off-by: Joonsoo Kim <js1304@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index c29f2dc0f4fc..99ee9b939264 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -1356,9 +1356,15 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq, | |||
1356 | if (!(wq->flags & WQ_UNBOUND)) { | 1356 | if (!(wq->flags & WQ_UNBOUND)) { |
1357 | struct global_cwq *gcwq = get_work_gcwq(work); | 1357 | struct global_cwq *gcwq = get_work_gcwq(work); |
1358 | 1358 | ||
1359 | if (gcwq && gcwq->cpu != WORK_CPU_UNBOUND) | 1359 | /* |
1360 | * If we cannot get the last gcwq from @work directly, | ||
1361 | * select the last CPU such that it avoids unnecessarily | ||
1362 | * triggering non-reentrancy check in __queue_work(). | ||
1363 | */ | ||
1364 | lcpu = cpu; | ||
1365 | if (gcwq) | ||
1360 | lcpu = gcwq->cpu; | 1366 | lcpu = gcwq->cpu; |
1361 | else | 1367 | if (lcpu == WORK_CPU_UNBOUND) |
1362 | lcpu = raw_smp_processor_id(); | 1368 | lcpu = raw_smp_processor_id(); |
1363 | } else { | 1369 | } else { |
1364 | lcpu = WORK_CPU_UNBOUND; | 1370 | lcpu = WORK_CPU_UNBOUND; |