From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 E852136894D for ; Mon, 8 Jun 2026 12:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780922235; cv=none; b=kKrdQzUSgzqolrwJnexX5cGLLRgvlVCnDVZfSsXnfeF+ezQkxsMxctyPFSvny5PTW0BUZSKNT7P57l2reaPbC3hY7BDXRy80bm449zQzjuwRjERmTyiVcgyElqfqmfPgwJXjraABOQpKIwdlZFtASgz2Aou+xicfbRtMFfj0oPE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780922235; c=relaxed/simple; bh=tcA8ZG0ocuhHspzQ4g/ONEDRGHLVnzLeySQnKpPx/eY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eXWkqcbhIZRF1KXPUGNSUtz3mVZ7LT+j5E8SpECwUFbQUWFOSny+ep3JtncAU/KL0uTHt2D5UA/+19/J69qb6bsq6OZvg5l3FQhifdxEqQtbjzUj6TXq28wcodJaqMp3jwoQI+i/Rq7VimKthZ/dLkwRYlqCPgLhCXvVSaN89Yo= 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=Pgluy9ps; arc=none smtp.client-ip=209.85.221.53 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="Pgluy9ps" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-45ef56d9b67so3282750f8f.2 for ; Mon, 08 Jun 2026 05:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780922232; x=1781527032; 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=5GTsQ+iSrxjTKEEbc+axMKSFbsfHuihy0QnEvExMctI=; b=Pgluy9psJAqIAZT95EoYCFXJLF5zecM7KSAuaxcdOswwxyl3wMumahgWEGWKM0rCyB EhZwPCFPrK0MNZ4wvcCOfAI/LDrqbgrWu4inIJ3y6S+rCcDdsDC1aNDuojSesDO2nUlj WaALXTFXM+PJyNfCvzq17JVhJJb+qU/Un7xr4dKj7tESafzrVY3cneyyMKX/+MKYaP+b dvUNMY8k0TKDjPKXKx4e28uoIVj8cFLIGNf1mBM830xazzyYTNnS2EsmEvkRiBNuijZi x3tQETk8ztSchoSSb+06qFMJNjYM98nYL6g5v5UbBCKFfLN2QSGfTa0wm0z0/bT4uCQZ sfdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780922232; x=1781527032; 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=5GTsQ+iSrxjTKEEbc+axMKSFbsfHuihy0QnEvExMctI=; b=USYLYa4hsRgKCeGEvEC5jX0gJDwZtsoA7OX+HadTGDO2Gihm1ei732+MdTXCuN/GVZ rWFScrAdqHIEKKKG7eSmN7fYv8uhwC3Awh70uAPToSY5LsBQLjPXBEOixHY4Grr8OtpS bS4klQM4C9AlpGBs9+NzPDUidHL7pF3UqwVz9SdYu5stHstZAI1xPCHAiM0hWqJ/PDAV XKR5qYIRiswh/82ppdXP0q8Lz4gzs/a9YY8ZtnStG+rqoUe6ExASQw3NpBqpVPkHXBse M+wWd3ZD3I1fA91gsLsFdikAV9AJ3hoAO2XN3BxUJiqn9QLb4pRC3GsTClYm5IdL3UyF Cqeg== X-Gm-Message-State: AOJu0YyarUy/Yk0/NHBrQl3oIqHlXnvVibco3AiU4h9yvXQCftYknFuU Yn0Lw1i0yIuSictSAjXn2wT8jLH8xjqYwhv9U1kPKEWt8dU/WPBkAx+f2pc9vihRuCUC0TDl/Os W0Ftp72Q= X-Gm-Gg: Acq92OEnOkubciDZ1/J5WpsXqRKlQPJf4QWv9Y9J4A9QE/5D8vMZIfrOriW9zoS9bl2 clI46h4h2Oun15I7YNaibaJxgeYnYEwQca75gms5Dgs9BaQ528FLIx2TwWkibJpMGdeDvA+adC8 h0Nn893jy1B1U0j270Wrtztnfq6voQhQgzNpYla/h6GDj3maSmC+wE8rJ1R8B3nk1lC5qhK/xre p5E9v6CYbpz+8smHE3AJtb1ZzqJQUgBjX4HTsPoW3fEWw2tr2au8XJk4JHFQgmM9c3/hawfavhH K6gutDgwMp+Fh9zWBtTYmIM4mabhJZwsUocOFQf17i4AkOecq/CkU6xelbo4v0aXfAz7R6QOroj X2Z4aZmPc+noRkpwpsnvkLHoP2afFUufIyMqU3xJZjUW3btRiYlX4SilTFD76Chq2oK1mb2cxiy M9EMGdc6CSKPhw5gndLgioo3+bG07cNMW6Gg2eJSFYEHLkRaoAxHN0Ktskbob7EZggksjR X-Received: by 2002:a05:6000:2b0b:b0:45e:ea2a:dd79 with SMTP id ffacd0b85a97d-460302e0a31mr16033918f8f.4.1780922232220; Mon, 08 Jun 2026 05:37:12 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2e4004sm52252233f8f.9.2026.06.08.05.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 05:37:11 -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 v5] checkpatch: Check WQ_PERCPU or WQ_UNBOUND presence in alloc_workqueue() users Date: Mon, 8 Jun 2026 14:37:00 +0200 Message-ID: <20260608123700.195206-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 a WARNING 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 v5: - Fixed "emit an ERROR" with "emit a WARNING" in the commit log Link to v4: https://lore.kernel.org/all/20260608083711.76885-1-marco.crivellari@suse.com/ Changes in v4: - properly align code Link to v3: https://lore.kernel.org/all/20260605074309.49270-1-marco.crivellari@suse.com/ Changes in v3: - code aligned to open parens - ERROR changed with WARN Link to v2: https://lore.kernel.org/all/20260604154447.381477-1-marco.crivellari@suse.com/ 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.crivellari@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..52da2dc4f467 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" . $herecurr); } - } +# check alloc_workqueue() parameters for WQ_PERCPU and WQ_UNBOUND uses + if (defined($stat) && + $stat =~ /^[ \+]\s*(?:$Lval\s*=\s*)?((?:devm_)?alloc_workqueue)\s*($balanced_parens)/) { + + my $func = $1; + my $args = $2; + my $has_percpu = $args =~ /\bWQ_PERCPU\b/; + my $has_unbound = $args =~ /\bWQ_UNBOUND\b/; + my $error_msg; + + if ($has_percpu && $has_unbound) { + $error_msg = "$func() should not contain both WQ_PERCPU and WQ_UNBOUND\n"; + } elsif (!$has_percpu && !$has_unbound) { + $error_msg = "$func() must specify either WQ_PERCPU or WQ_UNBOUND\n"; + } + + if (defined($error_msg)) { + my $stmt_cnt = statement_rawlines($stat); + my $herectx = get_stat_here($linenr, $stmt_cnt, $here); + WARN("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 == -1) { -- 2.54.0