[PATCH V2 05/15] workqueue: only set pool id when the work is running

From: Lai Jiangshan
Date: Mon Feb 18 2013 - 11:16:46 EST


When a work is dequeued via try_to_grab_pending(), its pool id is recored
in work->data. but this recording is useless when the work is not running.

In this patch, we only record pool id when the work is running.

Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
---
kernel/workqueue.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 5502188..06d6211 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1139,6 +1139,8 @@ static int try_to_grab_pending(struct work_struct *work, bool is_dwork,
goto fail;

if (cwq) {
+ int pool_id;
+
debug_work_deactivate(work);

/*
@@ -1154,8 +1156,13 @@ static int try_to_grab_pending(struct work_struct *work, bool is_dwork,
list_del_init(&work->entry);
cwq_dec_nr_in_flight(get_work_cwq(work), get_work_color(work));

- /* work->data points to cwq iff queued, point to pool */
- set_work_pool_and_keep_pending(work, pool->id);
+ /* work is dequeued, work->data points to pool iff running */
+ if (worker)
+ pool_id = pool->id;
+ else
+ pool_id = WORK_OFFQ_POOL_NONE;
+
+ set_work_pool_and_keep_pending(work, pool_id);

spin_unlock(&pool->lock);
return 1;
--
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/