This document provides a high-level architectural overview of the Linux kernel codebase, focusing on major subsystems, their interactions, and key code structures. It serves as an entry point for understanding the kernel's organization and provides context for the detailed subsystem documentation that follows.
For detailed information about specific subsystems:
The Linux kernel implements a monolithic architecture with modular extensions. All core subsystems run in a single address space with kernel privileges, enabling efficient communication but requiring careful synchronization. The kernel is organized into functional layers that interact through well-defined interfaces.
Sources: kernel/sys_ni.c1-50 include/linux/syscalls.h1-100 virt/kvm/kvm_main.c1-50 io_uring/io_uring.c1-100
The scheduler core in kernel/sched/core.c manages task execution. A notable feature for user-space performance is Restartable Sequences (rseq), which allows lightweight atomic per-cpu operations without heavy atomic instructions kernel/rseq.c12-19
The rseq system tracks critical sections defined by struct rseq_cs. If a task is preempted or interrupted within a registered critical section, the kernel automatically redirects execution to an abort_ip kernel/rseq.c50-55
Sources: kernel/rseq.c12-68 include/linux/rseq_entry.h42-56 include/uapi/linux/rseq.h
The memory management subsystem handles physical page allocation and virtual memory mapping. It includes specialized allocators like SLUB and the page allocator. For debugging, it integrates features like KASAN and KFENCE.
Sources: mm/page_alloc.c rust/kernel/page.rs1-50
The kernel provides robust error reporting through the panic and oops mechanisms. The panic() function is used to indicate a major problem that prevents the kernel from continuing kernel/panic.c8-11
Key Features:
panic_notifier_list allows subsystems to perform cleanup or emergency actions during a crash kernel/panic.c80-83panic_on_oops and panic_timeout can be tuned via the /proc/sys/kernel/ interface kernel/panic.c161-174Sources: kernel/panic.c1-100 include/linux/panic.h
The Linux kernel now supports Rust to provide memory safety guarantees for new code, particularly drivers. This is implemented via the kernel crate rust/kernel/lib.rs3-9
Key Rust Components:
device, clk, and pci rust/kernel/lib.rs43-137bindings crate provides raw access to C headers, managed via bindgen rust/bindings/bindings_helper.h1-40bindgen cannot handle rust/helpers/helpers.c3-8Sources: rust/kernel/lib.rs1-160 rust/helpers/helpers.c1-100 rust/bindings/bindings_helper.h1-100
The MAINTAINERS file is the authoritative source for code ownership and subsystem responsibilities. It uses a structured format to define:
Sources: MAINTAINERS1-100
| Subsystem | Primary Path | Role |
|---|---|---|
| Process Management | kernel/ | Scheduling, signals, rseq, and process lifecycle. |
| Memory Management | mm/ | Physical/virtual memory, SLUB, page cache. |
| Virtualization | virt/kvm/ | Hardware-assisted VM hosting (KVM). |
| I/O Stack | block/, fs/ | VFS, block layer, and filesystems like Btrfs. |
| Networking | net/ | TCP/IP stack, Bluetooth, and wireless. |
| Graphics | drivers/gpu/drm/ | Display management and GPU drivers (AMDGPU, Xe). |
| Rust Abstractions | rust/kernel/ | Safe language bindings for kernel development. |
Sources: MAINTAINERS Documentation/admin-guide/kernel-parameters.txt
Refresh this wiki
This wiki was recently refreshed. Please wait 3 days to refresh again.