Filtering function traces

You can get finer granularity in the functions being traced by using the dynamic tracer, which can be enabled with the CONFIG_DYNAMIC_FTRACE configuration variable. This is enabled with the tracing functionality by default. This adds two more files, set_ftrace_filter and set_ftrace_notrace. Adding functions to set_ftrace_filter will trace only those functions, and adding them to set_ftrace_notrace will not trace them, even if they are also added to set_ftrace_filter.

The set of available function names that can be filtered may be obtained by executing the following command:

$ cat /sys/kernel/debug/tracing/available_filter_functions  

Functions can be added with the following command:

$ echo -n <function_name> >>  
/sys/kernel/debug/tracing/set_ftrace_filter

Note that we use the concatenation operator (>>) so that the new function is appended to the existing ones.

Functions can also be removed with the following:

$ echo -n '!<function>' >>  /sys/kernel/debug/tracing/set_ftrace_filter  

To remove all functions, just echo a blank line into the file:

$ echo > /sys/kernel/debug/tracing/set_ftrace_filter  

There is a special syntax that adds extra flexibility to the filtering:

<function>:<command>:[<parameter>]  

Let's explain each of the components individually:

  • function: This specifies the function name. Wildcards are allowed.
  • command: This has the following attributes:
    • mod: This enables the given function name only in the module specified in the parameter command
    • traceon/traceoff: This enables or disables tracing when the specified function is hit the number of times given in the parameter, or always if no parameter is given
    • dump: This dumps the contents of the tracing buffer when the given function is hit

Here are some examples:

$ echo -n 'ipu_*:mod:ipu' > 
/sys/kernel/debug/tracing/set_ftrace_filter
$ echo -n 'suspend_enter:dump' >
/sys/kernel/debug/tracing/set_ftrace_filter
$ echo -n 'suspend_enter:traceon' >
/sys/kernel/debug/tracing/set_ftrace_filter
..................Content has been hidden....................

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