Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9123449EA5 for ; Wed, 1 Apr 2026 14:47:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775054860; cv=none; b=leYEVn9rUVVZ34MTzARUOXFgEXUAhHQq0cIvpdwXAdQMO5NhXbJrA8SGPjnABaiicwyLgIWYA+LdIXPfmb2KZY1wibHatAX8FLFW2WSFBN50RJR6JMuZ4NsiylY39C+rWehhYpftKVYF3WN3bH3z3TRuPyGkynFMQcUHCN3wwkc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775054860; c=relaxed/simple; bh=m5jgRl02Kb2saLdw/fhBCXn62G78CQNhsYoC8GWduAg=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=NUYuuzY8gl06rqSFsFI/MSgDVJgabd2+zSfYuLM5ChTeQGaOB4DImROra5VlE51ogkFs3/MDqB/FMZdAI3zl+gkc4G3mj4Wb1ybm7KecLNXdkwYVwV9nlRB9/L3QD6svaQDcVdlEopg/+eTqdO4KtHbwxuZRdQ+5l3LlP/H0UQc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gt7l8XIN; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gt7l8XIN" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-488895ad947so3333045e9.3 for ; Wed, 01 Apr 2026 07:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775054857; x=1775659657; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=5OtCDt1OAvI04ZsLWaIlEak0ysimwErbNeC45AGG338=; b=gt7l8XINFGzw1EqUPJn6KfMxeIRlDjoj/AFFw4GaMgv2fRy0YA5D7rYQNqZ3ZLMaEj XR9FXOev9l3lZvTSs//G3lXej4xYxGd8/cvupyxobW+N5eRDoDK4IzkOsLtRAVVMtATl i58j+qjg4UrehiMyovC4EEqVa8NuddhbAndjMFFa/wQxdB4szRcD2VQy1zpfMC1KreVO /3Hx/9rkFByEgRosUdJ76U5UG/uOoLxnyLS4Ih4VAf5s1R5WIsCuXl+/TtkhRirs8II7 UugnyXoI2AgvS/Fh3MiUeuclOBwhpu7R/1YMAF0Ffna9lnYiCiI40TDf/1iWZIE/bQFg tqBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775054857; x=1775659657; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5OtCDt1OAvI04ZsLWaIlEak0ysimwErbNeC45AGG338=; b=Edb1yWGM9DR12DetqbmKlYr6VX+NZ6+lascZLhDg9axrnmxShk0ExFw10HXnwPBbZx RXJOAbiWG3Sx7Zbl2weMarojzyEnWIrJGWyMMfuEuFyxqCRN6nvuCZIOMccu1frZeZp/ 9j2R1eU7dfUFlrFWZJmnipyG4YODwLzJ4cbQjsZ/SzUw2Vqevihx/iMBrLg8DhLM+LsJ XXEOOQaUKWKyg9IXwgTWhyFnC+Im+kuAmrMoti3cbkuv1TKtZgaIvC1EmksSswZzJqRr VLv4LNGpetQmW0gwk32voQkK697OinNlYAtgv3Uxdw2CeXNXdR/nAgmKLKh/z6wt3yxC EaYQ== X-Gm-Message-State: AOJu0YxAiKP87DJPFyAmB66d+/ReJ1+j+jSifnOuGXxiZ9+QNTlkJ+1B 1tC3Ro4oiNuEgB0rS6UHrJ6iCVR+6NBYaKp5wVi5BMP4SUyk0orrWrsr3L7sHySsL+8= X-Gm-Gg: ATEYQzxOhAQnnn7FtI/f4xTcC/TUBe/r9YEoy+SL4NkkQqkAKZRfRTQ1dh+ED0J3M/6 BG72PZqeb5vNRDgJuSdOcXuWcjUXm+UBaWzR5Bd4Rt0rX3P+nNhu62Zq05o+Y885K6P5FKz/UOZ OdAhwceALz8O1sMYZDzYd6O6z5/wIq0sJojCkOCMRjRSgtAxILSJX5Cs7+OEJhodbM704R/1vMN 2DTJZJy19+C+o55L9h6EUMrdl8bhQgX7W9jrB0lN/NR4jqjTzN3mvVCO+TObIGEWTPH4zOiocT7 F0mrpbsqvMclMqTsQGRRFlJPGCYQDNYDxump/CZiOb4aejxtvtnW8jSflC9vKKIwAO5NplbT76+ nHjolPj0ejHCt5KRfJezY8ld5U3WDa870ZrZ6dK3KShQHUufw6E6zFacwE+EnCkkpxXqQjGOpJf 1A96CMSGXZXQRTB+68zCDeqReOsE8ZuE9TSHlvndHUuaz8coJS/QuBMugppeLqqA== X-Received: by 2002:a05:600c:3b1e:b0:485:4388:3492 with SMTP id 5b1f17b1804b1-48883563102mr62343445e9.11.1775054856948; Wed, 01 Apr 2026 07:47:36 -0700 (PDT) Received: from fedorarm (net-2-37-83-250.cust.vodafonedsl.it. [2.37.83.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4887c8b6230sm45753505e9.24.2026.04.01.07.47.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2026 07:47:36 -0700 (PDT) From: Guido De Rossi To: LKML Subject: [PATCH 0/2] scripts: rewrite get_maintainer and checkpatch in Python Date: Wed, 1 Apr 2026 16:47:21 +0200 Message-ID: <20260401144723.44406-1-guido.derossi91@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The Continuing Evolution of Kernel Tooling: Perl to Python, a Natural Progression 1. Introduction The Linux kernel has always taken a pragmatic approach to language selection. C was chosen in 1991 not for elegance but for direct hardware access, minimal overhead, and broad compiler availability. In the same spirit, the auxiliary scripts that grew alongside the kernel -- patch validation, maintainer lookup, build orchestration -- were written in Perl, the undisputed text-processing champion of the 1990s and early 2000s. Larry Wall's creation was, in essence, the scripting language of the Unix world, and the kernel community adopted it enthusiastically. However, the landscape of software development is not static. Just as geological strata record the transformation of the Earth's surface, the source tree of a long-lived project records the shifting preferences of its community. The kernel is now experiencing two parallel language transitions that, while operating at different layers, are driven by remarkably similar forces. 2. The Rust-for-C Precedent The introduction of Rust in Linux 6.1 established a powerful precedent. Memory safety guarantees eliminate entire vulnerability classes -- use-after-free, buffer overflows, data races -- which account for approximately 70% of security-critical bugs in C codebases (Microsoft Security Response Center, 2019; Google Project Zero, 2020-2024). The kernel community's acceptance of Rust, despite significant integration challenges, demonstrates a willingness to embrace language transitions when the technical merits are sufficiently compelling. 3. The Case for Python over Perl The same evolutionary pressures driving the Rust-for-C transition apply with equal force to the scripting layer. 3.1. Developer Familiarity The TIOBE Index, Stack Overflow Developer Survey, and GitHub Octoverse have consistently documented a dramatic shift: Python has risen to the most widely used language in the world, while Perl has experienced a corresponding decline. A kernel developer encountering a bug in scripts/checkpatch.pl is far more likely to diagnose and fix it if the tool is written in Python. The cognitive overhead of context-switching between C, Rust, and Perl is a real productivity cost. Perl's TMTOWTDI ("There's More Than One Way To Do It") philosophy, while liberating for experienced Perl programmers, creates a barrier for developers who encounter Perl code infrequently. The Zen of Python's contrasting principle -- "There should be one obvious way to do it" -- produces code that is more uniformly readable across authors. 3.2. Language Viability The Perl 5/Raku schism fragmented the community for over a decade. While Perl 5 continues to receive maintenance releases, the rate of evolution has slowed considerably compared to Python's regular annual cadence. Depending on a language with a shrinking contributor base for critical development tooling introduces technical debt that compounds over time. 3.3. Existing Precedent The transition is already underway. Several kernel tools are already in Python: kernel-doc.py, spdxcheck.py, checkkconfigsymbols.py, and bpf_doc.py. The scripts/ directory currently contains 17 Perl scripts and 11 Python scripts, with the balance progressively shifting toward Python each release. 4. Implementation This series rewrites the two most heavily used Perl scripts: Patch 1: scripts/get_maintainer.py (2,393 lines) Full-parity rewrite of get_maintainer.pl (2,660 lines) producing identical output across all modes. Performance is achieved through literal prefix extraction from glob patterns, reducing regex compilations from ~9,500 to ~170 per invocation (98% reduction). Mode Perl Python Speedup ---------------------------------------------- Single file (--nogit) 7.96s 8.00s 1.0x Default (with git) 7.93s 8.09s 1.0x Patch (--nogit) 2.60s 2.22s 1.2x Self-test 2.69s 1.52s 1.8x Patch 2: scripts/checkpatch.py (2,417 lines) Rewrite of checkpatch.pl (7,882 lines) implementing the core checking infrastructure and most commonly triggered checks. The 3.3x line count reduction reflects Python's expressiveness. Mode Perl Python Speedup --------------------------------------------- core.c (10.9k lines) 9.0s 4.1s 2.2x dev.c (13.3k lines) 11.7s 4.8s 2.4x super.c (7.6k lines) 7.3s 3.3s 2.2x 5 files (~50k lines) 40.7s 16.6s 2.5x Patch mode (1 commit) 2.8s 2.7s 1.0x Git mode (5 commits) 14.3s 11.8s 1.2x Both scripts use only the Python 3.6+ standard library, already a kernel build requirement. They accept the same CLI options as their Perl counterparts and produce identical or near-identical output, so existing workflows and CI pipelines work without modification. 5. On the Preservation of the Perl Originals The original Perl scripts are deliberately retained in the tree. Much as archaeological remains are preserved in situ for the insight they offer into the practices and constraints of an earlier era, the .pl files serve as a historical reference and a compatibility fallback. They document the accumulated wisdom of two decades of kernel style enforcement and maintainer management, and remain available for environments where Python 3.6+ is not yet present or for developers who wish to cross-reference behavior between the two implementations. We do not delete what we have superseded; we let it stand as a testament to the work that came before. 6. Relationship to Broader Kernel Language Strategy These transitions address different layers of the kernel ecosystem. Rust replaces C where memory safety reduces bugs in code running at the highest privilege level. Python replaces Perl where developer accessibility and long-term maintainability matter more than raw speed -- in tools that run on the developer's workstation, not on the target system. Together, they represent a maturation of the kernel's language portfolio, adapting to modern realities while preserving the project's core values of technical excellence and practical judgment. 7. Conclusion This transition is not a statement about the inherent superiority of one language over another. Perl served the kernel community well for over two decades, and its contributions should not be understated. Rather, this reflects the natural evolution of a project that has always adopted new tools when they better serve its community. As Linus Torvalds has noted in discussions about Rust, the kernel must remain attractive to new contributors, and the tools surrounding it are part of that equation. By rewriting critical development tools in the language that the next generation of kernel developers already knows, we reduce friction, improve accessibility, and ensure the kernel's tooling remains as vibrant as the kernel itself. Guido De Rossi (2): get_maintainer: rewrite in Python checkpatch: rewrite in Python scripts/checkpatch.py | 2417 +++++++++++++++++++++++++++++++++++++ scripts/get_maintainer.py | 2393 ++++++++++++++++++++++++++++++++++++ 2 files changed, 4810 insertions(+) create mode 100755 scripts/checkpatch.py create mode 100755 scripts/get_maintainer.py -- 2.52.0