From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14D4949551C for ; Thu, 4 Jun 2026 17:11:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780593121; cv=none; b=WiJQDdQ6HfOTPg93ZroZx8lhHfPhJVXBt/BGG2rnJT5otcQgja9CEPg7sAxrkOoh+cDTgtKA+9JQ3Adch/fgT4m6Yvypq8i5QqlsKk/OAAa5HUAzVQwuD0AD7WQ2uR8thEEAlgQtbWobPieYf3IvCLKk6ydNUrsWpYeXsZ5Mwc8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780593121; c=relaxed/simple; bh=ZFasoel89xykrRJpHKr6OpF4ztvWJ5NnJFQvILk3iYs=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=Nz0GG321rswX5akQXqr5t5pXh+cy+JE1G6Y7HpiPx/SL/9Pd3RS1VwWX99/8eo253DwFiiDsGt0FnS51ihADx+S+jwbwQpDZlO8vd3PPRp95l4MOHSpKGF5xlPkJg6qiCCkPDFX8alPqtR4Pf4Rk01CoeLpDK9OchBKqI4MYzVg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com; spf=pass smtp.mailfrom=perches.com; arc=none smtp.client-ip=216.40.44.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=perches.com Received: from omf06.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3C1621C0D0D; Thu, 4 Jun 2026 17:11:52 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf06.hostedemail.com (Postfix) with ESMTPA id 7FF4120010; Thu, 4 Jun 2026 17:11:49 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2] checkpatch: Check WQ_PERCPU or WQ_UNBOUND presence in alloc_workqueue() users From: Joe Perches To: Marco Crivellari , linux-kernel@vger.kernel.org Cc: Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn , Tejun Heo , Frederic Weisbecker , Sebastian Andrzej Siewior , Michal Hocko , Breno Leitao Date: Thu, 04 Jun 2026 10:11:48 -0700 In-Reply-To: <20260604154447.381477-1-marco.crivellari@suse.com> References: <20260604154447.381477-1-marco.crivellari@suse.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 7FF4120010 X-Stat-Signature: z94h435agpmowh6c7h8o7btd4jdjqgg9 X-Rspamd-Server: rspamout07 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+eyKep3KcKDrRb7Bc/tE+FJtRTQwnC9vw= X-HE-Tag: 1780593109-917502 X-HE-Meta: U2FsdGVkX1/a7iseG9aa3EMCJMA3/ZRJ+HyqgGG1uWih3Ur4g+uPtyJ0HIMSxydy/zS+7ccDlyEffCAkjy6arJP79S5j35nEL+/3/WQavwb0gMAb8SbJJFDU4v4YTDv064EtZF0X0DyxM18YgQuZw9fCKBq2Lg0GEqCeOJ1lW8lfL6wAfNElL+uZMPf3jSXnwGSCxZgJFUsiGBHcvRLA92H+Yg62efLyjOe1Xq/+5k5BaDdJHD/hHiVvsln+V0+aikhZ+UHMW40SQUSWDwduC+5SqM00rAEpBQDaTpumtnnlxlbBDqH4mYhFlm/bj6zA On Thu, 2026-06-04 at 17:44 +0200, Marco Crivellari wrote: > The workqueue API introduced a new flag, WQ_PERCPU, that has to be used w= hen > WQ_UNBOUND is not present. One of these flags must be present, but not > both of them. >=20 > To limit usage mistakes, emit an ERROR if one of the below condition is m= et: > - alloc_workqueue() is called without WQ_PERCPU nor WQ_UNBOUND > - alloc_workqueue() is called with both WQ_PERCPU and WQ_UNBOUND [] > diff --git 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); > } > - } > =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)/) { Align to open paren please > + > + 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_UNB= OUND\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); Align to open paren please And as there are false positives, this should probably be a WARN