torvalds/linux
Tooling
The build system, lint tools, code generators, and helper scripts shipped in the tree.
Kbuild and Kconfig
The build system is Kbuild, a recursive make wrapper. The configuration system is Kconfig, a declarative DSL.
- Top-level driver:
Makefile - Per-directory rules: every directory has a
Makefilewithobj-$(CONFIG_FOO) += foo.olines. - Kconfig sources:
Kconfig,arch/*/Kconfig, etc. - Materialized config:
.config(aftermake defconfig/menuconfig). - The kconfig tools live in
scripts/kconfig/.
For a deeper dive, see Reference → Configuration and Subsystems → Scripts.
checkpatch
scripts/checkpatch.pl — the patch linter. ~10k lines of Perl. Run on every patch:
./scripts/checkpatch.pl --strict /tmp/patches/*.patchIt catches: trailing whitespace, lines too long, missing Signed-off-by:, suspicious commit messages, common bugs (e.g. printk without a level, missing kfree on error path), licensing header issues.
Sparse
A semantic checker by Linus Torvalds. Catches type errors, endianness mistakes, locking imbalance, address-space confusion (__user vs. __kernel).
make C=2 # Run sparse on every file
make C=1 # Only on changed filesInstall sparse separately. Annotations live in include/linux/compiler_attributes.h and include/linux/compiler_types.h.
Smatch
Out-of-tree static analyzer. More aggressive than sparse. The kernel ships sample integration but you must build smatch yourself. Catches NULL derefs, unchecked allocations, missing locks.
Coccinelle
Semantic patch language for matching and rewriting C patterns. The kernel ships SmPL scripts in scripts/coccinelle/:
make coccicheck MODE=report # Just report
make coccicheck MODE=patch # Generate patches
make coccicheck COCCI=path/to/script.cocci # Run a specific scriptExamples in tree:
scripts/coccinelle/api/kfree_mismatch.cocci— find use-after-free patterns.scripts/coccinelle/iterators/list_entry_update.cocci— iterator usage bugs.scripts/coccinelle/null/eno.cocci— incorrect error handling.
get_maintainer.pl
scripts/get_maintainer.pl — figure out who to send a patch to.
./scripts/get_maintainer.pl path/to/file.c
./scripts/get_maintainer.pl /tmp/series/0001-*.patchIt parses MAINTAINERS and applies heuristics around git history.
faddr2line, decode_stacktrace
Translate stack-trace addresses to file:line:
./scripts/faddr2line vmlinux some_function+0x42/0x100
./scripts/decode_stacktrace.sh vmlinux < dmesg-with-stackDevice-tree validation
make ARCH=arm64 dtbs_checkValidates DTS files against the YAML schemas under Documentation/devicetree/bindings/. Required for new bindings.
kernel-doc
Inline documentation in /** ... */ comments above functions, structs, and macros. Extracted by Sphinx at make htmldocs. Format reference: Documentation/doc-guide/kernel-doc.rst.
/**
* foo_init - initialize the foo subsystem
* @bar: configuration to apply
*
* Returns 0 on success, a negative errno on failure.
*/
int foo_init(struct bar *bar) { ... }Signed-by-tree CI infrastructure (out of tree but mentioned)
- KernelCI —
https://kernelci.org/— boot tests across many architectures and configs. - Intel 0-day —
https://01.org/lkp/— pulls patches from mailing lists, builds, runs tests. - Red Hat CKI, Linaro tuxsuite/tuxmake, Google syzbot — additional automation that watches mailing lists.
These are not run from the repository, but their results show up in patch reviews and lore.kernel.org threads.
Module signing
scripts/sign-file and the keys under certs/ handle module signing. See Reference → Configuration and Subsystems → Certs.
Linker scripts
Each architecture has a linker script template (e.g. arch/x86/kernel/vmlinux.lds.S). The macros in include/asm-generic/vmlinux.lds.h provide the cross-architecture sections. This is where __init, __exit, __rodata, and special tables (initcalls, tracepoints, BPF kfuncs) get their real placement.
Related pages
- Subsystems → Scripts — full list of in-tree scripts.
- Reference → Configuration — Kconfig, defconfigs.
- Patterns and conventions — what the tools enforce.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.