Kprobes
Kprobes lets you break into any kernel instruction address and run a custom handler when execution reaches that point. The technique is non-disruptive — the running kernel is not stopped and other CPUs continue executing.How kprobes works
- You register a probe on a symbol or address.
- The kernel replaces the target instruction with a trap.
- When the trap fires, the kprobe handler runs in the same context as the interrupted code.
- The kernel restores the original instruction and continues execution.
- Tracing scheduler events (
schedule(),try_to_wake_up()) - Counting how often a slow code path is taken
- Capturing call arguments without adding
printkand rebuilding
Kconfig
Kprobe trace events via tracefs
The easiest way to use kprobes is through the tracefskprobe_events interface:
Ftrace
Ftrace is the kernel’s built-in function tracer. It can record every function call in the kernel, trace specific subsystems, or profile latency-sensitive code paths. Results are read from the tracefs interface (/sys/kernel/tracing/).
Function tracer
Thefunction tracer records the name and CPU of every kernel function called:
Function graph tracer
Thefunction_graph tracer records entry and exit of each function, including
execution time. Useful for identifying slow code paths:
Trace boot initcalls
Add to the kernel command line to trace all initcalls at boot:MMIO trace events
Memory-mapped I/O (MMIO) traces record every register read and write performed by the kernel, using__raw_{read,write}{b,l,w,q} accessors. They are
essential for diagnosing the following crash categories on Qualcomm® SoCs:
Table: MMIO crash scenarios
Enable MMIO traces
Kconfig:rwmmio trace events via tracefs:
readl/writel/writeq), and the physical address. Cross-reference the
address against the SoC Technical Reference Manual to identify the register
block involved in a crash.

