From: Marco Crivellari <marco.crivellari@suse.com>
To: linux-kernel@vger.kernel.org
Cc: Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Marco Crivellari <marco.crivellari@suse.com>,
Michal Hocko <mhocko@suse.com>
Subject: [PATCH v3 1/9] Workqueue: add system_percpu_wq and system_dfl_wq
Date: Wed, 11 Jun 2025 15:14:30 +0200 [thread overview]
Message-ID: <20250611131438.651493-2-marco.crivellari@suse.com> (raw)
In-Reply-To: <20250611131438.651493-1-marco.crivellari@suse.com>
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.
system_wq is a per-CPU worqueue, yet nothing in its name tells about that
CPU affinity constraint, which is very often not required by users. Make
it clear by adding a system_percpu_wq.
system_unbound_wq should be the default workqueue so as not to enforce
locality constraints for random work whenever it's not required.
Adding system_dfl_wq to encourage its use when unbound work should be used.
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
include/linux/workqueue.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index b0dc957c3e56..74b0042709cd 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -427,7 +427,7 @@ enum wq_consts {
/*
* System-wide workqueues which are always present.
*
- * system_wq is the one used by schedule[_delayed]_work[_on]().
+ * system_percpu_wq is the one used by schedule[_delayed]_work[_on]().
* Multi-CPU multi-threaded. There are users which expect relatively
* short queue flush time. Don't queue works which can run for too
* long.
@@ -438,7 +438,7 @@ enum wq_consts {
* system_long_wq is similar to system_wq but may host long running
* works. Queue flushing might take relatively long.
*
- * system_unbound_wq is unbound workqueue. Workers are not bound to
+ * system_dfl_wq is unbound workqueue. Workers are not bound to
* any specific CPU, not concurrency managed, and all queued works are
* executed immediately as long as max_active limit is not reached and
* resources are available.
@@ -455,10 +455,12 @@ enum wq_consts {
* system_bh[_highpri]_wq are convenience interface to softirq. BH work items
* are executed in the queueing CPU's BH context in the queueing order.
*/
-extern struct workqueue_struct *system_wq;
+extern struct workqueue_struct *system_wq; /* use system_percpu_wq, this will be removed */
+extern struct workqueue_struct *system_percpu_wq;
extern struct workqueue_struct *system_highpri_wq;
extern struct workqueue_struct *system_long_wq;
extern struct workqueue_struct *system_unbound_wq;
+extern struct workqueue_struct *system_dfl_wq;
extern struct workqueue_struct *system_freezable_wq;
extern struct workqueue_struct *system_power_efficient_wq;
extern struct workqueue_struct *system_freezable_power_efficient_wq;
--
2.49.0
next prev parent reply other threads:[~2025-06-11 13:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 13:14 [PATCH v3 0/9] Workqueue: rename system workqueue and add WQ_PERCPU Marco Crivellari
2025-06-11 13:14 ` Marco Crivellari [this message]
2025-06-11 20:57 ` [PATCH v3 1/9] Workqueue: add system_percpu_wq and system_dfl_wq Tejun Heo
2025-06-12 7:47 ` Marco Crivellari
2025-06-11 13:14 ` [PATCH v3 2/9] Workqueue: replace use of system_wq with system_percpu_wq Marco Crivellari
2025-06-11 21:01 ` Tejun Heo
2025-06-12 9:39 ` Marco Crivellari
2025-06-11 13:14 ` [PATCH v3 3/9] Workqueue: replace use of system_unbound_wq with system_dfl_wq Marco Crivellari
2025-06-11 13:14 ` [PATCH v3 4/9] Workqueue: add new WQ_PERCPU flag Marco Crivellari
2025-06-11 13:14 ` [PATCH v3 5/9] Workqueue: net: WQ_PERCPU added to alloc_workqueue users Marco Crivellari
2025-06-11 13:14 ` [PATCH v3 6/9] Workqueue: mm: " Marco Crivellari
2025-06-11 13:14 ` [PATCH v3 7/9] Workqueue: fs: " Marco Crivellari
2025-06-11 13:14 ` [PATCH v3 8/9] Workqueue: WQ_PERCPU added to all the remaining users Marco Crivellari
2025-06-11 13:14 ` [PATCH v3 9/9] [Doc] Workqueue: add WQ_PERCPU Marco Crivellari
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250611131438.651493-2-marco.crivellari@suse.com \
--to=marco.crivellari@suse.com \
--cc=bigeasy@linutronix.de \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®