From nobody Mon Jun 8 08:53:11 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D94731ED93 for ; Thu, 4 Jun 2026 15:45:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780587902; cv=none; b=QrAJtH1oz4tXBViqusEyvq/zRDF8Vmfs2XkL4W8a43BYq7yicgeuKAkLXxRpvzrnHp1ChRcf2URmsvVCraj1l9oWFvzwhltqhiMqD5dLfcZj/GnE2qhaWG+/Zf18yVpPMbiQAl405FCWkd9ktgfjp+ZkaDIvjItsZspCZCwUjbk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780587902; c=relaxed/simple; bh=v7DxvWeBKQo4a91vvH2Wx78xWeBQ5JOw97ScvwdYg4c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=IFjNJ/meae41CTgL+1C6SfybqJUGW9GnylL6q3Oun+znIMV+xftyH9dhHFrculc5A0gRvujTHLcaUCysI5plpfNzemKl60ts65sAZucc8+vaBxL/oSJnYOx48QWKRqFF1+2/RZFXlPuI1AuluVL3EZrKq6WsUExpdccpZ9MJW4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Kw9It1zq; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Kw9It1zq" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4908b92904fso10914065e9.0 for ; Thu, 04 Jun 2026 08:45:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780587899; x=1781192699; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tz6oOuIT1gbsQI8TWcnqfK2m8w1MfKdQJi/XBjEgO+U=; b=Kw9It1zq/qo2bGh7sdkKsZuE2C5pcW3zMJlChf20R5P5JZwU8K5SNDuTj6g50GxP9R B27ZI2cuu2qN1T+dV107t8/eJN8ZWxK7+xRBHlXe7lOWncyarx8vpx1AcKJA61PxvGmn yEY0FdDM2qx52aQWNRy2f4wV96tWGPGumBOq37MDsQDUMUEb2dGNXpvAMMUpUcsCTdlp 8Y4dh5cRkTibZJXM0Uwtf1sB+C5UzL9pGEDZM1plnQGKi9SDBTw/mDENaou2H+DD0Lo7 v3XAJBQy4bc79UWHT46uRMlmtPqT/GP/cvJJsDEMIJZWVhxxvRaBaLCBkgLlNOvYCgLP WzGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780587899; x=1781192699; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tz6oOuIT1gbsQI8TWcnqfK2m8w1MfKdQJi/XBjEgO+U=; b=Edmxg5a973ay3vGkocQ4nq+49k8BmRJFDGpCuNFMpcaCeoVUGyUAI82ZjaIPSMBWlI N+YposAya17sjjyBPihf4CB/t/c7nWS90k/P8IaaqzXQNG/meykXhJa9jlQiOnhKCwmr 1j2p0nWIDmsLVThYs74vOfg4+io7lccWTonMrjVbBumMxYYmTjPkgnMo7qirPYW+Z/oX clrMzw07f4X2OL8KTbWq5+IuMACw+crZtsNKqkZYfZfOZSiYZojtlbkBP7tmD3V4tW22 OL/ZJRwwh/HoU8H4IOIhz4PiUYQgcZ75qvbF4WpSq0HDrUOeYu1mkcOoeUBBCNaPk+6T 7XHQ== X-Gm-Message-State: AOJu0YzsOeQ0+6mXYX1hCbl6f6SvPKx256yzVq/tKAnZoiKNC/PKUwX3 E4l9zfKh5vmktPbEfxf6plVvd0EDPeYRsklpCGuqfPM2v+1Vnjzm+YNQ/oSpgtpBQ4+VPWHOZim 3MjiTAuw= X-Gm-Gg: Acq92OEJhbwpiGewKv+qeF7hE4ZKNqPoVcG+2ViETH/MV2hcYgOmKiVNvHqnvGAFCnA zBkGEOCP141s3QETK2G2LCQmSVTvJ1TTUPfOABgx78ycG6WyOvr5A6WJJbW78UMb9PY/sTgaKT7 t+uNky/Uo35fsRs4uL+xszvOLj8O5rl5J5PWh81RfYWf2mV/PL5Wu5bFfJUero3bhHKwLqCHg7q bnS5GEOmnthpbmyeKLWVpgyDExUdCsZ40auC0plGUWgjqOHG26Au6W+iWEoE1YcSsvLJCkWhxdS BkWf3s6mjLjj+mMZSRKVcALKpXAZWc6X3q8EJffw19t65FmE6Kd4fm5RN5YRHW3FafaoXQC7X/A nWV7cicExUmOkQN0iCsd5E3fFg6zIHg5h2AVxj8njhtRef7WMl7vUboe6Kppp5qjUYxEKA8g9rN hgkotbcGurFcuKPX08+CIeTVfjlmwAsDmNvcTxViJMbzO5NFbWI4Bb6JTJSFUuMcfvMPc= X-Received: by 2002:a05:600c:8184:b0:490:688b:f10d with SMTP id 5b1f17b1804b1-490b5eb64c9mr124543535e9.7.1780587899094; Thu, 04 Jun 2026 08:44:59 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc23394asm79343565e9.0.2026.06.04.08.44.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:44:58 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org Cc: Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn , Tejun Heo , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Breno Leitao Subject: [PATCH v2] checkpatch: Check WQ_PERCPU or WQ_UNBOUND presence in alloc_workqueue() users Date: Thu, 4 Jun 2026 17:44:47 +0200 Message-ID: <20260604154447.381477-1-marco.crivellari@suse.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- Changes in v2: - removed $line from the test (Joe Perches) - devm_alloc_workqueue() regex take into account also (Joe Perches) - defined() on variables and other improvements (Joe Perches) Link to v1: https://lore.kernel.org/all/20260603140941.320063-1-marco.crive= llari@suse.com/ scripts/checkpatch.pl | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0492d6afc9a1..2464d83619f7 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -7804,8 +7804,31 @@ sub process { ERROR("UNINITIALIZED_PTR_WITH_FREE", "pointer '$1' with __free attribute should be initialized\n" . $h= erecurr); } - } =20 +# check alloc_workqueue() parameters for WQ_PERCPU and WQ_UNBOUND uses + if (defined($stat) && + $stat =3D~ /^[ \+]\s*(?:$Lval\s*=3D\s*)?((?:devm_)?alloc_workqueue)\s*= ($balanced_parens)/) { + + my $func =3D $1; + my $args =3D $2; + my $has_percpu =3D $args =3D~ /\bWQ_PERCPU\b/; + my $has_unbound =3D $args =3D~ /\bWQ_UNBOUND\b/; + my $error_msg; + + if ($has_percpu && $has_unbound) { + $error_msg =3D "$func() should not contain both WQ_PERCPU and WQ_UNBOU= ND\n"; + } elsif (!$has_percpu && !$has_unbound) { + $error_msg =3D "$func() must specify either WQ_PERCPU or WQ_UNBOUND\n"; + } + + if (defined($error_msg)) { + my $stmt_cnt =3D statement_rawlines($stat); + my $herectx =3D get_stat_here($linenr, $stmt_cnt, $here); + ERROR("ALLOC_WORKQUEUE_FLAGS", + $error_msg . $herectx); + } + } + } # If we have no input at all, then there is nothing to report on # so just keep quiet. if ($#rawlines =3D=3D -1) { --=20 2.54.0