From: Marco Crivellari <marco.crivellari@suse.com>
To: linux-kernel@vger.kernel.org
Cc: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>,
Tejun Heo <tj@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
Marco Crivellari <marco.crivellari@suse.com>,
Michal Hocko <mhocko@suse.com>, Breno Leitao <leitao@debian.org>
Subject: [PATCH] checkpatch: Check WQ_PERCPU or WQ_UNBOUND presence in alloc_workqueue() users
Date: Wed, 3 Jun 2026 16:09:41 +0200 [thread overview]
Message-ID: <20260603140941.320063-1-marco.crivellari@suse.com> (raw)
The workqueue API introduced a new flag, WQ_PERCPU, that has to be used when
WQ_UNBOUND is not present. One of these flags must be present, but not
both of them.
To limit usage mistakes, emit an ERROR if one of the below condition is met:
- alloc_workqueue() is called without WQ_PERCPU nor WQ_UNBOUND
- alloc_workqueue() is called with both WQ_PERCPU and WQ_UNBOUND
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
scripts/checkpatch.pl | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 0492d6afc9a1..2706aba6dac0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -7804,6 +7804,22 @@ sub process {
ERROR("UNINITIALIZED_PTR_WITH_FREE",
"pointer '$1' with __free attribute should be initialized\n" . $herecurr);
}
+
+# check alloc_workqueue() flags parameter (2nd argument) for WQ_PERCPU, WQ_UNBOUND presence
+ if ($line =~ /\balloc_workqueue\s*\(/ &&
+ $stat =~ /\balloc_workqueue\s*\(\s*[^,]+\s*,\s*([^,]+)/s) {
+ my $flags = $1;
+ my $has_percpu = $flags =~ /\bWQ_PERCPU\b/;
+ my $has_unbound = $flags =~ /\bWQ_UNBOUND\b/;
+
+ if ($has_percpu && $has_unbound) {
+ ERROR("ALLOC_WORKQUEUE_FLAGS",
+ "alloc_workqueue() second parameter should not contain both WQ_PERCPU and WQ_UNBOUND\n" . $herecurr);
+ } elsif (!$has_percpu && !$has_unbound) {
+ ERROR("ALLOC_WORKQUEUE_FLAGS",
+ "alloc_workqueue() second parameter should specify either WQ_PERCPU or WQ_UNBOUND\n" . $herecurr);
+ }
+ }
}
# If we have no input at all, then there is nothing to report on
--
2.54.0
next reply other threads:[~2026-06-03 14:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 14:09 Marco Crivellari [this message]
2026-06-04 5:08 ` Joe Perches
2026-06-04 9:31 ` Marco Crivellari
2026-06-04 14:09 ` Joe Perches
2026-06-04 14:18 ` 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=20260603140941.320063-1-marco.crivellari@suse.com \
--to=marco.crivellari@suse.com \
--cc=apw@canonical.com \
--cc=dwaipayanray1@gmail.com \
--cc=frederic@kernel.org \
--cc=joe@perches.com \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--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®