Skip to content

Commit 930c2ea

Browse files
DispatchCodehtejun
authored andcommitted
workqueue: Add new WQ_PERCPU flag
Currently if a user enqueue a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND. This lack of consistentcy cannot be addressed without refactoring the API. This patch adds a new WQ_PERCPU flag to explicitly request the use of the per-CPU behavior. Both flags coexist for one release cycle to allow callers to transition their calls. Once migration is complete, WQ_UNBOUND can be removed and unbound will become the implicit default. tj: Merged doc patch. Suggested-by: Tejun Heo <[email protected]> Signed-off-by: Marco Crivellari <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 128ea9f commit 930c2ea

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Documentation/core-api/workqueue.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ resources, scheduled and executed.
183183
BH work items cannot sleep. All other features such as delayed queueing,
184184
flushing and canceling are supported.
185185

186+
``WQ_PERCPU``
187+
Work items queued to a per-cpu wq are bound to a specific CPU.
188+
This flag is the right choice when cpu locality is important.
189+
190+
This flag is the complement of ``WQ_UNBOUND``.
191+
186192
``WQ_UNBOUND``
187193
Work items queued to an unbound wq are served by the special
188194
worker-pools which host workers which are not bound to any

include/linux/workqueue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ enum wq_flags {
401401
* http://thread.gmane.org/gmane.linux.kernel/1480396
402402
*/
403403
WQ_POWER_EFFICIENT = 1 << 7,
404+
WQ_PERCPU = 1 << 8, /* bound to a specific cpu */
404405

405406
__WQ_DESTROYING = 1 << 15, /* internal: workqueue is destroying */
406407
__WQ_DRAINING = 1 << 16, /* internal: workqueue is draining */

0 commit comments

Comments
 (0)