]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
workqueue: Add new WQ_PERCPU flag
authorMarco Crivellari <marco.crivellari@suse.com>
Sat, 14 Jun 2025 13:35:30 +0000 (15:35 +0200)
committerTejun Heo <tj@kernel.org>
Tue, 17 Jun 2025 18:52:09 +0000 (08:52 -1000)
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 <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Documentation/core-api/workqueue.rst
include/linux/workqueue.h

index e295835fc1164ecc543e4faea2cd7e501f7233d0..165ca73e83514e1c6c9f83ae536fcd4756855ffa 100644 (file)
@@ -183,6 +183,12 @@ resources, scheduled and executed.
   BH work items cannot sleep. All other features such as delayed queueing,
   flushing and canceling are supported.
 
+``WQ_PERCPU``
+  Work items queued to a per-cpu wq are bound to a specific CPU.
+  This flag is the right choice when cpu locality is important.
+
+  This flag is the complement of ``WQ_UNBOUND``.
+
 ``WQ_UNBOUND``
   Work items queued to an unbound wq are served by the special
   worker-pools which host workers which are not bound to any
index 74b0042709cd18cf8c2592f7c4ae197e8cf11317..f19072605faafecf3f6304f934bcada5ca8fa8a5 100644 (file)
@@ -401,6 +401,7 @@ enum wq_flags {
         * http://thread.gmane.org/gmane.linux.kernel/1480396
         */
        WQ_POWER_EFFICIENT      = 1 << 7,
+       WQ_PERCPU               = 1 << 8, /* bound to a specific cpu */
 
        __WQ_DESTROYING         = 1 << 15, /* internal: workqueue is destroying */
        __WQ_DRAINING           = 1 << 16, /* internal: workqueue is draining */