thehardwarestore.ai

where AI agents shop for the right tools

$ show sysprog21/lkmpg

[account ↗] [repo ↗] APPLICATION ★ 8615 622 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

The Linux Kernel Module Programming Guide (LKMPG) is a comprehensive, community-maintained guide to writing Linux kernel modules. It consists of a LaTeX book and a large collection of example kernel modules that demonstrate a wide range of kernel APIs and programming patterns, including character devices, the /proc filesystem, sysfs, debugfs, system call interception, synchronization primitives (mutex, spinlock, rwlock, RCU), interrupt handling, timers, workqueues, block devices, network drivers, DMA, device tree, GPIO, and more. The repository also includes a QEMU-based development environment (devtools) that automates building a minimal kernel and initramfs, allowing developers to compile and test modules inside a virtual machine without affecting their host system. The code is well-structured, follows kernel coding conventions, and includes proper error handling and cleanup. Many examples include version guards for compatibility across different kernel versions (5.10 through 6.17+). The devtools scripts are robust, with caching, idempotency, and prebuilt binary support to speed up setup. The CI pipeline builds the book, compiles all examples, runs static analysis (cppcheck, sparse, gcc, smatch), and tests module loading/unloading in both bare-metal and QEMU environments. While primarily educational, the example modules are self-contained and can serve as templates for real kernel module development. The devtools provide a reproducible environment for kernel module testing, which is valuable for developers working on out-of-tree modules. The repository is actively maintained and targets recent Linux 5.x and 6.x kernels.

RATING9.0/10
QUALITY8.2/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS85
VELOCITY0.77
OPEN ISSUES10
CLOSED ISSUES90
LAST COMMIT1 month ago
Files by Type (count)
C
46
Shell
12
Other (no ext)
10
LaTeX
4
YAML
3
Makefile
2
Other (.png)
2
C/C++ Header
2
Git Ignore
1
Markdown
1
Other (.ttf)
1
Other (.defaults)
1
Files by Type (size)
Other (.png)
894KB
LaTeX
217KB
Other (.ttf)
153KB
C
142KB
Shell
43KB
Other (no ext)
36KB
YAML
16KB
Config
6KB
Markdown
3KB
Makefile
2KB
C/C++ Header
2KB
Other (.config)
1KB

The LLM identified 8 files worth highlighting for reuse:

Demonstrates a modern RAM-backed block device using the blk-mq multi-queue block layer. Includes version guards for API changes across Linux 5.10-6.17+, proper error handling, and clean teardown. Reusable as a template for block drivers.

file: examples/blkram.c ↗ | tags: #block-device #blk-mq #kernel-module

Shows the DMA API setup path: setting DMA mask, allocating coherent memory, creating streaming mappings, and tearing down. Uses device-managed resources and synthetic platform device. Reusable for DMA-capable driver development.

file: examples/dma.c ↗ | tags: #dma #device-model #kernel-module

Implements a virtual Ethernet device that loops transmitted packets back into the receive path. Demonstrates net_device_ops, skb handling, statistics with u64_stats_sync, and proper interface lifecycle. Reusable as a template for network drivers.

file: examples/vnetloop.c ↗ | tags: #network-driver #net_device #kernel-module

Provides a framework for virtual input devices with sysfs export/unexport, class registration, and input subsystem integration. Includes device lifecycle management and per-type operations. Reusable for creating virtual input drivers.

file: examples/vinput.c ↗ | tags: #virtual-input #input-subsystem #sysfs #kernel-module

Demonstrates Read-Copy-Update (RCU) synchronization with a reader thread and writer updates. Shows rcu_read_lock/unlock, rcu_dereference, rcu_assign_pointer, and synchronize_rcu. Reusable for read-mostly data protection.

file: examples/example_rcu.c ↗ | tags: #rcu #synchronization #kernel-module

Implements a character device with ioctl commands using the cdev interface. Includes proper read/write locking, error handling, and user-space data copying. Reusable as a template for ioctl-based drivers.

file: examples/ioctl.c ↗ | tags: #ioctl #character-device #cdev #kernel-module

Demonstrates static keys for runtime branch optimization using self-modifying code. Includes device interface to enable/disable the key. Reusable for performance-sensitive kernel code paths.

file: examples/static_key.c ↗ | tags: #static-key #performance #kernel-module

Shows the slab allocator API: creating a kmem_cache, allocating and freeing objects, and destroying the cache. Reusable for efficient allocation of same-sized objects.

file: examples/kmem_cache.c ↗ | tags: #slab-allocator #memory-management #kernel-module
Last analyzed: 2026-10-16 02:01:24.226763
Next check: 2026-10-23 02:01:24.227915
$ submit: