From: Joe Perches <joe@perches.com>
To: Bart Van Assche <bvanassche@acm.org>, Andy Whitcroft <apw@canonical.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 02/10] checkpatch: cache SPDX license checks and gate on SPDX_LICENSE_TAG
Date: Wed, 02 Dec 2026 17:52:45 -0800 [thread overview]
Message-ID: <f287d3c36f2c31a34e226d54618f5372c8487afa.camel@perches.com> (raw)
In-Reply-To: <ee6d6089a67e532ff262e858a6ca507dbdbc1a24.1796165270.git.bvanassche@acm.org>
On Tue, 2026-12-01 at 14:53 -0800, Bart Van Assche wrote:
> Memoize is_SPDX_License_valid() results in %spdx_license_cache keyed by
memoize is a word? Maybe cache or remember.
> 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 ms
> per call) when checking repeated license expressions across multiple files
> or when SPDX_LICENSE_TAG warnings are ignored.
>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> 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.p;
> @@ -1323,15 +1323,19 @@ sub is_maintained_obsolete {
> return $maintained_status{$filename} =~ /obsolete/i;
> }
>
> +my %spdx_license_cache = ();
> +
> sub is_SPDX_License_valid {
> my ($license) = @_;
>
> return 1 if (!$tree || which("python3") eq "" || !(-x "$root/scripts/spdxcheck.py") || !(-e "$gitroot"));
>
> - my $root_path = abs_path($root);
> - my $status = `cd "$root_path"; echo "$license" | scripts/spdxcheck.py -`;
> - return 0 if ($status ne "");
> - return 1;
> + if (!exists($spdx_license_cache{$license})) {
> + my $root_path = abs_path($root);
> + my $status = `cd "$root_path"; echo "$license" | scripts/spdxcheck.py -`;
> + $spdx_license_cache{$license} = ($status ne "") ? 0 : 1;
> + }
> + return $spdx_license_cache{$license};
> }
This bit is useful
>
> my $camelcase_seeded = 0;
> @@ -3996,7 +4000,8 @@ sub process {
> "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
> } elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) {
> my $spdx_license = $1;
> - if (!is_SPDX_License_valid($spdx_license)) {
> + if (show_type("SPDX_LICENSE_TAG") &&
I'd rather not add a bunch of show_type calls to tests
> + !is_SPDX_License_valid($spdx_license)) {
> WARN("SPDX_LICENSE_TAG",
> "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr);
> }
next prev parent reply other threads:[~2026-12-03 1:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 22:53 [PATCH 00/10] Make checkpatch faster Bart Van Assche
2026-12-01 22:53 ` [PATCH 01/10] checkpatch: pre-filter obsolete MAINTAINERS checks and gate on OBSOLETE Bart Van Assche
2026-12-03 1:47 ` Joe Perches
2026-12-01 22:53 ` [PATCH 02/10] checkpatch: cache SPDX license checks and gate on SPDX_LICENSE_TAG Bart Van Assche
2026-12-03 1:52 ` Joe Perches [this message]
2026-12-01 22:53 ` [PATCH 03/10] checkpatch: cache git and PATH lookups and skip git_is_single_file() Bart Van Assche
2026-12-01 22:53 ` [PATCH 04/10] checkpatch: skip redundant build_types() rebuilds Bart Van Assche
2026-12-01 22:53 ` [PATCH 05/10] checkpatch: avoid dynamic regex recompilation in hot checks Bart Van Assche
2026-12-01 22:53 ` [PATCH 06/10] checkpatch: guard expensive per-line regexes with cheap pre-checks Bart Van Assche
2026-12-01 22:53 ` [PATCH 07/10] checkpatch: use hash lookups for single-word spelling checks Bart Van Assche
2026-12-01 22:53 ` [PATCH 08/10] checkpatch: scan ctx_statement_block() in place without slicing Bart Van Assche
2026-12-01 22:53 ` [PATCH 09/10] checkpatch: scan annotate_values() in place with leading-char dispatch Bart Van Assche
2026-12-01 22:53 ` [PATCH 10/10] checkpatch: add fast paths to per-line character-scanning helpers Bart Van Assche
2026-12-01 23:26 ` [PATCH 00/10] Make checkpatch faster Joe Perches
2026-12-01 23:53 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f287d3c36f2c31a34e226d54618f5372c8487afa.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=bvanassche@acm.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®