[RFC PATCH v1 0/2] scripts: introduce Python versioncheck backend

0 views
Skip to first unread message

ChenMiao

unread,
Feb 7, 2026, 6:33:26 PM (8 hours ago) Feb 7
to chao...@openatom.club, dz...@openatom.club, luo...@openatom.club, plu...@openatom.club, hust-os-ker...@googlegroups.com
From: Chen Miao <chen...@openatom.club>

Hi all,

This series adds scripts/checkversion.py for make versioncheck, keeps
scripts/checkversion.pl selectable, and switches the default backend to
Python.

The intent is to make this maintenance script easier to read and maintain
while preserving current diagnostics behavior.

Compared with scripts/checkversion.pl, the Python backend speeds up runtime
with:
- byte-level fast-path filters before regex passes;
- on-demand comment/string masking and checks;
- deferred line-number calculation for diagnostics;
- regex-based path excludes (scripts/checkversion.exclude and
VERSIONCHECK_EXCLUDE_REGEX_FILE);
- a fix for string masking to avoid multi-line overmatching that can hide
real version macro uses.

On the same tree, make versioncheck wall time dropped from 13.08s
(Perl) to 3.52s (Python).

RFC:
- Is it acceptable to migrate this kind of small maintenance script from
Perl to Python when behavior is preserved?
- For this series, is it acceptable to make scripts/checkversion.py the
default for make versioncheck, while keeping CHECKVERSION=perl as a
fallback?

Patch 2 then applies the current versioncheck findings by removing
unnecessary <linux/version.h> includes from the reported files.

Patch summary:
- 1/2: add scripts/checkversion.py, wire CHECKVERSION=perl|python,
and switch the default to Python.
- 2/2: remove redundant <linux/version.h> includes.

Tested with:
- make versioncheck CHECKVERSION=perl
- make versioncheck CHECKVERSION=python

Signed-off-by: Chen Miao <chen...@openatom.club>

Chen Miao (2):
scripts: checkversion: add Python implementation
scripts: checkversion: fix linux/version.h usage reported

Makefile | 13 +-
scripts/checkversion.exclude | 6 +
scripts/checkversion.py | 217 ++++++++++++++++++
.../testing/selftests/bpf/progs/dev_cgroup.c | 1 -
.../testing/selftests/bpf/progs/netcnt_prog.c | 1 -
.../selftests/bpf/progs/test_map_lock.c | 1 -
.../bpf/progs/test_send_signal_kern.c | 1 -
.../selftests/bpf/progs/test_spin_lock.c | 1 -
.../selftests/bpf/progs/test_tcp_estats.c | 1 -
tools/testing/selftests/wireguard/qemu/init.c | 1 -
10 files changed, 235 insertions(+), 8 deletions(-)
create mode 100644 scripts/checkversion.exclude
create mode 100755 scripts/checkversion.py

--
2.43.0

ChenMiao

unread,
Feb 7, 2026, 6:33:34 PM (8 hours ago) Feb 7
to chao...@openatom.club, dz...@openatom.club, luo...@openatom.club, plu...@openatom.club, hust-os-ker...@googlegroups.com
From: Chen Miao <chen...@openatom.club>

Running make versioncheck reports:

./tools/testing/selftests/bpf/progs/dev_cgroup.c: 9 linux/version.h not needed.
./tools/testing/selftests/bpf/progs/netcnt_prog.c: 3 linux/version.h not needed.
./tools/testing/selftests/bpf/progs/test_map_lock.c: 4 linux/version.h not needed.
./tools/testing/selftests/bpf/progs/test_send_signal_kern.c: 4 linux/version.h not needed.
./tools/testing/selftests/bpf/progs/test_spin_lock.c: 4 linux/version.h not needed.
./tools/testing/selftests/bpf/progs/test_tcp_estats.c: 37 linux/version.h not needed.
./tools/testing/selftests/wireguard/qemu/init.c: 27 linux/version.h not needed.

Remove unnecessary linux/version.h includes from the flagged source files.

After this change, make versioncheck passes with Python version.

Signed-off-by: Chen Miao <chen...@openatom.club>
---
tools/testing/selftests/bpf/progs/dev_cgroup.c | 1 -
tools/testing/selftests/bpf/progs/netcnt_prog.c | 1 -
tools/testing/selftests/bpf/progs/test_map_lock.c | 1 -
tools/testing/selftests/bpf/progs/test_send_signal_kern.c | 1 -
tools/testing/selftests/bpf/progs/test_spin_lock.c | 1 -
tools/testing/selftests/bpf/progs/test_tcp_estats.c | 1 -
tools/testing/selftests/wireguard/qemu/init.c | 1 -
7 files changed, 7 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/dev_cgroup.c b/tools/testing/selftests/bpf/progs/dev_cgroup.c
index c1dfbd2b56fc9..4c4e747bf827a 100644
--- a/tools/testing/selftests/bpf/progs/dev_cgroup.c
+++ b/tools/testing/selftests/bpf/progs/dev_cgroup.c
@@ -6,7 +6,6 @@
*/

#include <linux/bpf.h>
-#include <linux/version.h>
#include <bpf/bpf_helpers.h>

SEC("cgroup/dev")
diff --git a/tools/testing/selftests/bpf/progs/netcnt_prog.c b/tools/testing/selftests/bpf/progs/netcnt_prog.c
index f9ef8aee56f16..8d82bdb8f2804 100644
--- a/tools/testing/selftests/bpf/progs/netcnt_prog.c
+++ b/tools/testing/selftests/bpf/progs/netcnt_prog.c
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/bpf.h>
-#include <linux/version.h>

#include <bpf/bpf_helpers.h>
#include "netcnt_common.h"
diff --git a/tools/testing/selftests/bpf/progs/test_map_lock.c b/tools/testing/selftests/bpf/progs/test_map_lock.c
index 1c02511b73cdb..982bdbf0dba6b 100644
--- a/tools/testing/selftests/bpf/progs/test_map_lock.c
+++ b/tools/testing/selftests/bpf/progs/test_map_lock.c
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2019 Facebook
#include <linux/bpf.h>
-#include <linux/version.h>
#include <bpf/bpf_helpers.h>

#define VAR_NUM 16
diff --git a/tools/testing/selftests/bpf/progs/test_send_signal_kern.c b/tools/testing/selftests/bpf/progs/test_send_signal_kern.c
index 176a355e30624..e70b191162359 100644
--- a/tools/testing/selftests/bpf/progs/test_send_signal_kern.c
+++ b/tools/testing/selftests/bpf/progs/test_send_signal_kern.c
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2019 Facebook
#include <vmlinux.h>
-#include <linux/version.h>
#include <bpf/bpf_helpers.h>

struct task_struct *bpf_task_from_pid(int pid) __ksym;
diff --git a/tools/testing/selftests/bpf/progs/test_spin_lock.c b/tools/testing/selftests/bpf/progs/test_spin_lock.c
index d8d77bdffd3d2..9bcee268f828b 100644
--- a/tools/testing/selftests/bpf/progs/test_spin_lock.c
+++ b/tools/testing/selftests/bpf/progs/test_spin_lock.c
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2019 Facebook
#include <linux/bpf.h>
-#include <linux/version.h>
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"

diff --git a/tools/testing/selftests/bpf/progs/test_tcp_estats.c b/tools/testing/selftests/bpf/progs/test_tcp_estats.c
index e2ae049c2f850..eb0e55ba3f284 100644
--- a/tools/testing/selftests/bpf/progs/test_tcp_estats.c
+++ b/tools/testing/selftests/bpf/progs/test_tcp_estats.c
@@ -34,7 +34,6 @@
#include <string.h>
#include <linux/bpf.h>
#include <linux/ipv6.h>
-#include <linux/version.h>
#include <sys/socket.h>
#include <bpf/bpf_helpers.h>

diff --git a/tools/testing/selftests/wireguard/qemu/init.c b/tools/testing/selftests/wireguard/qemu/init.c
index 3e49924dd77e8..20d8d3192f75c 100644
--- a/tools/testing/selftests/wireguard/qemu/init.c
+++ b/tools/testing/selftests/wireguard/qemu/init.c
@@ -24,7 +24,6 @@
#include <sys/sysmacros.h>
#include <sys/random.h>
#include <linux/random.h>
-#include <linux/version.h>

__attribute__((noreturn)) static void poweroff(void)
{
--
2.43.0

Reply all
Reply to author
Forward
0 new messages