kernel-maintainer
Rust For Linux Kernel Maintainer
A comprehensive skill for working with Rust code in the Linux kernel. This skill provides guidance on coding standards, API usage, patch review, debugging, and code navigation for the Rust For Linux (RFL) project.
When to Use This Skill
Use this skill when:
- Writing or maintaining Rust kernel modules
- Reviewing Rust patches for the kernel
- Learning Rust For Linux development
- Debugging kernel Rust issues
- Understanding kernel Rust APIs
- Following kernel Rust coding conventions
Overview
Rust For Linux (RFL) brings Rust as a second language to the Linux kernel, enabling memory-safe kernel module development. This skill helps you navigate the unique constraints and patterns of kernel development with Rust.
Key differences from userspace Rust:
- No standard library - Use
coreandalloc - Custom allocators - Use kernel allocation functions
- Different error handling - Kernel-style error codes
- Concurrency models - Kernel synchronization primitives
- FFI boundaries - Safe wrappers around C kernel APIs
Quick Start
New to Rust For Linux?
- Start with coding standards to understand kernel Rust conventions
- Reference the API guide for common patterns
- Review the patch review guide to understand expectations
Working on a Specific Task?
- Writing a module → See coding standards + API reference
- Reviewing patches → See patch review guide
- Debugging issues → See debugging guide
Part 1: Fundamentals
Start here to understand Rust For Linux basics.
Coding Standards
The kernel has specific conventions for Rust code. Always follow these when writing kernel Rust:
Key topics:
- Formatting and style (4 spaces, line length limits)
- Naming conventions (PascalCase, snake_case, SCREAMING_SNAKE_CASE)
- Kernel-specific guidelines (error handling, memory management, safety)
- Module organization
- Documentation requirements
API Reference
Understanding kernel Rust APIs is essential for effective kernel development:
Core modules covered:
kernel::alloc- Memory allocation with kernel flagskernel::error- Error handling with kernel error codeskernel::sync- Mutex, SpinLock, RwLockkernel::fs- Filesystem abstractionskernel::device- Device driver supportkernel::ioctl- IOCTL interfacekernel::miscdev- Miscellaneous devices
Part 2: Code Navigation
Finding Your Way Around
The Rust For Linux codebase is organized into several key areas:
rust/ - Main Rust support
├── bindings/ - Generated C bindings
├── core/ - Core kernel abstractions
├── alloc/ - Memory allocation
├── kernel/ - Main kernel module support
└── samples/ - Example modules
Key Patterns
- Module Structure: Each kernel subsystem has Rust wrappers in
rust/kernel/ - FFI Layer: C bindings are in
rust/bindings/ - Samples: Example modules in
rust/samples/
Navigation Tips
- Use
rust/as the root for Rust-specific code - Check
rust/core/for core abstractions - Look at
rust/samples/for working examples - The RFL directory contains indexed search data for quick lookup
Part 3: Patch Review
When reviewing Rust kernel patches, follow a systematic approach:
Review Checklist
See Patch Review Guide for detailed checklist:
- Safety - Memory safety, concurrency, error handling
- Standards - Coding style, naming, formatting
- API Design - Public interfaces, documentation
- Testing - Unit tests, error path coverage
- Performance - Allocations, data structures, locking
Key Review Points
- Always verify unsafe code has proper safety comments
- Check error handling is comprehensive
- Ensure kernel idioms are followed (not generic Rust)
- Verify module initialization/cleanup pairing
Part 4: Debugging
When things go wrong, use systematic debugging:
Common Issues
See Debugging Guide for:
- Compilation errors
- Runtime issues (module won't load, panics)
- Memory issues (allocation failures, leaks)
- Concurrency issues (deadlocks, race conditions)
Debugging Techniques
- Check dmesg first - Most kernel issues leave traces
- Add pr_info! checkpoints - Narrow down failure location
- Use kernel debugging tools - DebugFS, tracepoints
- Test incrementally - Small changes, test often
Part 5: Resources
Templates
Module Template
use kernel::prelude::*;
module! {
type: MyModule,
name: "my_rust_module",
author: "Your Name",
description: "Description",
license: "GPL",
}
struct MyModule;
impl kernel::Module for MyModule {
fn init() -> Result<Self> {
pr_info!("Module initializing\n");
Ok(Self)
}
}
File Operations Template
use kernel::fs::{File, FileOperations};
struct MyFileOps;
impl FileOperations for MyFileOps {
type OpenData = ();
type ReadWriteBits = u32;
fn open(_data: &(), _f: &File) -> Result<()> {
Ok(())
}
fn read(
_f: &File,
_data: &Self::OpenData,
_buf: &mut [u8],
_offset: u64,
) -> Result<usize> {
Ok(0)
}
}
Reference Quick Links
| Topic | File |
|---|---|
| Coding conventions | coding_standards.md |
| API usage | api_reference.md |
| Patch review | patch_review.md |
| Debugging | debugging_guide.md |
| Module structure | module_structure.md |
| Testing | testing_guide.md |
| Common patterns | common_patterns.md |
External Resources
Part 6: Module Development
When creating new kernel modules, follow established patterns:
Module Structure
See Module Structure Guide for:
- Directory organization
- Character, block, and network device templates
- Module parameters
- Cargo.toml configuration
Common Patterns
See Common Patterns for:
- Initialization patterns
- Error handling idioms
- Synchronization primitives
- Memory management
- Device registration
Part 7: Testing
Comprehensive testing is essential for kernel modules:
Testing Guide
See Testing Guide for:
- Unit tests
- KUnit integration
- Error path testing
- Property-based testing
- Performance testing
Best Practices Summary
- Always check allocations - Never assume memory is available
- Document unsafe code - Safety comments are mandatory
- Handle all errors - No silent failures
- Follow kernel patterns - Kernel idioms, not generic Rust
- Test thoroughly - Error paths, edge cases
- Keep modules focused - One logical change per module
- Write good commit messages - Explain what and why, not how
More from ab22593k/skills
latency-principles
Comprehensive framework for diagnosing, optimizing, and hiding latency in software systems. You MUST use this skill whenever the user mentions slow performance, response time, p99/tail latency, or asks about system throughput and concurrency. It covers Little's Law, Amdahl's Law, and strategies for Data/Compute optimization (e.g., zero-copy, wait-free sync, request hedging). Trigger this even for theoretical questions about latency laws or ballpark estimations using latency constants.
14expressive-design
Material 3 Expressive design system for Flutter (Android & Linux). You MUST use this skill whenever the user asks to improve, modernize, or transform a Flutter UI, especially for consumer, media, or communication apps. It provides exact specs for Bento Grids, Masonry, color convergence, variable fonts, and expressive motion. Trigger this for any request involving 'modern' or 'emotionally engaging' Flutter widgets, even if they don't explicitly mention 'Expressive' design. Do NOT use for banking or safety-critical apps where standard M3 is required.
13widget-previewer
Use the Flutter Widget Previewer to preview widgets in isolation with real-time rendering in Chrome. Use when working with Flutter widget previews, @Preview annotations, preview configurations, or widget development workflows. Triggers include setting up widget previewer, adding @Preview annotations, customizing previews, creating custom preview annotations, handling multiple preview configurations, or troubleshooting widget preview issues.
3generative-thinker
Guides the agent to apply Generativity Theory to solve problems by building high-leverage, open-ended systems. Use this skill when the user asks for "out of the box" ideas, platform strategies, or when a task benefits from enabling others to innovate rather than providing a narrow, single-purpose fix.
3effective-testing
A comprehensive methodology for highly effective, human-centered software testing, based on 'Taking Testing Seriously' (Bach & Bolton, 2026). Use this skill whenever testing, quality assurance, bug hunting, test strategy, automation traps, or risk analysis are mentioned. MANDATORY for: (1) Designing test strategies for complex products, (2) Performing exploratory testing using Session-Based Test Management (SBTM), (3) Identifying bugs with advanced oracle heuristics (FEW HICCUPS), (4) Reporting bugs with high business significance, (5) Prospective testing on requirements/designs, or (6) Supervizing AI and signals-based testing. If the user asks 'Is this code good?', 'How should I test this?', or 'Help me find bugs', YOU MUST use this skill to provide a professional, context-driven investigation rather than shallow checks.
2latency principles
Comprehensive framework for diagnosing, optimizing, and hiding latency in software systems. You MUST use this skill whenever the user mentions slow performance, response time, p99/tail latency, or asks about system throughput and concurrency. It covers Little's Law, Amdahl's Law, and strategies for Data/Compute optimization (e.g., zero-copy, wait-free sync, request hedging). Trigger this even for theoretical questions about latency laws or ballpark estimations using latency constants.
1