Kernel tracing with eBPF means attaching a verified BPF program to a Linux instrumentation point—such as a tracepoint or kernel function probe—to observe events, debug behavior, or analyze performance. Start with the event you need, check which probes the target machine exposes, and use a tracepoint when it captures the event; choose bpftrace for quick exploration, libbpf for a custom application, or ftrace if its built-in tracing already answers the question.
What is eBPF tracing?
eBPF is a Linux kernel mechanism for running sandboxed programs that extend or instrument kernel behavior without changing kernel source code or loading a kernel module. For tracing, a program attaches to an instrumentation point, runs when the corresponding event occurs, and can record or aggregate the information needed for analysis.
It is not one tracing command or a single kind of probe. Available attachment points include static tracepoints and dynamic kernel function probes; tooling such as bpftrace also supports userspace probes and USDT (User Statically Defined Tracing). The right choice depends on the event, the hooks available on the host, and how you want to collect and analyze results.
How do I choose what to trace?
Start with a diagnostic question
Describe the behavior you want to explain before choosing a probe: for example, which operation is slow, how often a particular event occurs, or what a kernel function does during a workload. That narrows the search to instrumentation points that can observe the behavior directly.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall#1 Best Overall
Discover probes on the target host
Probe availability varies with the kernel, system configuration, architecture, symbols, BTF support, installed tools, and—in the case of userspace probes—the binary. Do not assume a probe name from another machine will exist locally. The bpftrace tutorial uses bpftrace -l to list probes; use the installed version’s listing and filtering options to look for candidates on the machine you intend to trace.
Choose the least fragile hook that answers the question
If a tracepoint exposes the event you need, it is usually a strong starting point. Tracepoints are defined instrumentation events, and the bpftrace tutorial recommends them over kprobes because they have a stable API. If no suitable tracepoint exists, a dynamic kernel function probe may be necessary; confirm that the function can be probed on the target kernel and account for the greater dependence on kernel implementation details.
Rank #2
What is the difference between a tracepoint and a kprobe?
| Instrumentation | What it hooks | When it is useful | Stability and availability |
|---|---|---|---|
| Tracepoint | A named kernel event designed for instrumentation. | When an exposed event corresponds to the operation you want to observe. | Preferred over a kprobe when it supplies the needed event, according to the bpftrace tutorial’s stability guidance. The available events still depend on the host. |
| Kprobe or kretprobe | A kernel function entry point or return point. | When the needed function behavior is not covered by a suitable tracepoint and the function is probeable. | Dynamic and host-dependent; confirm support and function availability on the target kernel rather than assuming a hook is portable. |
Both are ways to observe kernel activity, but they answer different questions: a tracepoint represents an event, while a function probe follows execution at a selected function boundary. Pick based on the information required, not on a blanket assumption that one probe type is always available.
How do I get started with bpftrace?
bpftrace is a tracing language and tool for short scripts and interactive exploration. Its documented providers include tracepoints, kprobes and kretprobes, uprobes and uretprobes, USDT, raw tracepoints, and kernel functions when BTF-supported tracing is available. Provider names and probe availability are system- and binary-dependent.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #3
- Define the question. Decide which event, function, or latency you need to observe and what information would answer the question.
- List local candidates. Run
bpftrace -lon the target system, then use the installed tool’s probe-pattern filtering to narrow the results. The bpftrace 0.22 documentation describes these providers; installed versions and host capabilities may differ. - Prefer a matching tracepoint. If a tracepoint captures the event, begin there. Use a kernel function probe only when the needed hook is otherwise unavailable and the target supports it.
- Collect only what you need. Filter events and aggregate close to the probe when appropriate, rather than collecting an unnecessarily large stream of raw data.
- Validate under the real workload. Check that the script observes the intended behavior and measure the effect of the instrumentation and collection path in the environment where it will run.
Successful attachment is not guaranteed by a script that works elsewhere: kernel configuration, permissions, architecture, symbols, BTF support, and bpftrace version can all affect what is available or succeeds.
When should I use libbpf instead?
Use libbpf when you are building a maintained custom BPF application and want an explicit C-based loader and lifecycle. The documented lifecycle covers opening a BPF object, loading it, attaching its programs, and tearing it down. Loading includes creating maps and asking the kernel to verify and load programs before they are attached.
libbpf supports CO-RE (Compile Once – Run Everywhere) workflows intended to help a program work across kernel versions. That is a portability aid, not a promise that every program runs on every kernel: required program types, attachment points, kernel features, and host capabilities still constrain deployment. The kernel’s program-type and ELF-section documentation maps program types and section conventions to attachment types, so check the current documentation and target capabilities rather than relying on a remembered section name.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How does eBPF compare with ftrace?
ftrace is a kernel tracing framework for function, latency, and event tracing, accessed through tracefs, commonly mounted at /sys/kernel/tracing. It can be enough to answer a kernel tracing question without writing an eBPF program; it can also complement eBPF when its existing controls or event points suit part of the investigation.
Recommended Free Tools
Best Value
| Approach | Good fit | What to check |
|---|---|---|
| bpftrace | Short exploratory scripts and quick investigation. | Whether the required probe exists on the host and whether the installed version supports it. |
| libbpf | A custom BPF application with an explicit loader, attachment, and teardown lifecycle. | Required kernel features, program types, attachment points, and portability constraints. |
| ftrace | Built-in function, latency, or event tracing that can be configured through tracefs. | Whether its available events and controls answer the diagnostic question without custom BPF code. |
Compare the approaches by event coverage, interface stability, setup and maintenance effort, required analysis, data volume, and measured effect in the workload. There is no basis here for a blanket performance ranking: the overhead depends on the chosen instrumentation and collection path, so measure it on the target system.
What limits portability and tracing overhead?
Portability is host-dependent
eBPF tracing is Linux-specific. Kernel versions and configuration, architecture, privileges, symbols, BTF support, installed tool versions, and binary-specific probes can all change which programs attach successfully. Check the actual target host and its current kernel documentation rather than treating a probe or section name as universal.
There is no universal overhead figure
A tracing program’s effect depends on what it attaches to, how often the event fires, what work the program performs, and how results are collected. The kernel documentation does not establish one numeric overhead that applies generally. Measure the selected instrumentation and collection path with the real workload, and keep only the data needed to answer the diagnostic question.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problems




