[PATCH 00/10] Make checkpatch faster
From: Bart Van Assche
Date: Tue Dec 01 2026 - 17:54:12 EST
Hi ,
LLMs tend to run checkpatch often. This patch series makes checkpatch about
twice as fast and prevents that it slows down LLM-based workflows
significantly. All then patches have been generated by an LLM.
Patches 1-3 avoid or cache the subprocesses. Patches 4-10 reduce
regex recompilation, add cheap pre-checks in front of expensive
regexes, use a hash for single-word spelling checks, and scan strings
in place instead of slicing them.
Timings with this series (Perl 5.40, one CPU, --strict):
50 recent commits, tree mode: 11.1 s -> 2.4 s
checkpatch -f kernel/sched/core.c: 8.1 s -> 4.1 s
checkpatch -f fs/btrfs/inode.c: 8.7 s -> 4.2 s
checkpatch -f ufs/core/ufshcd.c: 8.7 s -> 4.3 s
The goal is identical output. To check this, I ran the old and new
checkpatch.pl on the same inputs and compared stdout, stderr, the exit
code and the --fix results.
No differences were found apart from line numbers in existing Perl
warnings. Two intentional differences are described in patch 3: with
-f, a git-tracked file name containing a regex metacharacter no longer
makes checkpatch die, and some Perl warnings are printed once instead
of once per call.
Please consider this patch series for the next merge window.
Thanks,
Bart.
Bart Van Assche (10):
checkpatch: pre-filter obsolete MAINTAINERS checks and gate on
OBSOLETE
checkpatch: cache SPDX license checks and gate on SPDX_LICENSE_TAG
checkpatch: cache git and PATH lookups and skip git_is_single_file()
checkpatch: skip redundant build_types() rebuilds
checkpatch: avoid dynamic regex recompilation in hot checks
checkpatch: guard expensive per-line regexes with cheap pre-checks
checkpatch: use hash lookups for single-word spelling checks
checkpatch: scan ctx_statement_block() in place without slicing
checkpatch: scan annotate_values() in place with leading-char dispatch
checkpatch: add fast paths to per-line character-scanning helpers
scripts/checkpatch.pl | 728 +++++++++++++++++++++++++++++++-----------
1 file changed, 539 insertions(+), 189 deletions(-)