What happened

Attach an eBPF program to a hot kernel path — say, every file open — and you have added code to a syscall that runs millions of times, with no idea what it costs. This post is the measurement recipe: build a microbenchmark that calls openat on /etc/hostname in a loop with CLOCK_MONOTONIC timing, pin it to one core with taskset -c 3, give it real-time priority with chrt -f 99, throw away the first ten percent as warmup, and compare against a baseline with no hook attached. Then set net.core.bpf_jit_enable=1 and net.core.bpf_jit_kallsyms=1 so perf can name the JIT-compiled eBPF symbols, and run perf record -e cycles:k -F 997 -g --call-graph fp. In the author's case the flame graph pointed at bpf_probe_read_kernel at 29.94% of cycles, with copy_from_kernel_nofault under it at 18.88%. 113 points, six comments.

Why it matters

Two sysctls, perf and a fifty-line C loop replace an observability vendor's entire pitch. That is zero-budget engineering in its purest form, and the same discipline as running models locally: own the measurement and you stop paying people to tell you numbers you could have produced yourself in an afternoon. The bpf_jit_kallsyms detail alone earns the read — without it perf renders your program as unnamed addresses, which is why so many engineers wrongly conclude eBPF is invisible to profilers.

But, but, but…

The post publishes no absolute overhead number, and the author says so outright: the cost depends entirely on what your hook does, so a percentage from someone else's LSM hook tells you nothing about yours.

What you get is p50/p99 deltas against your own baseline and a flame graph — a method, not a benchmark. Cycle attribution inside the eBPF program can also be a decoy: an HN commenter pushed the analysis one level deeper and reported that in their own profiling over 90% of cycle time traced back to page table walks, meaning a hot bpf_probe_read_kernel may really be TLB misses and address-translation work provoked by your access pattern. In that case the fix is reshaping which memory you touch, not rewriting the eBPF.