lkml.org 
[lkml]   [2013]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 06/13] workqueue: get pool id from work->data directly if it is offq
Date
We know that when the time of the two calls of get_work_pool_id(),
the work is offq, so we can get pool id from work->data directly
and remove the overhead of idr_find() called by get_work_pool_id().

Implement offq_work_pool_id() instead of get_work_pool_id().

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
kernel/workqueue.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index b7cfaa1..9f04416 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -617,22 +617,22 @@ static struct worker_pool *get_work_pool(struct work_struct *work)
}

/**
- * get_work_pool_id - return the worker pool ID a given work is associated with
- * @work: the work item of interest
+ * offq_work_pool_id - return the worker pool ID a given work is associated with
+ * @work: the off-queued work item of interest
*
* Return the worker_pool ID @work was last associated with.
- * %WORK_OFFQ_POOL_NONE if none.
*/
-static int get_work_pool_id(struct work_struct *work)
+static int offq_work_pool_id(struct work_struct *work)
{
- struct worker_pool *pool = get_work_pool(work);
+ unsigned long data = atomic_long_read(&work->data);

- return pool ? pool->id : WORK_OFFQ_POOL_NONE;
+ BUG_ON(data & WORK_STRUCT_CWQ);
+ return data >> WORK_OFFQ_POOL_SHIFT;
}

static void mark_work_canceling(struct work_struct *work)
{
- unsigned long pool_id = get_work_pool_id(work);
+ unsigned long pool_id = offq_work_pool_id(work);

pool_id <<= WORK_OFFQ_POOL_SHIFT;
set_work_data(work, pool_id | WORK_OFFQ_CANCELING, WORK_STRUCT_PENDING);
@@ -2952,7 +2952,7 @@ bool cancel_delayed_work(struct delayed_work *dwork)
return false;

set_work_pool_and_clear_pending(&dwork->work,
- get_work_pool_id(&dwork->work));
+ offq_work_pool_id(&dwork->work));
local_irq_restore(flags);
return ret;
}
--
1.7.7.6


\
 
 \ /
  Last update: 2013-01-31 20:22    [W:0.280 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site