[PATCH 1/4] checkpatch: is_userspace: exclude kernel code under tools/
From: Kir Kolyshkin
Date: Thu Oct 22 2026 - 18:45:06 EST
is_userspace() treats everything under tools/ as userspace code, and is
used to skip checks that only make sense for the kernel. However, tools/
also contains some kernel code: test modules, Kbuild-built mocks, and
templates and golden outputs of the runtime verification monitor
generator. Such code should be subject to the same checks as the rest
of the kernel.
Explicitly exclude the known locations of kernel code under tools/.
Signed-off-by: Kir Kolyshkin <kolyshkin@xxxxxxxxx>
---
scripts/checkpatch.pl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8a7787d228a6..8f9a46d809ae 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2665,6 +2665,12 @@ sub exclude_global_initialisers {
sub is_userspace {
my ($realfile) = @_;
+
+ # Kernel code under tools/: test modules, mocks, code generator templates.
+ return 0 if ($realfile =~ m@^tools/testing/(?:cxl|nvdimm|crypto)/@ ||
+ $realfile =~ m@^tools/testing/selftests/(?:bpf/test_kmods|livepatch/test_modules|mm/page_frag|net/bench/page_pool)/@ ||
+ $realfile =~ m@^tools/(?:power/cpupower/debug/kernel|virtio/vhost_test|verification/rvgen)/@);
+
return ($realfile =~ m@^tools/@ || $realfile =~ m@^scripts/@);
}
--
2.56.0