lkmpg is a modernized, open-source guide that teaches the fundamentals of writing Linux kernel modules through clear explanations and working examples. It covers the full lifecycle: building and loading modules, understanding kernel symbols, handling device files, and interacting with kernel subsystems. Readers learn about concurrency concerns (spinlocks, mutexes), memory allocation in kernel space, and safe patterns for error handling and cleanup. The guide pairs narrative chapters with compilable code, so you can move from theory to practice and observe behavior directly with dmesg and friends. It also calls out pitfalls—like blocking in the wrong context or leaking references—that matter for stable, production-quality modules. As a teaching resource and a quick reference, lkmpg lowers the barrier to kernel development by showing how to extend Linux safely and idiomatically.
Features
- Covers module initialization and cleanup procedures in modern Linux kernels
- Examples of device driver code and interfacing with hardware abstractions
- Explains synchronization, concurrency, locking, race conditions inside kernel modules
- Updated explanations to match changes in kernel APIs since version 5.0
- Includes scripts and examples for building modules
- Licensed under OSL-3.0 (Open Software License) making it free to use and redistribute under those terms