linux_kernel_portfolio

Bootmem Trace: Page Allocation and Refcount Bug

Files

File Purpose
bootmem_trace.c Kernel module source with axiomatic comments
worksheet.md Step-by-step hand calculations and error report
Makefile Build configuration

Build and Run

cd kernel_exercises/bootmem_trace
make
cat /proc/buddyinfo  # Record before
sudo insmod bootmem_trace.ko
dmesg | tail -30     # Observe values
sudo rmmod bootmem_trace
cat /proc/buddyinfo  # Compare after

Exercise Goal

  1. Trace page allocation from axioms
  2. Calculate PFN, physical address, zone by hand
  3. Trace _refcount transitions: 1→2→1→0→-1
  4. Observe kernel BUG on refcount underflow

Worksheet Contents