Part 3 6 chapters

Performance & resources

Measure where time and resources go: scheduling latency, hardware IRQs, sampling profiles, memory leaks, block-I/O patterns, and power.

Chapter 21

runqlat

Measure scheduler run-queue latency โ€” how long tasks wait runnable-but-not-running โ€” by stitching together the sched tracepoints, and meet the technique that hot paths demand: aggregating a histogram in the kernel instead of emitting per-event.

30 minutesRead โ†’
Chapter 22

hardirqs

Measure the time the kernel spends in hardware-interrupt handlers, per IRQ vector, by timing the irq tracepoints keyed by CPU and accumulating per-vector totals in a kernel map โ€” and understand why hardirq time is hidden latency.

25 minutesRead โ†’
Chapter 23

profile

Build a sampling CPU profiler with a perf_event program firing at a fixed frequency across all CPUs, capture kernel and user call stacks with bpf_get_stackid and StackTrace maps, and emit flame-graph-ready folded output.

35 minutesRead โ†’
Chapter 24

memleak

Find allocations that are never freed by pairing malloc/calloc with free on libc, recording each outstanding allocation's call stack with bpf_get_stackid so the leak points back to the code that made it.

30 minutesRead โ†’
Chapter 25

biopattern

Classify block-device I/O as sequential or random per device by tracking each device's sector position across the block_rq_issue tracepoint โ€” the access pattern that determines whether storage thrives or thrashes.

25 minutesRead โ†’
Chapter 26

Energy monitoring

Attribute power consumption to individual processes โ€” the modern sustainability use of eBPF โ€” by crediting each task its on-CPU time and multiplying its share by system power from RAPL, and why virtualization makes this hard.

30 minutesRead โ†’