Ftrace

This page has information about ftrace, that I couldn't find elsewhere.

Tracing a specific process
(Adapted from email by Steven Rostedt) To trace just the kernel functions executed in the context of a particular function, set the pseudo-variable 'set-ftrace-pid', to the process id (pid) of the process.

If the process is not already running, you can use a wrapper shell script and the 'exec' command, to execute a command as a known pid.

Like so: echo $$ > /debug/tracing/set_ftrace_pid echo function > /debug/tracing/current_tracer exec $*
 * 1) !/bin/sh
 * 1) can set other filtering here

In this example, '$$' is the pid of the currently executing process (the shell script. This is set into the 'set_ftrace_pid' variable, then the 'function' tracer is enabled.  Then this script exec's the command (specified by the first argument to the script).

Example usage (assuming script is called 'trace_cmd'): trace_cmd ls