From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 D850433DEC2 for ; Wed, 3 Jun 2026 14:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780495800; cv=none; b=cfusxIgE53+V/mrwVCafCpW1s2c05wbgZiw3qJhMWVjff0kypXJl5q1LB+FNVxSXVeRCvJCQ79hFtFQPv30M4H/fqyDf79bRQgrkJmIDToMhKXudoJyOcCDxV0TWh/yAXQvNIKThptwN8G4RGb0ksI+UHXiwcilutdDwoX2nTXg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780495800; c=relaxed/simple; bh=kPLPVzB0hN7FH7OHKoV1k4j2DKT3Jg7rqvQBJpqC26A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=uIZng/ax6bylJ+lyXqKJMEAHTWzLgK+bX5jW2B6sSzWLver16VsMDejzLenuwq2B9Ba2uw3F6xDQOX8Hf/YTycxmJ2CYWeazc/U/Vh2F9nGriGEniVsiStZc/NzOiBV8LMTMRtb5l2FSzs3nyix/IeYk5gmc4Vhxcs+F0UVFfgY= 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=P/K3pAVi; arc=none smtp.client-ip=209.85.128.49 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="P/K3pAVi" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-490b1bbcf3aso18832665e9.1 for ; Wed, 03 Jun 2026 07:09:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780495797; x=1781100597; 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=XGsj3P8U/fsYLT2MSpgtiTgb2MGm5gCMZZJCQU2XISA=; b=P/K3pAVi2/HKM/VmPyzH72tvMsHtiObBYldvld16ZYqC2MpIqVrVaxpX5QX7Q3Lgm5 1s2r8JjV+l0abbFDvD74uOdkjmS8YZcA0DzTUq48IsmN6f4uYYWmdFtcq4x4W7wOaPU0 kHPmkd/ULfpYTOavlC5jEUZySqZs65G6UG0c/kXITFmvITQEexAxxHPSj3bpHrYLlfUW omBI9+O4843+R6jm/KRDUE8RrJDl7Ibc3/EcEYGhdrtUtwJnN8y0l2cBeDFz6AXv8xPN ixvbJ07neSuf9lKjOjLC5qQmJsVs7bf08K7REEoVS4RMcG///33GMKkv8oCw/vLcpWNL +S0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780495797; x=1781100597; 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=XGsj3P8U/fsYLT2MSpgtiTgb2MGm5gCMZZJCQU2XISA=; b=hh/VE3WBp/fXR9Jy0loqQzK4wcvKpJ54wXDojahCR8dN5nfBOc+wE8c32CSiq8mH06 yK8ITr3XAQlWI3z0t9ZxX/tcD6MZPz/gc9pvL1rH4XkIwRVBBjtbOJLYdupBKyoRp/U5 euCu6CiuJze/x42uGFMJu+0gyKTAp8Cw74mu7KEAaVCdOEsnPjA5dv4Rj26pUKG3b4Lb Ou4ueyIEWktuMRgz6tN7UEQFo2mgX6jFFw5e31F/pBhS5g9ife1IMX0k23+mN8k5KJaV 12XNAYI306GP/PM3+rfYK62PMl85Lr6j1vPQciZ04MBhkw4i84ACFbJ0UQDynp2eCmXf eJPg== X-Gm-Message-State: AOJu0YxbHiBaeH/m8W2ww5trBjup+EE4oXDCFF4/fVAA202qj/qPKit5 +jECu5SAcAQiEbV1VYp68jwkaCbipjhW2KyF3x3b+86B6n5nDMdu5SIu8VGEm+42H/6Xb7h1C4O EFEZ7Fss= X-Gm-Gg: Acq92OErQ23GpD7o7j7tz1tJZLlsdsi8kowNKUwxtcARe+sBxUWo6KH2eCOdln8WvMe CxOSyRjr/tTGS6COLOsQt2jAa+5JWRx8Mb2xgq3N0o9M2BZg7B9lzwGdWj+921rQCtcWWy+XQGH W0jDzOYdV4hfAzoCtm99yzA6VDS178Bsj8PvPQEohXsEomKNmS6vwbPJ3MYCa1dI2Qg4yqmAKng kw9/HFhUllQ6zXA9tXhDs2sy8S9TTJPlR4uFPfKD47CJ5RMrHcYvuzIBgH0/RMnqrRaygjf88/3 yHga1uFBaIohgQPRqle/0SgRpX2pn8dkI7ZMiR3cGeZAPphUZIGdkdZlpxyLJNMnGn1cXDRNHde MYmEXlAQ9vw5nBgQZLXqpiyYdM/KYFfCdZOgElBamHcHv5cFXZAoFrY+LuOMm0ymbR5FOpvBaUT dJ+41CuhqK/PemNndp0WhjHn+/koe1cZNbKdq3ErEkQL4OjaBjwQ== X-Received: by 2002:a05:600c:3596:b0:490:44eb:c1ea with SMTP id 5b1f17b1804b1-490b5edd71amr64000665e9.24.1780495797238; Wed, 03 Jun 2026 07:09:57 -0700 (PDT) Received: from linux.fritz.box ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b63e63d7sm66577615e9.12.2026.06.03.07.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 07:09:56 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org Cc: Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn , Tejun Heo , Frederic Weisbecker , Marco Crivellari , Michal Hocko , Breno Leitao Subject: [PATCH] checkpatch: Check WQ_PERCPU or WQ_UNBOUND presence in alloc_workqueue() users Date: Wed, 3 Jun 2026 16:09:41 +0200 Message-ID: <20260603140941.320063-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: 8bit 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 --- 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