There's more...

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:

  1. To disable writing to the buffer, use the following command:
$ echo 0 > /sys/kernel/debug/tracing/tracing_on  
  1. And to re-enable it, use the following command:
$ echo 1 > /sys/kernel/debug/tracing/tracing_on  

You can also enable and disable tracing from kernel space by using the tracing_on and tracing_off functions.

Inserted traces will appear in any tracer, including the function tracer, in which case it will appear as a comment.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset