]> git.baikalelectronics.ru Git - kernel.git/commit
workqueue: make get_work_pool_id() cheaper
authorLai Jiangshan <laijs@cn.fujitsu.com>
Thu, 7 Feb 2013 21:14:20 +0000 (13:14 -0800)
committerTejun Heo <tj@kernel.org>
Thu, 7 Feb 2013 21:14:20 +0000 (13:14 -0800)
commit3fc02f2a33aa8c8096d3df61de7aa5838aae8adc
tree33aa61fc2a98acff099a2393665318328448e137
parent679e503f3a7cf8e98b8e7daeb9b5e9b6cafe9ce9
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>
kernel/workqueue.c