Part 9 · 1 chapters · ~8 min
Reading the Source
Navigating the kernel tree with Elixir cross-referencer and cscope, finding a syscall's implementation, reading git history and blame, LKML and lore.kernel.org, the patch workflow, maintainers and MAINTAINERS, building and booting your own kernel in QEMU, and a reading plan.
10
A reading plan
code
# find any syscall's implementation git grep -n 'SYSCALL_DEFINE3(read,' # fs/read_write.c # browse with cross-references: https://elixir.bootlin.com/linux/latest/source # why is this line here? git log -L '/^ssize_t vfs_read/,+20:fs/read_write.c' --oneline | head git log --grep='EEVDF' --oneline kernel/sched/ | head # the discussion behind a patch: search its subject on lore.kernel.org # who to ask about a file scripts/get_maintainer.pl -f mm/vmscan.c # build and boot your own kernel in QEMU (minutes, safe) make defconfig && make -j$(nproc) qemu-system-x86_64 -kernel arch/x86/boot/bzImage -initrd initramfs.cpio.gz -nographic -append console=ttyS0
| week | read | with |
|---|---|---|
| 1 | fs/read_write.c, fs/open.c | strace a program and match each syscall |
| 2 | kernel/fork.c (copy_process), kernel/exit.c | trace fork with bpftrace |
| 3 | mm/memory.c (handle_mm_fault), mm/mmap.c | count faults with perf |
| 4 | kernel/sched/fair.c (EEVDF pick) | /proc/<pid>/sched |
| 5 | net/ipv4/tcp_input.c (receive path) | ss -tmi, nstat |
| 6 | kernel/cgroup/, kernel/nsproxy.c | unshare and /sys/fs/cgroup |
Books: Linux Kernel Development (Love) for concepts, Understanding the Linux Kernel (Bovet and Cesati) for depth, LWN.net articles for current changes, and Brendan Gregg's Systems Performance for the observable side.