From nobody Mon Jun 8 06:36:41 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 AB4B247ECE6 for ; Fri, 5 Jun 2026 07:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780645400; cv=none; b=Zbps+kJX9VTu/hXdIcJBSy+qr384dnaUUs3PChJ9mkhiyZbv//PpuKJ7xVSJsoHeeN6/xjH8ManEOsezPvxSA4Qk+jCKPqo+x1GyrMZkjzOXP1NrbM5ZW4Wv3Gp8isT/cgQ83f0jsjB41LY3Xs2e4qUaIAXa9nZsLERHVS+MU/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780645400; c=relaxed/simple; bh=OtWAU7WQw1WEpoKr69TfRnr+9LhKKsIpC5cjoGKbIE8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nlOPGQo03VeG1ibz4wadLrNH0joH3KVYZ4Ax+byS3puwwT/QzhyBO9Sl1WvcfHuQFEHWADUECJCJ+RNqJNgEPa2EbVafoAmYujH1m21swg3cp/6+E2akdKE/kHtzChaT3KQWqi5xgGsJMki1wAKDKMafFwneoE0c1ZijkXQv+UI= 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=PPzdwYB7; arc=none smtp.client-ip=209.85.128.44 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="PPzdwYB7" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-490b7866869so18538685e9.2 for ; Fri, 05 Jun 2026 00:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780645397; x=1781250197; 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=drAuf+PDNsCDc4tcIraIcCRcvZv26pHzOrfgF5SXSe8=; b=PPzdwYB79Qna1/z6YMM5k/xCILUzU6SkAUDrmEAW2FXzbJTSqLq/lvgSsK54uN/3zj qNY/AC3FHTcf76BIi4pulnspMVrDZEnQn9GvvlVB4omffsI10ks3lzNH5QFb9YzIZsma YmEPT/Ir6wgmIQphT5/SKDGUs6urplKZfaicn6nBn/IhuK2vYgNGeSz6q5jAYYYHjW2b HlI8GGZSq8XYMHEb5sNAUuhrM5peKHJAa/7dwgUsWP5y56P3Kux+kfg0SzlPcDKmr/bP cGxgReFZn4N0TR7ejcp36y10yFHZ4BAbTxBXfbrDJgsRk9/duG6JMFs3bG2NZfdb/zZb 80mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780645397; x=1781250197; 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=drAuf+PDNsCDc4tcIraIcCRcvZv26pHzOrfgF5SXSe8=; b=e8lCmWiswxRRdNrS+6eGLAU97ZA7fEOMHNSxayDrZ3Z6iyOeS8qAZ3k4EfdMeZ1L0T h3rA1zn52hq9/AtwKxlRNmVUSxS+IoOQ+d0IfQ51ETbVEMQqcFropItL/xFXd6WVlOP8 t8IgRI0O3cJfnDB6OFAoUTlzBu5g4US/qGaNhlv5PxYgGLknvI8he+3HTySZcrVLqd+s uB3m33bA9YgK5LHCVLOKy1+UD4YfhRL/Mv9tYRhA3PboETQNCMBTL02kc2A7v4geU6Li O4gTGbJ8kHd33kCneghwIF4vkXo0xmALCLfgOMQz4M+8GGXYH2uggrXDoX2FSOrsouOZ QV+A== X-Gm-Message-State: AOJu0YxTyPBQG9SXdxVwZ6g9jYWttd8TtACjPCuyK8LBJlVmxxz+wMX5 tuZXl+rRu9qEn0TUJ5hH8EYWyObrn9cyEo/DwTXYhtdX5amy0w+tosPXT8NmIDIEsKDop56mOU3 3Zt1dlUg= X-Gm-Gg: Acq92OFp0jeNng6EjvO6X4FILgwT8bBVQSslcbvBzJ5Y/1HlWfi4Z9xBLd6A4N41mQH VMzywfU9on3lGAZ+kOhSZO0G3QCUUZx6KxdslJGgSDexBv0bq2YL7YHV3hM80xppAlGxNAIHgCM jY3vttvszl3cvWsWcX16ttOGK6sHb8PeE4WNOGoNI8Zir7cBAMAI7EGDkMcJKVR2fJ2/Nu10ucR kJN+SCik0rDJrhzfZQepd1xthMSoQh9shyKrLb8uuS3XX7/ALJxLZnAVs4puXhaAx8/ijVzK4D8 K6v42jhM27m0mUkCkB5YywEF+Lwj6ncj2dff0ILFhPruea8L3Y+7hm4eWe5wnIMA1LYb+11/QrJ 9+HrINphdjxPka4wnXbLmjiEK4uAJaga4B1Ae85djQ5HwzQV7GldOlOHwleI9tkESWz8Kh1Xyxg asNDsNz5ImYAoUjAEs0NvcELjwOL5PxFIIXgtBg5Qg/JQNKtK8QWI1jqyjSg== X-Received: by 2002:a05:600c:4fd1:b0:490:467e:a3d7 with SMTP id 5b1f17b1804b1-490c2643a92mr31152705e9.30.1780645397023; Fri, 05 Jun 2026 00:43:17 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f360bd6sm25326261f8f.36.2026.06.05.00.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 00:43:16 -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 v3] checkpatch: Check WQ_PERCPU or WQ_UNBOUND presence in alloc_workqueue() users Date: Fri, 5 Jun 2026 09:43:09 +0200 Message-ID: <20260605074309.49270-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 v3: - code aligned to open parens - ERROR changed with WARN Link to v2: https://lore.kernel.org/all/20260604154447.381477-1-marco.crive= llari@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.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..f1b03897b6e7 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); + 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 =3D=3D -1) { --=20 2.54.0