From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=199.89.1.14 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796165648; b=gEvpypBdPTdzCnLTJWQ95QbS/iek+AZiXkODjQNao6xuYVSlcP/3tzW9yIa/FHGzdcBd muAQtlFIHOWyKW1vWJPozA740HDbYAX67mtfrkpYDd/7HzHNDW08P27VQcyIJC3T3rd7n Zcs/ZnzOGMWuVC80gTRhnvdFAryWvEaICK8THj6zmIIDwb+jqwwbGGKr2EeiUMsM3Nqgr JmPipcdMt+7WSbQKpzaTAJR9Ds+C5jq58akBo0DtuuJH66fw4lCOY9ncEdrrBsJv2TkCl FoimLxjskLd04JU69L6az/wr2t0ftogQ8LEEfqbFCG8SuwY93M0IET7cilpbkGZOHsw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796165648; h=DMARC-Filter:Received:DKIM-Signature:X-Virus-Scanned:Received: Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; bh=s6+cS7xqj1jinIE4mUXKDWPZq2IHKL5WCCXhphlJJ1k=; b=l6XxIh+NiT5LOkfD2zgIQri2/qq0llDAyrS8qecejuOho+e1DiHF/Cw44Ai/SkovmTxc N8bjbH6QGQbhWjlg34EKLT7jFHQ9F/Gq/plzf3RchGt2idhuKun4xwmJ4YtEbwuW8sgim nrq08CZDKL4atV+k28dt+b3mlvvF2GwgZ+UlzxaGMyVXG22ozMdd9tFqgivceyUkb2YQ3 xOC7XlYccGSyKxbLvH0vYpW0rhSnwV8xyqmlrRw//G+dldFiDWk23qtBxWVdK41dRQfqk C0z0rZgM2kvUttOipc+1WT0WtAMhlmagW/VrAIESeJAAzz82Cqpz/ld0X4xw+hBpEMg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=G2mhlFmo; arc=none smtp.remote-ip=199.89.1.14 Received: from 011.lax.mailroute.net (011.lax.mailroute.net [199.89.1.14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2701A606A332 for ; Tue, 1 Dec 2026 22:54:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2701A606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=G2mhlFmo Received: from localhost (localhost [127.0.0.1]) by 011.lax.mailroute.net (Postfix) with ESMTP id 4jfGR34nhqz1XMYJX; Tue, 1 Dec 2026 22:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1796165645; x=1798757646; bh=s6+cS 7xqj1jinIE4mUXKDWPZq2IHKL5WCCXhphlJJ1k=; b=G2mhlFmoPH1L0DvBvbsAK mtZeaiU8ObCszCiZT0cb/AXPNGyKnQBwYoWD3s1ujGAmklpbgmxrQ3bKeuQyPOWO nhcHvRBQtLB16HRxpO6yucRxZWe5KqeBXD86Qg0p5pi+KMU1EzsjuX8+EpcxGkZE 2uo4hf9IMbBk9H/sjxYhMO9f9db/FzceccP50S/qz7zU2yobViggvklUmi1Ja5qj So8fF+y8Tc8uF89goxv3VEdgYzs7FrRk842HgEqKuQU5GCwuAY7Y+gOp677sQRfb reIJuNTjvdtKhaZkpbjxNhtulf/sXjbewi09GPOQ4cgo49G6IBhnpmR3xxkkG0Ae A== X-Virus-Scanned: by MailRoute Received: from 011.lax.mailroute.net ([127.0.0.1]) by localhost (011.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id TeqTPDJrbJTP; Tue, 1 Dec 2026 22:54:05 +0000 (UTC) Received: from bvanassche.c.googlers.com.com (57.237.82.34.bc.googleusercontent.com [34.82.237.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 011.lax.mailroute.net (Postfix) with ESMTPSA id 4jfGQy74fWz1XMYJR; Tue, 1 Dec 2026 22:54:02 +0000 (UTC) From: Bart Van Assche To: Joe Perches , Andy Whitcroft Cc: Andrew Morton , linux-kernel@vger.kernel.org, Bart Van Assche Subject: [PATCH 02/10] checkpatch: cache SPDX license checks and gate on SPDX_LICENSE_TAG Date: Tue, 1 Dec 2026 14:53:46 -0800 Message-ID: X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Memoize is_SPDX_License_valid() results in %spdx_license_cache keyed by license string, and gate the call site in process() on show_type("SPDX_LICENSE_TAG"). Avoid launching a new Python interpreter for scripts/spdxcheck.py (~140 m= s per call) when checking repeated license expressions across multiple file= s or when SPDX_LICENSE_TAG warnings are ignored. Signed-off-by: Bart Van Assche --- scripts/checkpatch.pl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 543fd002ee29..3602e79fc091 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1323,15 +1323,19 @@ sub is_maintained_obsolete { return $maintained_status{$filename} =3D~ /obsolete/i; } =20 +my %spdx_license_cache =3D (); + sub is_SPDX_License_valid { my ($license) =3D @_; =20 return 1 if (!$tree || which("python3") eq "" || !(-x "$root/scripts/sp= dxcheck.py") || !(-e "$gitroot")); =20 - my $root_path =3D abs_path($root); - my $status =3D `cd "$root_path"; echo "$license" | scripts/spdxcheck.py= -`; - return 0 if ($status ne ""); - return 1; + if (!exists($spdx_license_cache{$license})) { + my $root_path =3D abs_path($root); + my $status =3D `cd "$root_path"; echo "$license" | scripts/spdxcheck.p= y -`; + $spdx_license_cache{$license} =3D ($status ne "") ? 0 : 1; + } + return $spdx_license_cache{$license}; } =20 my $camelcase_seeded =3D 0; @@ -3996,7 +4000,8 @@ sub process { "Missing or malformed SPDX-License-Identifier tag in line $che= cklicenseline\n" . $herecurr); } elsif ($rawline =3D~ /(SPDX-License-Identifier: .*)/) { my $spdx_license =3D $1; - if (!is_SPDX_License_valid($spdx_license)) { + if (show_type("SPDX_LICENSE_TAG") && + !is_SPDX_License_valid($spdx_license)) { WARN("SPDX_LICENSE_TAG", "'$spdx_license' is not supported in LICENSES/...\n" . $herec= urr); }