ftrace event counters

This topic describes the data that gatord reads from the host ftrace event counters.

The data that is stored in an ftrace tracepoint event can also be read as each event is emitted. Each trace event accessible by perf has a self-defining binary structure, which is defined by /sys/kernel/debug/tracing/events/<group>/<event>/format. The counter is read from the field in this binary structure that is defined by the arg attribute in the event XML.

ftrace event counters use the event XML syntax that is shown in this example:

<?xml version="1.0" encoding="UTF-8"?>
<events>
<category name="Ftrace">
  <event counter="ftrace_power_cpu_idle"
         tracepoint="power/cpu_idle"
         arg="state"
         title="Power"
         name="cpu_idle"
         regex="cpu_idle"
         description="Number of times cpu_idle is entered or exited" />
</category>
</events>

The XML syntax for ftrace events include the following attributes:

counter

The counter attribute must be a unique identifier code, and must begin with the ftrace_ prefix.

tracepoint

The tracepoint attribute is the source ftrace event that you want to use. Specify tracepoint in the form <group>/<event>, which equates to the path /sys/kernel/debug/tracing/events/<group>/<event> where the tracepoint is defined.

arg

The optional arg attribute is used with tracepoint to extract a specified counter value from each tracepoint event, otherwise the number of events is counted.

regex

The regex value is used to either count the number of times a tracepoint is seen, or extracts an argument attribute to use as a counter value.

To filter this event by thread, add per_cpu="yes" proc="yes" to the event xml. The tracepoint must correctly report the pid associated with the event as part of the tracepoint common fields.

Attribute behavior with the efficient ftrace collection option

The behavior of the tracepoint, and regex attributes depends on if you are using the efficient ftrace option.

When the Use more efficient Ftrace collection checkbox is selected, and arg is not set, tracepoint identifies the tracepoint name and counts the number of times that it is seen. If arg is set, the specified argument attribute is used as the counter value for each data point.

When the Use more efficient Ftrace collection checkbox is cleared, regex is used to match with the ftrace log text. regex must be in one of the following formats:

  • tracepoint_name:.* to count the number of times a tracepoint is seen

  • tracepoint_name:.*arg=([0-9]+).* to extract an argument attribute as the counter value

Note

  • You can only generate one Streamline counter per tracepoint.

  • The event XML must contain tracepoint and regex, but arg is optional. If regex is used to capture an arg value, and arg is not specified in your event XML, the output is determined by whether you are using efficient ftrace collection..