用途:提供 Linux 内核的整体心智地图,覆盖启动顺序、主要子系统、关键数据结构以及源码查找位置,作为驱动与子系统开发的架构级导航,与内核内部细节类技能互补。
适用场景:首次浏览 linux.git 查功能或缺陷;理解启动如何到达 init 与驱动 probe;沿子系统追踪系统调用或中断;在学习平台设备模型或驱动技能前的上手准备。
主要内容:
- 启动流程(x86/ARM64 简化):firmware/UEFI → arch/*/boot 解压与早期初始化 → start_kernel()(mm、调度、定时器、IRQ 子系统)→ rest_init() → kernel_init → run_init_process → 用户态 init(systemd)。module_init/device_initcall 在 start_kernel 期间、init 之前执行。
- 主要子系统及典型路径:调度 kernel/sched/(task_struct、sched_entity);内存 mm/(struct page、mm_struct、vm_area_struct);VFS fs/(inode、dentry、file、super_block);块层 block/(request_queue、gendisk);网络 net/(sk_buff、net_device);驱动 drivers/(device、device_driver);系统调用 kernel/、fs/、mm/(SYSCALL_DEFINE*)。
- Initcall 层级(顺序重要):early_initcall → core_initcall → postcore_initcall → arch_initcall → subsys_initcall → fs_initcall → device_initcall → late_initcall;平台驱动通常在 subsys_initcall 或通过 module_init 注册。
- 查代码方法:grep -rn "platform_driver_register" drivers/ 定位符号;./scripts/config --state CONFIG_FOO 查看配置;ls Documentation/admin-guide/ 查看文件层级文档;以 /linux-kernel-architecture 形式提问,如页错误处理位置及调用者。
- 常见问题:驱动过早 probe(initcall 与设备树顺序问题,用 deferred_probe 延迟);符号缺失(编译为模块,需 modprobe 或确认 CONFIG_* 内建);找错子系统(drivers/ 中存在相似名,应沿 struct bus_type 追踪);启动挂起(早期 printk 被禁用,可用 earlyprintk、initcall_debug)。
相关技能:kernel-internals(调度、SLUB、VFS 细节)、kernel-memory-management(mm/ 细节)、platform-device-model(驱动模型)、device-tree(硬件描述)、linux-kernel-modules(LKM 基础)。
限制:资料未提供该 Skill 的具体安装方式、平台支持范围、收费与价格信息,暂未提供。