From: Marco Crivellari <marco.crivellari@suse.com>
To: linux-kernel@vger.kernel.org
Cc: Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>,
Frederic Weisbecker <frederic@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Marco Crivellari <marco.crivellari@suse.com>,
Michal Hocko <mhocko@suse.com>, Breno Leitao <leitao@debian.org>
Subject: [RFC PATCH 1/2] workqueue: Add warn and fallback if system_{unbound}_wq is used
Date: Thu, 14 May 2026 11:23:53 +0200 [thread overview]
Message-ID: <20260514092354.125149-2-marco.crivellari@suse.com> (raw)
In-Reply-To: <20260514092354.125149-1-marco.crivellari@suse.com>
Currently many users transitioned already to the new introduced workqueue
(system_percpu_wq, system_dfl_wq), but there are new users who still use the
older system_wq and system_unbound_wq.
This change try to push this transition forward, by warning whether the old
workqueus are used and redirecting them old used workqueue with the appropriate
new one.
Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
kernel/workqueue.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 3d2e3b2ec528..80d9c91ae606 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2425,6 +2425,24 @@ bool queue_work_on(int cpu, struct workqueue_struct *wq,
bool ret = false;
unsigned long irq_flags;
+ /*
+ * NOTE: These checks are here to assure that no users will still
+ * rely on system_wq and system_unbound wq.
+ * They can be removed along with those workqueue when the
+ * time comes.
+ */
+ if (unlikely(wq == system_wq)) {
+ pr_warn_once("workqueue: system_wq will be removed shortly. "
+ "Use system_percpu_wq instead. Caller: %ps\n",
+ __builtin_return_address(0));
+ wq = system_percpu_wq;
+ } else if (unlikely(wq == system_unbound_wq)) {
+ pr_warn_once("workqueue: system_unbound_wq will be removed shortly. "
+ "Use system_dfl_wq instead. Caller: %ps\n",
+ __builtin_return_address(0));
+ wq = system_dfl_wq;
+ }
+
local_irq_save(irq_flags);
if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work)) &&
@@ -2592,6 +2610,24 @@ bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
bool ret = false;
unsigned long irq_flags;
+ /*
+ * NOTE: These checks are here to assure that no users will still
+ * rely on system_wq and system_unbound wq.
+ * They can be removed along with those workqueue when the
+ * time comes.
+ */
+ if (unlikely(wq == system_wq)) {
+ pr_warn_once("workqueue: system_wq will be removed shortly. "
+ "Use system_percpu_wq instead. Caller: %ps\n",
+ __builtin_return_address(0));
+ wq = system_percpu_wq;
+ } else if (unlikely(wq == system_unbound_wq)) {
+ pr_warn_once("workqueue: system_unbound_wq will be removed shortly. "
+ "Use system_dfl_wq instead. Caller: %ps\n",
+ __builtin_return_address(0));
+ wq = system_dfl_wq;
+ }
+
/* read the comment in __queue_work() */
local_irq_save(irq_flags);
@@ -2630,6 +2666,24 @@ bool mod_delayed_work_on(int cpu, struct workqueue_struct *wq,
unsigned long irq_flags;
bool ret;
+ /*
+ * NOTE: These checks are here to assure that no users will still
+ * rely on system_wq and system_unbound wq.
+ * They can be removed along with those workqueue when the
+ * time comes.
+ */
+ if (unlikely(wq == system_wq)) {
+ pr_warn_once("workqueue: system_wq will be removed shortly. "
+ "Use system_percpu_wq instead. Caller: %ps\n",
+ __builtin_return_address(0));
+ wq = system_percpu_wq;
+ } else if (unlikely(wq == system_unbound_wq)) {
+ pr_warn_once("workqueue: system_unbound_wq will be removed shortly. "
+ "Use system_dfl_wq instead. Caller: %ps\n",
+ __builtin_return_address(0));
+ wq = system_dfl_wq;
+ }
+
ret = work_grab_pending(&dwork->work, WORK_CANCEL_DELAYED, &irq_flags);
if (!clear_pending_if_disabled(&dwork->work))
--
2.54.0
next prev parent reply other threads:[~2026-05-14 9:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 9:23 [RFC PATCH 0/2] workqueue: Add wornings and check WQ flags usage Marco Crivellari
2026-05-14 9:23 ` Marco Crivellari [this message]
2026-05-14 9:23 ` [RFC PATCH 2/2] workqueue: Add warnings and ensure one among WQ_PERCPU or WQ_UNBOUND is present Marco Crivellari
2026-05-15 9:09 ` Marco Crivellari
2026-05-15 12:17 ` [RFC PATCH 0/2] workqueue: Add wornings and check WQ flags usage Breno Leitao
2026-05-15 13:25 ` 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=20260514092354.125149-2-marco.crivellari@suse.com \
--to=marco.crivellari@suse.com \
--cc=bigeasy@linutronix.de \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.com \
--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®