diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2013-02-07 16:14:20 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-02-07 16:14:20 -0500 |
commit | 54d5b7d079dffa74597715a892473b474babd5b5 (patch) | |
tree | 33aa61fc2a98acff099a2393665318328448e137 /kernel/workqueue.c | |
parent | e19e397a85f33100bfa4210e256bec82fe22e167 (diff) |
workqueue: make get_work_pool_id() cheaper
get_work_pool_id() currently first obtains pool using get_work_pool()
and then return pool->id. For an off-queue work item, this involves
obtaining pool ID from worker->data, performing idr_find() to find the
matching pool and then returning its pool->id which of course is the
same as the one which went into idr_find().
Just open code WORK_STRUCT_CWQ case and directly return pool ID from
work->data.
tj: The original patch dropped on-queue work item handling and renamed
the function to offq_work_pool_id(). There isn't much benefit in
doing so. Handling it only requires a single if() and we need at
least BUG_ON(), which is also a branch, even if we drop on-queue
handling. Open code WORK_STRUCT_CWQ case and keep the function in
line with get_work_pool(). Rewrote the description.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 91ce7a984c22..1801c37b28c4 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -611,9 +611,13 @@ static struct worker_pool *get_work_pool(struct work_struct *work) | |||
611 | */ | 611 | */ |
612 | static int get_work_pool_id(struct work_struct *work) | 612 | static int get_work_pool_id(struct work_struct *work) |
613 | { | 613 | { |
614 | struct worker_pool *pool = get_work_pool(work); | 614 | unsigned long data = atomic_long_read(&work->data); |
615 | |||
616 | if (data & WORK_STRUCT_CWQ) | ||
617 | return ((struct cpu_workqueue_struct *) | ||
618 | (data & WORK_STRUCT_WQ_DATA_MASK))->pool->id; | ||
615 | 619 | ||
616 | return pool ? pool->id : WORK_OFFQ_POOL_NONE; | 620 | return data >> WORK_OFFQ_POOL_SHIFT; |
617 | } | 621 | } |
618 | 622 | ||
619 | static void mark_work_canceling(struct work_struct *work) | 623 | static void mark_work_canceling(struct work_struct *work) |