eBPF observability foundations
Quick answer
eBPF lets supported programs run at selected kernel hooks under kernel-controlled constraints. For observability, an event can trigger a program that updates a map or reports a record. The verifier, attach point and map serve different roles.
A program that passes the verifier is not automatically a correct measurement. Decide what event counts, which workload it represents, and whether event loss or map capacity biases the result. Compare a bounded sample with an independent measurement.
Prepare the practice environment
Run python3 lab-fixtures/advanced-kernel/setup.py from the extracted root as an ordinary user. Enter the printed private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. The helper reads fictional records. No root, external network, module load or BPF attachment is required. Optional hardware inspection requires an authorized VM.
Prerequisites
Review: Device driver and interrupt concepts.
How it works
A loader supplies a program to the kernel. The verifier examines reachable execution paths, pointer use, bounds and permitted helpers according to program type. Acceptance does not establish correct metrics or acceptable overhead. Supported attach points include tracepoints, kprobes and uprobes; availability and stability differ by kernel, configuration and program type. Tracepoints are explicit instrumentation sites, while kprobes and uprobes observe selected kernel and userspace instruction locations respectively. BPF maps store typed or structured data according to map type; per-CPU aggregation can reduce contention but needs correct merging. BTF conveys type information and supports tooling such as CO-RE relocations; it does not guarantee universal portability. bpftool inspects and can manage BPF objects; bpftrace provides a tracing language. A histogram groups durations by intervals: choose units and nonoverlapping boundaries and account for missing events. Avoid collecting payloads, credentials or unrelated process data. Native BPF loading and attachment require an authorized environment and version-specific permissions; do not weaken controls. This chapter uses offline event lists only.
Try the examples
Half-open buckets count each sample once. These are fictional durations, not actual measurements.
Expected stdout:
[0,10) us: 2[10,100) us: 3[100,infinity) us: 2total: 7A planning checklist rejects a fictional payload request. It does not emulate the verifier or run BPF. The first arrow indicates the selected hook, not an executed event.
Expected stdout:
tracepoint -> verifier -> load -> attach -> map countsrejected: payload collectionOptional tool version in an authorized lab. No object enumeration or attachment is needed.
Manual example; not executed locally. Follow its stated environment restrictions.
Common mistakes
Verifier acceptance is not proof of program correctness or privacy. Do not interpret bucket boundaries as exact percentile values or load tracing programs on unauthorized hosts.
Practice
Inspect latency.json. Calculate the three bucket counts by hand including values exactly 10 and 100 microseconds. Explain why the histogram cannot give an exact p95 and how a loss counter would help.
Related references
Study: bpftool, bpftrace. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
eBPF observability foundations — Knowledge Check
Apply kernel engineering concepts to concrete local examples.
What is the verifier responsible for?
What is a BPF map used for?
Which bucket contains exactly 10 us?
What does BTF describe?