mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 0/2] workqueue: Add wornings and check WQ flags usage
Date: Thu, 14 May 2026 11:23:52 +0200	[thread overview]
Message-ID: <20260514092354.125149-1-marco.crivellari@suse.com> (raw)

Hi,

Currently system_wq and system_unbound_wq can still be used and no message
is printed. To avoid further use of them, add a warning and route the
workqueue on system_percpu_wq or system_dfl_wq.

Similar scenario for WQ_PERCPU and WQ_UNBOUND. Currently there are still
users that use alloc_workqueue(,0,). To avoid such situations, a couple
of checks have been added:

  - if neither of the flag is present, set WQ_PERCPU
  - if both are present, remove WQ_PERCPU

Along with these, a warning will be printed.

~~~~

Few things to note, and that's the main reason because it is an RFC:

1. I wanted to use a compile time error, but considering the new users still
   relying on the old workqueue or using alloc_workqueue() without one of the
   flags, it means break the code. So I decided to avoid.

2. there are no compile-time warnings: should we add something?

3. __alloc_workqueue() prints the WQ_* messages with pr_warn_ratelimited();
   I used this because otherwise with the _once version we're going to see
   only the 1st.

4. another option would have been make the workqueue unbound by default, but
   of course, it's still not possible due to point 1.


Thanks!

Marco Crivellari (2):
  workqueue: Add warn and fallback if system_{unbound}_wq is used
  workqueue: Add warnings and ensure one among WQ_PERCPU or WQ_UNBOUND
    is present

 kernel/workqueue.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

-- 
2.54.0


             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 Marco Crivellari [this message]
2026-05-14  9:23 ` [RFC PATCH 1/2] workqueue: Add warn and fallback if system_{unbound}_wq is used Marco Crivellari
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-1-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®