January 2018
Intermediate to advanced
456 pages
12h 49m
English
The kernel tracing system allows us to insert traces in the code by using the trace_printk function call. It has the same syntax as printk and can be used in the same scenarios, interrupts, NMI, or scheduler contexts.
Its advantage is that, as it prints to the tracing buffer in memory and not to the console, it has much lower delays than printk, so it is useful to debug scenarios where printk is affecting the system's behavior, for example, when masking a timing bug.
Tracing is enabled once a tracer is configured, but whether the trace writes to the ring buffer or not can be controlled:
$ echo 0 > /sys/kernel/debug/tracing/tracing_on
Read now
Unlock full access