This page provides a high-level orientation to the Linux kernel source tree. The Linux kernel is a large-scale, monolithic kernel with a modular design, supporting a vast array of hardware architectures and devices. It manages system resources including CPU time, memory, and peripheral access while providing a stable User Application Binary Interface (UAPI) for userspace.
The source tree is organized by functional area rather than by hardware alone. The top-level directories categorize code into architecture-specific logic, core kernel services, device drivers, and supporting infrastructure.
arch/: Contains all architecture-specific code (e.g., x86, arm64). Each architecture implements low-level hooks required by the generic kernel.kernel/: The core of the operating system, containing the scheduler, signal handling, and core process management logic.mm/: The Memory Management subsystem, implementing the page allocator, slab allocators, and virtual memory logic rust/bindings/bindings_helper.h72drivers/: The largest directory by file count, containing subdirectories for every class of hardware (gpu, net, usb, pci, gpio, etc.) MAINTAINERS35-36 drivers/gpio/Kconfig3-12fs/: The Virtual File System (VFS) layer and individual filesystem implementations (ext4, xfs, btrfs, smb, 9p) MAINTAINERS152-164 rust/bindings/bindings_helper.h63net/: Networking protocols (TCP/IP, Bluetooth, 6LOWPAN) and core socket logic MAINTAINERS103-111 MAINTAINERS130-131rust/: Support for writing kernel modules in Rust, including the kernel crate and generated bindings rust/kernel/lib.rs3-12 rust/bindings/bindings_helper.h1-7init/: Contains the main kernel entry point (start_kernel) and logic for parsing boot-time configuration.include/: Global header files defining the kernel's internal and external APIs rust/bindings/bindings_helper.h29-31tools/: Userspace tools for testing and performance analysis (e.g., perf, objtool) scripts/livepatch/klp-build36For a detailed breakdown of every top-level directory and how code ownership is tracked, see Repository Map & Major Directories.
Subsystems interact through well-defined internal APIs. While the kernel is monolithic, it uses an object-oriented pattern in C, where structures contain function pointers (ops) implemented by specific drivers. For example, struct gpio_chip or specific panel functions define how frameworks interact with hardware drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c174-180
The MAINTAINERS file is the source of truth for subsystem boundaries. It maps file patterns to specific people and mailing lists MAINTAINERS33-39
For details on how changes flow from a developer's machine into the mainline tree, see Subsystem Boundaries, Ownership, and Patch Flow.
The following diagram illustrates how a peripheral driver interacts with kernel subsystems and underlying hardware interfaces.
Peripheral Driver Initialization Path
Sources: drivers/gpio/Makefile6-23 drivers/gpio/gpio-altera.c1-35 drivers/gpio/Kconfig165-172
Several technologies are "cross-cutting," meaning they are used across almost all subsystems to ensure performance, safety, or observability.
kernel crate provides safe wrappers for C APIs, such as DMA, PCI, and Memory Management rust/kernel/lib.rs63-67 rust/kernel/lib.rs105-106For a technical introduction to these primitives, see Key Cross-Cutting Concepts (RCU, Maple Tree, BPF, tracefs).
The kernel uses the Kbuild system. Configuration is handled via Kconfig, which defines symbols (e.g., CONFIG_GPIOLIB) that control conditional compilation in Makefiles drivers/gpio/Kconfig12-13 drivers/gpio/Makefile6-10
Build and Rust Integration
Sources: Makefile25-39 rust/Makefile1-25 rust/kernel/lib.rs141-143 scripts/generate_rust_analyzer.py3-12
drivers/ and look at existing drivers in the same class (e.g., drivers/gpio/ drivers/gpio/Kconfig130-148).kernel/ for process management or mm/ for memory allocation rust/bindings/bindings_helper.h72-88rust/kernel/ for existing API abstractions like Device, Dma, or Pci rust/kernel/lib.rs63-106scripts/get_maintainer.pl which parses the MAINTAINERS file MAINTAINERS50-54For detailed guides on specific subsystems, refer to the child pages listed in the sidebar.
Sources: MAINTAINERS1-131 Makefile1-205 rust/kernel/lib.rs1-144 drivers/gpio/Kconfig1-100 drivers/gpio/Makefile1-50 rust/bindings/bindings_helper.h1-107 rust/helpers/helpers.c1-103
Refresh this wiki
This wiki was recently refreshed. Please wait 1 day to refresh again.