linux-kernel-architecture
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLinux Kernel Architecture
Linux内核架构
Purpose
用途
Provide a mental map of the Linux kernel: boot sequence, major subsystems, key data structures, and where to look in source — complementing with architecture-level navigation for driver and subsystem work.
skills/kernel/kernel-internals提供Linux内核的思维导图:启动序列、主要子系统、关键数据结构以及源码位置——作为的补充,为驱动和子系统开发提供架构层面的导航支持。
skills/kernel/kernel-internalsWhen to Use
使用场景
- First time exploring for a feature or bug
linux.git - Understanding how boot reaches and driver
initprobe - Tracing a syscall or interrupt through subsystems
- Onboarding before or driver skills
skills/kernel-dev/platform-device-model
- 首次为开发功能或修复bug探索时
linux.git - 理解启动过程如何到达以及驱动
init阶段时probe - 追踪系统调用或中断在各个子系统中的流转时
- 在学习或驱动相关Skill前进行入门学习时
skills/kernel-dev/platform-device-model
Workflow
工作流程
1. Boot flow (x86/ARM64 simplified)
1. 启动流程(x86/ARM64简化版)
firmware/UEFI
├── arch/*/boot — decompress kernel, early setup
├── start_kernel() — mm, scheduler, timers, IRQ subsys
├── rest_init() → kernel_init → run_init_process
└── userspace init (systemd)Driver / run during before init.
module_initdevice_initcallstart_kernelfirmware/UEFI
├── arch/*/boot — 解压内核,早期初始化
├── start_kernel() — 内存管理、调度器、定时器、IRQ子系统
├── rest_init() → kernel_init → run_init_process
└── 用户空间初始化(systemd)驱动的 / 在执行期间、init启动前运行。
module_initdevice_initcallstart_kernel2. Major subsystems
2. 主要子系统
| Subsystem | Path (typical) | Key structs |
|---|---|---|
| Scheduler | | |
| Memory | | |
| VFS | | |
| Block | | |
| Net | | |
| Drivers | | |
| Syscalls | | |
| 子系统 | 典型路径 | 关键结构体 |
|---|---|---|
| 调度器 | | |
| 内存管理 | | |
| VFS | | |
| 块设备 | | |
| 网络 | | |
| 驱动 | | |
| 系统调用 | | |
3. Initcall levels
3. Initcall级别
c
/* include/linux/init.h — order matters */
early_initcall → core_initcall → postcore_initcall
→ arch_initcall → subsys_initcall → fs_initcall
→ device_initcall → late_initcallPlatform drivers usually register at or via .
subsys_initcallmodule_initc
/* include/linux/init.h — 顺序至关重要 */
early_initcall → core_initcall → postcore_initcall
→ arch_initcall → subsys_initcall → fs_initcall
→ device_initcall → late_initcall平台驱动通常在级别注册,或通过注册。
subsys_initcallmodule_init4. Finding code
4. 查找代码
bash
undefinedbash
undefinedLocate symbol
定位符号
grep -rn "platform_driver_register" drivers/
grep -rn "platform_driver_register" drivers/
Trace config
追踪配置
./scripts/config --state CONFIG_FOO
./scripts/config --state CONFIG_FOO
File hierarchy docs
文件层级文档
ls Documentation/admin-guide/
undefinedls Documentation/admin-guide/
undefined5. Agent usage
5. Agent使用示例
/linux-kernel-architecture Where does page fault handling live and what calls it?/linux-kernel-architecture 页面错误处理代码位于哪里,由谁调用?Common Problems
常见问题
| Symptom | Cause | Fix |
|---|---|---|
| Driver probes too early | Initcall vs DT ordering | Defer with |
| Symbol missing | Built as module | |
| Wrong subsystem | Similar names in | Follow |
| Boot hang | Early printk disabled | |
| 症状 | 原因 | 解决方案 |
|---|---|---|
| 驱动过早触发probe | Initcall与设备树顺序问题 | 使用 |
| 符号缺失 | 编译为模块 | 执行 |
| 进入错误子系统 | | 跟踪 |
| 启动挂起 | 早期printk未启用 | 启用 |
Related Skills
相关Skill
- — scheduler, SLUB, VFS depth
skills/kernel/kernel-internals - — mm/ details
skills/kernel-dev/kernel-memory-management - — driver model
skills/kernel-dev/platform-device-model - — hardware description
skills/kernel-dev/device-tree - — LKM basics
skills/low-level-programming/linux-kernel-modules
- — 调度器、SLUB、VFS深度解析
skills/kernel/kernel-internals - — mm/细节
skills/kernel-dev/kernel-memory-management - — 驱动模型
skills/kernel-dev/platform-device-model - — 硬件描述
skills/kernel-dev/device-tree - — LKM基础
skills/low-level-programming/linux-kernel-modules