[PATCH 04/13] workqueue: clear cwq when cancel the work

From: Lai Jiangshan
Date: Thu Jan 31 2013 - 13:45:33 EST


Add clear_work_cwq() which clear the CWQ bit when the work is offq when it is
cancelled.

It is the other important step of killing CWQ bit of the work which is
not queued on any pool.

Now, when a work is offq, it has no CWQ bit.

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

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index b12b30e..50d3dd5 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -556,6 +556,12 @@ static void set_work_cwq(struct work_struct *work,
WORK_STRUCT_PENDING | WORK_STRUCT_CWQ | extra_flags);
}

+static void clear_work_cwq(struct work_struct *work, int pool_id)
+{
+ set_work_data(work, pool_id << WORK_OFFQ_POOL_SHIFT,
+ WORK_STRUCT_PENDING);
+}
+
static void set_work_pool_and_clear_pending(struct work_struct *work,
int pool_id)
{
@@ -1115,6 +1121,7 @@ static int try_to_grab_pending(struct work_struct *work, bool is_dwork,
cwq_dec_nr_in_flight(get_work_cwq(work),
get_work_color(work));

+ clear_work_cwq(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/