1ea272257SMauro Carvalho Chehab================
2ea272257SMauro Carvalho ChehabEvent Histograms
3ea272257SMauro Carvalho Chehab================
4ea272257SMauro Carvalho Chehab
5ea272257SMauro Carvalho ChehabDocumentation written by Tom Zanussi
6ea272257SMauro Carvalho Chehab
7ea272257SMauro Carvalho Chehab1. Introduction
8ea272257SMauro Carvalho Chehab===============
9ea272257SMauro Carvalho Chehab
10ea272257SMauro Carvalho Chehab  Histogram triggers are special event triggers that can be used to
11ea272257SMauro Carvalho Chehab  aggregate trace event data into histograms.  For information on
12ea272257SMauro Carvalho Chehab  trace events and event triggers, see Documentation/trace/events.rst.
13ea272257SMauro Carvalho Chehab
14ea272257SMauro Carvalho Chehab
15ea272257SMauro Carvalho Chehab2. Histogram Trigger Command
16ea272257SMauro Carvalho Chehab============================
17ea272257SMauro Carvalho Chehab
18ea272257SMauro Carvalho Chehab  A histogram trigger command is an event trigger command that
19ea272257SMauro Carvalho Chehab  aggregates event hits into a hash table keyed on one or more trace
20ea272257SMauro Carvalho Chehab  event format fields (or stacktrace) and a set of running totals
21ea272257SMauro Carvalho Chehab  derived from one or more trace event format fields and/or event
22ea272257SMauro Carvalho Chehab  counts (hitcount).
23ea272257SMauro Carvalho Chehab
24ea272257SMauro Carvalho Chehab  The format of a hist trigger is as follows::
25ea272257SMauro Carvalho Chehab
26ea272257SMauro Carvalho Chehab        hist:keys=<field1[,field2,...]>[:values=<field1[,field2,...]>]
27ea272257SMauro Carvalho Chehab          [:sort=<field1[,field2,...]>][:size=#entries][:pause][:continue]
285032b381STom Zanussi          [:clear][:name=histname1][:<handler>.<action>] [if <filter>]
29ea272257SMauro Carvalho Chehab
30ea272257SMauro Carvalho Chehab  When a matching event is hit, an entry is added to a hash table
31ea272257SMauro Carvalho Chehab  using the key(s) and value(s) named.  Keys and values correspond to
32ea272257SMauro Carvalho Chehab  fields in the event's format description.  Values must correspond to
33ea272257SMauro Carvalho Chehab  numeric fields - on an event hit, the value(s) will be added to a
34ea272257SMauro Carvalho Chehab  sum kept for that field.  The special string 'hitcount' can be used
35ea272257SMauro Carvalho Chehab  in place of an explicit value field - this is simply a count of
36ea272257SMauro Carvalho Chehab  event hits.  If 'values' isn't specified, an implicit 'hitcount'
37ea272257SMauro Carvalho Chehab  value will be automatically created and used as the only value.
38ea272257SMauro Carvalho Chehab  Keys can be any field, or the special string 'stacktrace', which
39ea272257SMauro Carvalho Chehab  will use the event's kernel stacktrace as the key.  The keywords
40ea272257SMauro Carvalho Chehab  'keys' or 'key' can be used to specify keys, and the keywords
41ea272257SMauro Carvalho Chehab  'values', 'vals', or 'val' can be used to specify values.  Compound
42ea272257SMauro Carvalho Chehab  keys consisting of up to two fields can be specified by the 'keys'
43ea272257SMauro Carvalho Chehab  keyword.  Hashing a compound key produces a unique entry in the
44ea272257SMauro Carvalho Chehab  table for each unique combination of component keys, and can be
45ea272257SMauro Carvalho Chehab  useful for providing more fine-grained summaries of event data.
46ea272257SMauro Carvalho Chehab  Additionally, sort keys consisting of up to two fields can be
47ea272257SMauro Carvalho Chehab  specified by the 'sort' keyword.  If more than one field is
48ea272257SMauro Carvalho Chehab  specified, the result will be a 'sort within a sort': the first key
49ea272257SMauro Carvalho Chehab  is taken to be the primary sort key and the second the secondary
50ea272257SMauro Carvalho Chehab  key.  If a hist trigger is given a name using the 'name' parameter,
51ea272257SMauro Carvalho Chehab  its histogram data will be shared with other triggers of the same
52ea272257SMauro Carvalho Chehab  name, and trigger hits will update this common data.  Only triggers
53ea272257SMauro Carvalho Chehab  with 'compatible' fields can be combined in this way; triggers are
54ea272257SMauro Carvalho Chehab  'compatible' if the fields named in the trigger share the same
55ea272257SMauro Carvalho Chehab  number and type of fields and those fields also have the same names.
56ea272257SMauro Carvalho Chehab  Note that any two events always share the compatible 'hitcount' and
57ea272257SMauro Carvalho Chehab  'stacktrace' fields and can therefore be combined using those
58ea272257SMauro Carvalho Chehab  fields, however pointless that may be.
59ea272257SMauro Carvalho Chehab
60ea272257SMauro Carvalho Chehab  'hist' triggers add a 'hist' file to each event's subdirectory.
61ea272257SMauro Carvalho Chehab  Reading the 'hist' file for the event will dump the hash table in
62ea272257SMauro Carvalho Chehab  its entirety to stdout.  If there are multiple hist triggers
63ea272257SMauro Carvalho Chehab  attached to an event, there will be a table for each trigger in the
64ea272257SMauro Carvalho Chehab  output.  The table displayed for a named trigger will be the same as
65ea272257SMauro Carvalho Chehab  any other instance having the same name. Each printed hash table
66ea272257SMauro Carvalho Chehab  entry is a simple list of the keys and values comprising the entry;
67ea272257SMauro Carvalho Chehab  keys are printed first and are delineated by curly braces, and are
68ea272257SMauro Carvalho Chehab  followed by the set of value fields for the entry.  By default,
69ea272257SMauro Carvalho Chehab  numeric fields are displayed as base-10 integers.  This can be
70ea272257SMauro Carvalho Chehab  modified by appending any of the following modifiers to the field
71ea272257SMauro Carvalho Chehab  name:
72ea272257SMauro Carvalho Chehab
73ea272257SMauro Carvalho Chehab	=========== ==========================================
74ea272257SMauro Carvalho Chehab        .hex        display a number as a hex value
75ea272257SMauro Carvalho Chehab	.sym        display an address as a symbol
76ea272257SMauro Carvalho Chehab	.sym-offset display an address as a symbol and offset
77ea272257SMauro Carvalho Chehab	.syscall    display a syscall id as a system call name
78ea272257SMauro Carvalho Chehab	.execname   display a common_pid as a program name
79ea272257SMauro Carvalho Chehab	.log2       display log2 value rather than raw number
80ea272257SMauro Carvalho Chehab	.usecs      display a common_timestamp in microseconds
81ea272257SMauro Carvalho Chehab	=========== ==========================================
82ea272257SMauro Carvalho Chehab
83ea272257SMauro Carvalho Chehab  Note that in general the semantics of a given field aren't
84ea272257SMauro Carvalho Chehab  interpreted when applying a modifier to it, but there are some
85ea272257SMauro Carvalho Chehab  restrictions to be aware of in this regard:
86ea272257SMauro Carvalho Chehab
87ea272257SMauro Carvalho Chehab    - only the 'hex' modifier can be used for values (because values
88ea272257SMauro Carvalho Chehab      are essentially sums, and the other modifiers don't make sense
89ea272257SMauro Carvalho Chehab      in that context).
90ea272257SMauro Carvalho Chehab    - the 'execname' modifier can only be used on a 'common_pid'.  The
91ea272257SMauro Carvalho Chehab      reason for this is that the execname is simply the 'comm' value
92ea272257SMauro Carvalho Chehab      saved for the 'current' process when an event was triggered,
93ea272257SMauro Carvalho Chehab      which is the same as the common_pid value saved by the event
94ea272257SMauro Carvalho Chehab      tracing code.  Trying to apply that comm value to other pid
95ea272257SMauro Carvalho Chehab      values wouldn't be correct, and typically events that care save
96ea272257SMauro Carvalho Chehab      pid-specific comm fields in the event itself.
97ea272257SMauro Carvalho Chehab
98ea272257SMauro Carvalho Chehab  A typical usage scenario would be the following to enable a hist
99ea272257SMauro Carvalho Chehab  trigger, read its current contents, and then turn it off::
100ea272257SMauro Carvalho Chehab
101ea272257SMauro Carvalho Chehab    # echo 'hist:keys=skbaddr.hex:vals=len' > \
102ea272257SMauro Carvalho Chehab      /sys/kernel/debug/tracing/events/net/netif_rx/trigger
103ea272257SMauro Carvalho Chehab
104ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/net/netif_rx/hist
105ea272257SMauro Carvalho Chehab
106ea272257SMauro Carvalho Chehab    # echo '!hist:keys=skbaddr.hex:vals=len' > \
107ea272257SMauro Carvalho Chehab      /sys/kernel/debug/tracing/events/net/netif_rx/trigger
108ea272257SMauro Carvalho Chehab
109ea272257SMauro Carvalho Chehab  The trigger file itself can be read to show the details of the
110ea272257SMauro Carvalho Chehab  currently attached hist trigger.  This information is also displayed
111ea272257SMauro Carvalho Chehab  at the top of the 'hist' file when read.
112ea272257SMauro Carvalho Chehab
113ea272257SMauro Carvalho Chehab  By default, the size of the hash table is 2048 entries.  The 'size'
114ea272257SMauro Carvalho Chehab  parameter can be used to specify more or fewer than that.  The units
115ea272257SMauro Carvalho Chehab  are in terms of hashtable entries - if a run uses more entries than
116ea272257SMauro Carvalho Chehab  specified, the results will show the number of 'drops', the number
117ea272257SMauro Carvalho Chehab  of hits that were ignored.  The size should be a power of 2 between
118ea272257SMauro Carvalho Chehab  128 and 131072 (any non- power-of-2 number specified will be rounded
119ea272257SMauro Carvalho Chehab  up).
120ea272257SMauro Carvalho Chehab
121ea272257SMauro Carvalho Chehab  The 'sort' parameter can be used to specify a value field to sort
122ea272257SMauro Carvalho Chehab  on.  The default if unspecified is 'hitcount' and the default sort
123ea272257SMauro Carvalho Chehab  order is 'ascending'.  To sort in the opposite direction, append
124ea272257SMauro Carvalho Chehab  .descending' to the sort key.
125ea272257SMauro Carvalho Chehab
126ea272257SMauro Carvalho Chehab  The 'pause' parameter can be used to pause an existing hist trigger
127ea272257SMauro Carvalho Chehab  or to start a hist trigger but not log any events until told to do
128ea272257SMauro Carvalho Chehab  so.  'continue' or 'cont' can be used to start or restart a paused
129ea272257SMauro Carvalho Chehab  hist trigger.
130ea272257SMauro Carvalho Chehab
131ea272257SMauro Carvalho Chehab  The 'clear' parameter will clear the contents of a running hist
132ea272257SMauro Carvalho Chehab  trigger and leave its current paused/active state.
133ea272257SMauro Carvalho Chehab
134ea272257SMauro Carvalho Chehab  Note that the 'pause', 'cont', and 'clear' parameters should be
135ea272257SMauro Carvalho Chehab  applied using 'append' shell operator ('>>') if applied to an
136ea272257SMauro Carvalho Chehab  existing trigger, rather than via the '>' operator, which will cause
137ea272257SMauro Carvalho Chehab  the trigger to be removed through truncation.
138ea272257SMauro Carvalho Chehab
139ea272257SMauro Carvalho Chehab- enable_hist/disable_hist
140ea272257SMauro Carvalho Chehab
141ea272257SMauro Carvalho Chehab  The enable_hist and disable_hist triggers can be used to have one
142ea272257SMauro Carvalho Chehab  event conditionally start and stop another event's already-attached
143ea272257SMauro Carvalho Chehab  hist trigger.  Any number of enable_hist and disable_hist triggers
144ea272257SMauro Carvalho Chehab  can be attached to a given event, allowing that event to kick off
145ea272257SMauro Carvalho Chehab  and stop aggregations on a host of other events.
146ea272257SMauro Carvalho Chehab
147ea272257SMauro Carvalho Chehab  The format is very similar to the enable/disable_event triggers::
148ea272257SMauro Carvalho Chehab
149ea272257SMauro Carvalho Chehab      enable_hist:<system>:<event>[:count]
150ea272257SMauro Carvalho Chehab      disable_hist:<system>:<event>[:count]
151ea272257SMauro Carvalho Chehab
152ea272257SMauro Carvalho Chehab  Instead of enabling or disabling the tracing of the target event
153ea272257SMauro Carvalho Chehab  into the trace buffer as the enable/disable_event triggers do, the
154ea272257SMauro Carvalho Chehab  enable/disable_hist triggers enable or disable the aggregation of
155ea272257SMauro Carvalho Chehab  the target event into a hash table.
156ea272257SMauro Carvalho Chehab
157ea272257SMauro Carvalho Chehab  A typical usage scenario for the enable_hist/disable_hist triggers
158ea272257SMauro Carvalho Chehab  would be to first set up a paused hist trigger on some event,
159ea272257SMauro Carvalho Chehab  followed by an enable_hist/disable_hist pair that turns the hist
160ea272257SMauro Carvalho Chehab  aggregation on and off when conditions of interest are hit::
161ea272257SMauro Carvalho Chehab
162ea272257SMauro Carvalho Chehab   # echo 'hist:keys=skbaddr.hex:vals=len:pause' > \
163ea272257SMauro Carvalho Chehab      /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
164ea272257SMauro Carvalho Chehab
165ea272257SMauro Carvalho Chehab    # echo 'enable_hist:net:netif_receive_skb if filename==/usr/bin/wget' > \
166ea272257SMauro Carvalho Chehab      /sys/kernel/debug/tracing/events/sched/sched_process_exec/trigger
167ea272257SMauro Carvalho Chehab
168ea272257SMauro Carvalho Chehab    # echo 'disable_hist:net:netif_receive_skb if comm==wget' > \
169ea272257SMauro Carvalho Chehab      /sys/kernel/debug/tracing/events/sched/sched_process_exit/trigger
170ea272257SMauro Carvalho Chehab
171ea272257SMauro Carvalho Chehab  The above sets up an initially paused hist trigger which is unpaused
172ea272257SMauro Carvalho Chehab  and starts aggregating events when a given program is executed, and
173ea272257SMauro Carvalho Chehab  which stops aggregating when the process exits and the hist trigger
174ea272257SMauro Carvalho Chehab  is paused again.
175ea272257SMauro Carvalho Chehab
176ea272257SMauro Carvalho Chehab  The examples below provide a more concrete illustration of the
177ea272257SMauro Carvalho Chehab  concepts and typical usage patterns discussed above.
178ea272257SMauro Carvalho Chehab
179ea272257SMauro Carvalho Chehab'special' event fields
180ea272257SMauro Carvalho Chehab------------------------
181ea272257SMauro Carvalho Chehab
182ea272257SMauro Carvalho Chehab  There are a number of 'special event fields' available for use as
183ea272257SMauro Carvalho Chehab  keys or values in a hist trigger.  These look like and behave as if
184ea272257SMauro Carvalho Chehab  they were actual event fields, but aren't really part of the event's
185ea272257SMauro Carvalho Chehab  field definition or format file.  They are however available for any
186ea272257SMauro Carvalho Chehab  event, and can be used anywhere an actual event field could be.
187ea272257SMauro Carvalho Chehab  They are:
188ea272257SMauro Carvalho Chehab
189ea272257SMauro Carvalho Chehab    ====================== ==== =======================================
190ea272257SMauro Carvalho Chehab    common_timestamp       u64  timestamp (from ring buffer) associated
191ea272257SMauro Carvalho Chehab                                with the event, in nanoseconds.  May be
192ea272257SMauro Carvalho Chehab			        modified by .usecs to have timestamps
193ea272257SMauro Carvalho Chehab			        interpreted as microseconds.
194ea272257SMauro Carvalho Chehab    cpu                    int  the cpu on which the event occurred.
195ea272257SMauro Carvalho Chehab    ====================== ==== =======================================
196ea272257SMauro Carvalho Chehab
197ea272257SMauro Carvalho ChehabExtended error information
198ea272257SMauro Carvalho Chehab--------------------------
199ea272257SMauro Carvalho Chehab
200ea272257SMauro Carvalho Chehab  For some error conditions encountered when invoking a hist trigger
201ea272257SMauro Carvalho Chehab  command, extended error information is available via the
202ea272257SMauro Carvalho Chehab  corresponding event's 'hist' file.  Reading the hist file after an
203ea272257SMauro Carvalho Chehab  error will display more detailed information about what went wrong,
204ea272257SMauro Carvalho Chehab  if information is available.  This extended error information will
205ea272257SMauro Carvalho Chehab  be available until the next hist trigger command for that event.
206ea272257SMauro Carvalho Chehab
207ea272257SMauro Carvalho Chehab  If available for a given error condition, the extended error
208ea272257SMauro Carvalho Chehab  information and usage takes the following form::
209ea272257SMauro Carvalho Chehab
210ea272257SMauro Carvalho Chehab    # echo xxx > /sys/kernel/debug/tracing/events/sched/sched_wakeup/trigger
211ea272257SMauro Carvalho Chehab    echo: write error: Invalid argument
212ea272257SMauro Carvalho Chehab
213ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/sched/sched_wakeup/hist
214ea272257SMauro Carvalho Chehab    ERROR: Couldn't yyy: zzz
215ea272257SMauro Carvalho Chehab      Last command: xxx
216ea272257SMauro Carvalho Chehab
217ea272257SMauro Carvalho Chehab6.2 'hist' trigger examples
218ea272257SMauro Carvalho Chehab---------------------------
219ea272257SMauro Carvalho Chehab
220ea272257SMauro Carvalho Chehab  The first set of examples creates aggregations using the kmalloc
221ea272257SMauro Carvalho Chehab  event.  The fields that can be used for the hist trigger are listed
222ea272257SMauro Carvalho Chehab  in the kmalloc event's format file::
223ea272257SMauro Carvalho Chehab
224ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/format
225ea272257SMauro Carvalho Chehab    name: kmalloc
226ea272257SMauro Carvalho Chehab    ID: 374
227ea272257SMauro Carvalho Chehab    format:
228ea272257SMauro Carvalho Chehab	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
229ea272257SMauro Carvalho Chehab	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
230ea272257SMauro Carvalho Chehab	field:unsigned char common_preempt_count;		offset:3;	size:1;	signed:0;
231ea272257SMauro Carvalho Chehab	field:int common_pid;					offset:4;	size:4;	signed:1;
232ea272257SMauro Carvalho Chehab
233ea272257SMauro Carvalho Chehab	field:unsigned long call_site;				offset:8;	size:8;	signed:0;
234ea272257SMauro Carvalho Chehab	field:const void * ptr;					offset:16;	size:8;	signed:0;
235ea272257SMauro Carvalho Chehab	field:size_t bytes_req;					offset:24;	size:8;	signed:0;
236ea272257SMauro Carvalho Chehab	field:size_t bytes_alloc;				offset:32;	size:8;	signed:0;
237ea272257SMauro Carvalho Chehab	field:gfp_t gfp_flags;					offset:40;	size:4;	signed:0;
238ea272257SMauro Carvalho Chehab
239ea272257SMauro Carvalho Chehab  We'll start by creating a hist trigger that generates a simple table
240ea272257SMauro Carvalho Chehab  that lists the total number of bytes requested for each function in
241ea272257SMauro Carvalho Chehab  the kernel that made one or more calls to kmalloc::
242ea272257SMauro Carvalho Chehab
243ea272257SMauro Carvalho Chehab    # echo 'hist:key=call_site:val=bytes_req' > \
244ea272257SMauro Carvalho Chehab            /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger
245ea272257SMauro Carvalho Chehab
246ea272257SMauro Carvalho Chehab  This tells the tracing system to create a 'hist' trigger using the
247ea272257SMauro Carvalho Chehab  call_site field of the kmalloc event as the key for the table, which
248ea272257SMauro Carvalho Chehab  just means that each unique call_site address will have an entry
249ea272257SMauro Carvalho Chehab  created for it in the table.  The 'val=bytes_req' parameter tells
250ea272257SMauro Carvalho Chehab  the hist trigger that for each unique entry (call_site) in the
251ea272257SMauro Carvalho Chehab  table, it should keep a running total of the number of bytes
252ea272257SMauro Carvalho Chehab  requested by that call_site.
253ea272257SMauro Carvalho Chehab
254ea272257SMauro Carvalho Chehab  We'll let it run for awhile and then dump the contents of the 'hist'
255ea272257SMauro Carvalho Chehab  file in the kmalloc event's subdirectory (for readability, a number
256ea272257SMauro Carvalho Chehab  of entries have been omitted)::
257ea272257SMauro Carvalho Chehab
258ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist
259ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=call_site:vals=bytes_req:sort=hitcount:size=2048 [active]
260ea272257SMauro Carvalho Chehab
261ea272257SMauro Carvalho Chehab    { call_site: 18446744072106379007 } hitcount:          1  bytes_req:        176
262ea272257SMauro Carvalho Chehab    { call_site: 18446744071579557049 } hitcount:          1  bytes_req:       1024
263ea272257SMauro Carvalho Chehab    { call_site: 18446744071580608289 } hitcount:          1  bytes_req:      16384
264ea272257SMauro Carvalho Chehab    { call_site: 18446744071581827654 } hitcount:          1  bytes_req:         24
265ea272257SMauro Carvalho Chehab    { call_site: 18446744071580700980 } hitcount:          1  bytes_req:          8
266ea272257SMauro Carvalho Chehab    { call_site: 18446744071579359876 } hitcount:          1  bytes_req:        152
267ea272257SMauro Carvalho Chehab    { call_site: 18446744071580795365 } hitcount:          3  bytes_req:        144
268ea272257SMauro Carvalho Chehab    { call_site: 18446744071581303129 } hitcount:          3  bytes_req:        144
269ea272257SMauro Carvalho Chehab    { call_site: 18446744071580713234 } hitcount:          4  bytes_req:       2560
270ea272257SMauro Carvalho Chehab    { call_site: 18446744071580933750 } hitcount:          4  bytes_req:        736
271ea272257SMauro Carvalho Chehab    .
272ea272257SMauro Carvalho Chehab    .
273ea272257SMauro Carvalho Chehab    .
274ea272257SMauro Carvalho Chehab    { call_site: 18446744072106047046 } hitcount:         69  bytes_req:       5576
275ea272257SMauro Carvalho Chehab    { call_site: 18446744071582116407 } hitcount:         73  bytes_req:       2336
276ea272257SMauro Carvalho Chehab    { call_site: 18446744072106054684 } hitcount:        136  bytes_req:     140504
277ea272257SMauro Carvalho Chehab    { call_site: 18446744072106224230 } hitcount:        136  bytes_req:      19584
278ea272257SMauro Carvalho Chehab    { call_site: 18446744072106078074 } hitcount:        153  bytes_req:       2448
279ea272257SMauro Carvalho Chehab    { call_site: 18446744072106062406 } hitcount:        153  bytes_req:      36720
280ea272257SMauro Carvalho Chehab    { call_site: 18446744071582507929 } hitcount:        153  bytes_req:      37088
281ea272257SMauro Carvalho Chehab    { call_site: 18446744072102520590 } hitcount:        273  bytes_req:      10920
282ea272257SMauro Carvalho Chehab    { call_site: 18446744071582143559 } hitcount:        358  bytes_req:        716
283ea272257SMauro Carvalho Chehab    { call_site: 18446744072106465852 } hitcount:        417  bytes_req:      56712
284ea272257SMauro Carvalho Chehab    { call_site: 18446744072102523378 } hitcount:        485  bytes_req:      27160
285ea272257SMauro Carvalho Chehab    { call_site: 18446744072099568646 } hitcount:       1676  bytes_req:      33520
286ea272257SMauro Carvalho Chehab
287ea272257SMauro Carvalho Chehab    Totals:
288ea272257SMauro Carvalho Chehab        Hits: 4610
289ea272257SMauro Carvalho Chehab        Entries: 45
290ea272257SMauro Carvalho Chehab        Dropped: 0
291ea272257SMauro Carvalho Chehab
292ea272257SMauro Carvalho Chehab  The output displays a line for each entry, beginning with the key
293ea272257SMauro Carvalho Chehab  specified in the trigger, followed by the value(s) also specified in
294ea272257SMauro Carvalho Chehab  the trigger.  At the beginning of the output is a line that displays
295ea272257SMauro Carvalho Chehab  the trigger info, which can also be displayed by reading the
296ea272257SMauro Carvalho Chehab  'trigger' file::
297ea272257SMauro Carvalho Chehab
298ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger
299ea272257SMauro Carvalho Chehab    hist:keys=call_site:vals=bytes_req:sort=hitcount:size=2048 [active]
300ea272257SMauro Carvalho Chehab
301ea272257SMauro Carvalho Chehab  At the end of the output are a few lines that display the overall
302ea272257SMauro Carvalho Chehab  totals for the run.  The 'Hits' field shows the total number of
303ea272257SMauro Carvalho Chehab  times the event trigger was hit, the 'Entries' field shows the total
304ea272257SMauro Carvalho Chehab  number of used entries in the hash table, and the 'Dropped' field
305ea272257SMauro Carvalho Chehab  shows the number of hits that were dropped because the number of
306ea272257SMauro Carvalho Chehab  used entries for the run exceeded the maximum number of entries
307ea272257SMauro Carvalho Chehab  allowed for the table (normally 0, but if not a hint that you may
308ea272257SMauro Carvalho Chehab  want to increase the size of the table using the 'size' parameter).
309ea272257SMauro Carvalho Chehab
310ea272257SMauro Carvalho Chehab  Notice in the above output that there's an extra field, 'hitcount',
311ea272257SMauro Carvalho Chehab  which wasn't specified in the trigger.  Also notice that in the
312ea272257SMauro Carvalho Chehab  trigger info output, there's a parameter, 'sort=hitcount', which
313ea272257SMauro Carvalho Chehab  wasn't specified in the trigger either.  The reason for that is that
314ea272257SMauro Carvalho Chehab  every trigger implicitly keeps a count of the total number of hits
315ea272257SMauro Carvalho Chehab  attributed to a given entry, called the 'hitcount'.  That hitcount
316ea272257SMauro Carvalho Chehab  information is explicitly displayed in the output, and in the
317ea272257SMauro Carvalho Chehab  absence of a user-specified sort parameter, is used as the default
318ea272257SMauro Carvalho Chehab  sort field.
319ea272257SMauro Carvalho Chehab
320ea272257SMauro Carvalho Chehab  The value 'hitcount' can be used in place of an explicit value in
321ea272257SMauro Carvalho Chehab  the 'values' parameter if you don't really need to have any
322ea272257SMauro Carvalho Chehab  particular field summed and are mainly interested in hit
323ea272257SMauro Carvalho Chehab  frequencies.
324ea272257SMauro Carvalho Chehab
325ea272257SMauro Carvalho Chehab  To turn the hist trigger off, simply call up the trigger in the
326ea272257SMauro Carvalho Chehab  command history and re-execute it with a '!' prepended::
327ea272257SMauro Carvalho Chehab
328ea272257SMauro Carvalho Chehab    # echo '!hist:key=call_site:val=bytes_req' > \
329ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger
330ea272257SMauro Carvalho Chehab
331ea272257SMauro Carvalho Chehab  Finally, notice that the call_site as displayed in the output above
332ea272257SMauro Carvalho Chehab  isn't really very useful.  It's an address, but normally addresses
333ea272257SMauro Carvalho Chehab  are displayed in hex.  To have a numeric field displayed as a hex
334ea272257SMauro Carvalho Chehab  value, simply append '.hex' to the field name in the trigger::
335ea272257SMauro Carvalho Chehab
336ea272257SMauro Carvalho Chehab    # echo 'hist:key=call_site.hex:val=bytes_req' > \
337ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger
338ea272257SMauro Carvalho Chehab
339ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist
340ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=call_site.hex:vals=bytes_req:sort=hitcount:size=2048 [active]
341ea272257SMauro Carvalho Chehab
342ea272257SMauro Carvalho Chehab    { call_site: ffffffffa026b291 } hitcount:          1  bytes_req:        433
343ea272257SMauro Carvalho Chehab    { call_site: ffffffffa07186ff } hitcount:          1  bytes_req:        176
344ea272257SMauro Carvalho Chehab    { call_site: ffffffff811ae721 } hitcount:          1  bytes_req:      16384
345ea272257SMauro Carvalho Chehab    { call_site: ffffffff811c5134 } hitcount:          1  bytes_req:          8
346ea272257SMauro Carvalho Chehab    { call_site: ffffffffa04a9ebb } hitcount:          1  bytes_req:        511
347ea272257SMauro Carvalho Chehab    { call_site: ffffffff8122e0a6 } hitcount:          1  bytes_req:         12
348ea272257SMauro Carvalho Chehab    { call_site: ffffffff8107da84 } hitcount:          1  bytes_req:        152
349ea272257SMauro Carvalho Chehab    { call_site: ffffffff812d8246 } hitcount:          1  bytes_req:         24
350ea272257SMauro Carvalho Chehab    { call_site: ffffffff811dc1e5 } hitcount:          3  bytes_req:        144
351ea272257SMauro Carvalho Chehab    { call_site: ffffffffa02515e8 } hitcount:          3  bytes_req:        648
352ea272257SMauro Carvalho Chehab    { call_site: ffffffff81258159 } hitcount:          3  bytes_req:        144
353ea272257SMauro Carvalho Chehab    { call_site: ffffffff811c80f4 } hitcount:          4  bytes_req:        544
354ea272257SMauro Carvalho Chehab    .
355ea272257SMauro Carvalho Chehab    .
356ea272257SMauro Carvalho Chehab    .
357ea272257SMauro Carvalho Chehab    { call_site: ffffffffa06c7646 } hitcount:        106  bytes_req:       8024
358ea272257SMauro Carvalho Chehab    { call_site: ffffffffa06cb246 } hitcount:        132  bytes_req:      31680
359ea272257SMauro Carvalho Chehab    { call_site: ffffffffa06cef7a } hitcount:        132  bytes_req:       2112
360ea272257SMauro Carvalho Chehab    { call_site: ffffffff8137e399 } hitcount:        132  bytes_req:      23232
361ea272257SMauro Carvalho Chehab    { call_site: ffffffffa06c941c } hitcount:        185  bytes_req:     171360
362ea272257SMauro Carvalho Chehab    { call_site: ffffffffa06f2a66 } hitcount:        185  bytes_req:      26640
363ea272257SMauro Carvalho Chehab    { call_site: ffffffffa036a70e } hitcount:        265  bytes_req:      10600
364ea272257SMauro Carvalho Chehab    { call_site: ffffffff81325447 } hitcount:        292  bytes_req:        584
365ea272257SMauro Carvalho Chehab    { call_site: ffffffffa072da3c } hitcount:        446  bytes_req:      60656
366ea272257SMauro Carvalho Chehab    { call_site: ffffffffa036b1f2 } hitcount:        526  bytes_req:      29456
367ea272257SMauro Carvalho Chehab    { call_site: ffffffffa0099c06 } hitcount:       1780  bytes_req:      35600
368ea272257SMauro Carvalho Chehab
369ea272257SMauro Carvalho Chehab    Totals:
370ea272257SMauro Carvalho Chehab        Hits: 4775
371ea272257SMauro Carvalho Chehab        Entries: 46
372ea272257SMauro Carvalho Chehab        Dropped: 0
373ea272257SMauro Carvalho Chehab
374ea272257SMauro Carvalho Chehab  Even that's only marginally more useful - while hex values do look
375ea272257SMauro Carvalho Chehab  more like addresses, what users are typically more interested in
376ea272257SMauro Carvalho Chehab  when looking at text addresses are the corresponding symbols
377ea272257SMauro Carvalho Chehab  instead.  To have an address displayed as symbolic value instead,
378ea272257SMauro Carvalho Chehab  simply append '.sym' or '.sym-offset' to the field name in the
379ea272257SMauro Carvalho Chehab  trigger::
380ea272257SMauro Carvalho Chehab
381ea272257SMauro Carvalho Chehab    # echo 'hist:key=call_site.sym:val=bytes_req' > \
382ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger
383ea272257SMauro Carvalho Chehab
384ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist
385ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=call_site.sym:vals=bytes_req:sort=hitcount:size=2048 [active]
386ea272257SMauro Carvalho Chehab
387ea272257SMauro Carvalho Chehab    { call_site: [ffffffff810adcb9] syslog_print_all                              } hitcount:          1  bytes_req:       1024
388ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8154bc62] usb_control_msg                               } hitcount:          1  bytes_req:          8
389ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf6fe] hidraw_send_report [hid]                      } hitcount:          1  bytes_req:          7
390ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8154acbe] usb_alloc_urb                                 } hitcount:          1  bytes_req:        192
391ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf1ca] hidraw_report_event [hid]                     } hitcount:          1  bytes_req:          7
392ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811e3a25] __seq_open_private                            } hitcount:          1  bytes_req:         40
393ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8109524a] alloc_fair_sched_group                        } hitcount:          2  bytes_req:        128
394ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811febd5] fsnotify_alloc_group                          } hitcount:          2  bytes_req:        528
395ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81440f58] __tty_buffer_request_room                     } hitcount:          2  bytes_req:       2624
396ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81200ba6] inotify_new_group                             } hitcount:          2  bytes_req:         96
397ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa05e19af] ieee80211_start_tx_ba_session [mac80211]      } hitcount:          2  bytes_req:        464
398ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81672406] tcp_get_metrics                               } hitcount:          2  bytes_req:        304
399ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81097ec2] alloc_rt_sched_group                          } hitcount:          2  bytes_req:        128
400ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81089b05] sched_create_group                            } hitcount:          2  bytes_req:       1424
401ea272257SMauro Carvalho Chehab    .
402ea272257SMauro Carvalho Chehab    .
403ea272257SMauro Carvalho Chehab    .
404ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04a580c] intel_crtc_page_flip [i915]                   } hitcount:       1185  bytes_req:     123240
405ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0287592] drm_mode_page_flip_ioctl [drm]                } hitcount:       1185  bytes_req:     104280
406ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state [i915]            } hitcount:       1402  bytes_req:     190672
407ea272257SMauro Carvalho Chehab    { call_site: [ffffffff812891ca] ext4_find_extent                              } hitcount:       1518  bytes_req:     146208
408ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa029070e] drm_vma_node_allow [drm]                      } hitcount:       1746  bytes_req:      69840
409ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23 [i915]         } hitcount:       2021  bytes_req:     792312
410ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc [drm]                   } hitcount:       2592  bytes_req:     145152
411ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0489a66] intel_ring_begin [i915]                       } hitcount:       2629  bytes_req:     378576
412ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa046041c] i915_gem_execbuffer2 [i915]                   } hitcount:       2629  bytes_req:    3783248
413ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81325607] apparmor_file_alloc_security                  } hitcount:       5192  bytes_req:      10384
414ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00b7c06] hid_report_raw_event [hid]                    } hitcount:       5529  bytes_req:     110584
415ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8131ebf7] aa_alloc_task_context                         } hitcount:      21943  bytes_req:     702176
416ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8125847d] ext4_htree_store_dirent                       } hitcount:      55759  bytes_req:    5074265
417ea272257SMauro Carvalho Chehab
418ea272257SMauro Carvalho Chehab    Totals:
419ea272257SMauro Carvalho Chehab        Hits: 109928
420ea272257SMauro Carvalho Chehab        Entries: 71
421ea272257SMauro Carvalho Chehab        Dropped: 0
422ea272257SMauro Carvalho Chehab
423ea272257SMauro Carvalho Chehab  Because the default sort key above is 'hitcount', the above shows a
424ea272257SMauro Carvalho Chehab  the list of call_sites by increasing hitcount, so that at the bottom
425ea272257SMauro Carvalho Chehab  we see the functions that made the most kmalloc calls during the
426ea272257SMauro Carvalho Chehab  run.  If instead we we wanted to see the top kmalloc callers in
427ea272257SMauro Carvalho Chehab  terms of the number of bytes requested rather than the number of
428ea272257SMauro Carvalho Chehab  calls, and we wanted the top caller to appear at the top, we can use
429ea272257SMauro Carvalho Chehab  the 'sort' parameter, along with the 'descending' modifier::
430ea272257SMauro Carvalho Chehab
431ea272257SMauro Carvalho Chehab    # echo 'hist:key=call_site.sym:val=bytes_req:sort=bytes_req.descending' > \
432ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger
433ea272257SMauro Carvalho Chehab
434ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist
435ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=call_site.sym:vals=bytes_req:sort=bytes_req.descending:size=2048 [active]
436ea272257SMauro Carvalho Chehab
437ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa046041c] i915_gem_execbuffer2 [i915]                   } hitcount:       2186  bytes_req:    3397464
438ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23 [i915]         } hitcount:       1790  bytes_req:     712176
439ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8125847d] ext4_htree_store_dirent                       } hitcount:       8132  bytes_req:     513135
440ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811e2a1b] seq_buf_alloc                                 } hitcount:        106  bytes_req:     440128
441ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0489a66] intel_ring_begin [i915]                       } hitcount:       2186  bytes_req:     314784
442ea272257SMauro Carvalho Chehab    { call_site: [ffffffff812891ca] ext4_find_extent                              } hitcount:       2174  bytes_req:     208992
443ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811ae8e1] __kmalloc                                     } hitcount:          8  bytes_req:     131072
444ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state [i915]            } hitcount:        859  bytes_req:     116824
445ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc [drm]                   } hitcount:       1834  bytes_req:     102704
446ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04a580c] intel_crtc_page_flip [i915]                   } hitcount:        972  bytes_req:     101088
447ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0287592] drm_mode_page_flip_ioctl [drm]                } hitcount:        972  bytes_req:      85536
448ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00b7c06] hid_report_raw_event [hid]                    } hitcount:       3333  bytes_req:      66664
449ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8137e559] sg_kmalloc                                    } hitcount:        209  bytes_req:      61632
450ea272257SMauro Carvalho Chehab    .
451ea272257SMauro Carvalho Chehab    .
452ea272257SMauro Carvalho Chehab    .
453ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81095225] alloc_fair_sched_group                        } hitcount:          2  bytes_req:        128
454ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81097ec2] alloc_rt_sched_group                          } hitcount:          2  bytes_req:        128
455ea272257SMauro Carvalho Chehab    { call_site: [ffffffff812d8406] copy_semundo                                  } hitcount:          2  bytes_req:         48
456ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81200ba6] inotify_new_group                             } hitcount:          1  bytes_req:         48
457ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa027121a] drm_getmagic [drm]                            } hitcount:          1  bytes_req:         48
458ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811e3a25] __seq_open_private                            } hitcount:          1  bytes_req:         40
459ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811c52f4] bprm_change_interp                            } hitcount:          2  bytes_req:         16
460ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8154bc62] usb_control_msg                               } hitcount:          1  bytes_req:          8
461ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf1ca] hidraw_report_event [hid]                     } hitcount:          1  bytes_req:          7
462ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf6fe] hidraw_send_report [hid]                      } hitcount:          1  bytes_req:          7
463ea272257SMauro Carvalho Chehab
464ea272257SMauro Carvalho Chehab    Totals:
465ea272257SMauro Carvalho Chehab        Hits: 32133
466ea272257SMauro Carvalho Chehab        Entries: 81
467ea272257SMauro Carvalho Chehab        Dropped: 0
468ea272257SMauro Carvalho Chehab
469ea272257SMauro Carvalho Chehab  To display the offset and size information in addition to the symbol
470ea272257SMauro Carvalho Chehab  name, just use 'sym-offset' instead::
471ea272257SMauro Carvalho Chehab
472ea272257SMauro Carvalho Chehab    # echo 'hist:key=call_site.sym-offset:val=bytes_req:sort=bytes_req.descending' > \
473ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger
474ea272257SMauro Carvalho Chehab
475ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist
476ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=call_site.sym-offset:vals=bytes_req:sort=bytes_req.descending:size=2048 [active]
477ea272257SMauro Carvalho Chehab
478ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa046041c] i915_gem_execbuffer2+0x6c/0x2c0 [i915]                  } hitcount:       4569  bytes_req:    3163720
479ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0489a66] intel_ring_begin+0xc6/0x1f0 [i915]                      } hitcount:       4569  bytes_req:     657936
480ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23+0x694/0x1020 [i915]      } hitcount:       1519  bytes_req:     472936
481ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa045e646] i915_gem_do_execbuffer.isra.23+0x516/0x1020 [i915]      } hitcount:       3050  bytes_req:     211832
482ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811e2a1b] seq_buf_alloc+0x1b/0x50                                 } hitcount:         34  bytes_req:     148384
483ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04a580c] intel_crtc_page_flip+0xbc/0x870 [i915]                  } hitcount:       1385  bytes_req:     144040
484ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811ae8e1] __kmalloc+0x191/0x1b0                                   } hitcount:          8  bytes_req:     131072
485ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0287592] drm_mode_page_flip_ioctl+0x282/0x360 [drm]              } hitcount:       1385  bytes_req:     121880
486ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc+0x32/0x100 [drm]                  } hitcount:       1848  bytes_req:     103488
487ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state+0x2c/0xa0 [i915]            } hitcount:        461  bytes_req:      62696
488ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa029070e] drm_vma_node_allow+0x2e/0xd0 [drm]                      } hitcount:       1541  bytes_req:      61640
489ea272257SMauro Carvalho Chehab    { call_site: [ffffffff815f8d7b] sk_prot_alloc+0xcb/0x1b0                                } hitcount:         57  bytes_req:      57456
490ea272257SMauro Carvalho Chehab    .
491ea272257SMauro Carvalho Chehab    .
492ea272257SMauro Carvalho Chehab    .
493ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8109524a] alloc_fair_sched_group+0x5a/0x1a0                       } hitcount:          2  bytes_req:        128
494ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa027b921] drm_vm_open_locked+0x31/0xa0 [drm]                      } hitcount:          3  bytes_req:         96
495ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8122e266] proc_self_follow_link+0x76/0xb0                         } hitcount:          8  bytes_req:         96
496ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81213e80] load_elf_binary+0x240/0x1650                            } hitcount:          3  bytes_req:         84
497ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8154bc62] usb_control_msg+0x42/0x110                              } hitcount:          1  bytes_req:          8
498ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf6fe] hidraw_send_report+0x7e/0x1a0 [hid]                     } hitcount:          1  bytes_req:          7
499ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf1ca] hidraw_report_event+0x8a/0x120 [hid]                    } hitcount:          1  bytes_req:          7
500ea272257SMauro Carvalho Chehab
501ea272257SMauro Carvalho Chehab    Totals:
502ea272257SMauro Carvalho Chehab        Hits: 26098
503ea272257SMauro Carvalho Chehab        Entries: 64
504ea272257SMauro Carvalho Chehab        Dropped: 0
505ea272257SMauro Carvalho Chehab
506ea272257SMauro Carvalho Chehab  We can also add multiple fields to the 'values' parameter.  For
507ea272257SMauro Carvalho Chehab  example, we might want to see the total number of bytes allocated
508ea272257SMauro Carvalho Chehab  alongside bytes requested, and display the result sorted by bytes
509ea272257SMauro Carvalho Chehab  allocated in a descending order::
510ea272257SMauro Carvalho Chehab
511ea272257SMauro Carvalho Chehab    # echo 'hist:keys=call_site.sym:values=bytes_req,bytes_alloc:sort=bytes_alloc.descending' > \
512ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger
513ea272257SMauro Carvalho Chehab
514ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist
515ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=call_site.sym:vals=bytes_req,bytes_alloc:sort=bytes_alloc.descending:size=2048 [active]
516ea272257SMauro Carvalho Chehab
517ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa046041c] i915_gem_execbuffer2 [i915]                   } hitcount:       7403  bytes_req:    4084360  bytes_alloc:    5958016
518ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811e2a1b] seq_buf_alloc                                 } hitcount:        541  bytes_req:    2213968  bytes_alloc:    2228224
519ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0489a66] intel_ring_begin [i915]                       } hitcount:       7404  bytes_req:    1066176  bytes_alloc:    1421568
520ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23 [i915]         } hitcount:       1565  bytes_req:     557368  bytes_alloc:    1037760
521ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8125847d] ext4_htree_store_dirent                       } hitcount:       9557  bytes_req:     595778  bytes_alloc:     695744
522ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa045e646] i915_gem_do_execbuffer.isra.23 [i915]         } hitcount:       5839  bytes_req:     430680  bytes_alloc:     470400
523ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state [i915]            } hitcount:       2388  bytes_req:     324768  bytes_alloc:     458496
524ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc [drm]                   } hitcount:       3911  bytes_req:     219016  bytes_alloc:     250304
525ea272257SMauro Carvalho Chehab    { call_site: [ffffffff815f8d7b] sk_prot_alloc                                 } hitcount:        235  bytes_req:     236880  bytes_alloc:     240640
526ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8137e559] sg_kmalloc                                    } hitcount:        557  bytes_req:     169024  bytes_alloc:     221760
527ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00b7c06] hid_report_raw_event [hid]                    } hitcount:       9378  bytes_req:     187548  bytes_alloc:     206312
528ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04a580c] intel_crtc_page_flip [i915]                   } hitcount:       1519  bytes_req:     157976  bytes_alloc:     194432
529ea272257SMauro Carvalho Chehab    .
530ea272257SMauro Carvalho Chehab    .
531ea272257SMauro Carvalho Chehab    .
532ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8109bd3b] sched_autogroup_create_attach                 } hitcount:          2  bytes_req:        144  bytes_alloc:        192
533ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81097ee8] alloc_rt_sched_group                          } hitcount:          2  bytes_req:        128  bytes_alloc:        128
534ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8109524a] alloc_fair_sched_group                        } hitcount:          2  bytes_req:        128  bytes_alloc:        128
535ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81095225] alloc_fair_sched_group                        } hitcount:          2  bytes_req:        128  bytes_alloc:        128
536ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81097ec2] alloc_rt_sched_group                          } hitcount:          2  bytes_req:        128  bytes_alloc:        128
537ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81213e80] load_elf_binary                               } hitcount:          3  bytes_req:         84  bytes_alloc:         96
538ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81079a2e] kthread_create_on_node                        } hitcount:          1  bytes_req:         56  bytes_alloc:         64
539ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf6fe] hidraw_send_report [hid]                      } hitcount:          1  bytes_req:          7  bytes_alloc:          8
540ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8154bc62] usb_control_msg                               } hitcount:          1  bytes_req:          8  bytes_alloc:          8
541ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf1ca] hidraw_report_event [hid]                     } hitcount:          1  bytes_req:          7  bytes_alloc:          8
542ea272257SMauro Carvalho Chehab
543ea272257SMauro Carvalho Chehab    Totals:
544ea272257SMauro Carvalho Chehab        Hits: 66598
545ea272257SMauro Carvalho Chehab        Entries: 65
546ea272257SMauro Carvalho Chehab        Dropped: 0
547ea272257SMauro Carvalho Chehab
548ea272257SMauro Carvalho Chehab  Finally, to finish off our kmalloc example, instead of simply having
549ea272257SMauro Carvalho Chehab  the hist trigger display symbolic call_sites, we can have the hist
550ea272257SMauro Carvalho Chehab  trigger additionally display the complete set of kernel stack traces
551ea272257SMauro Carvalho Chehab  that led to each call_site.  To do that, we simply use the special
552ea272257SMauro Carvalho Chehab  value 'stacktrace' for the key parameter::
553ea272257SMauro Carvalho Chehab
554ea272257SMauro Carvalho Chehab    # echo 'hist:keys=stacktrace:values=bytes_req,bytes_alloc:sort=bytes_alloc' > \
555ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger
556ea272257SMauro Carvalho Chehab
557ea272257SMauro Carvalho Chehab  The above trigger will use the kernel stack trace in effect when an
558ea272257SMauro Carvalho Chehab  event is triggered as the key for the hash table.  This allows the
559ea272257SMauro Carvalho Chehab  enumeration of every kernel callpath that led up to a particular
560ea272257SMauro Carvalho Chehab  event, along with a running total of any of the event fields for
561ea272257SMauro Carvalho Chehab  that event.  Here we tally bytes requested and bytes allocated for
562ea272257SMauro Carvalho Chehab  every callpath in the system that led up to a kmalloc (in this case
563ea272257SMauro Carvalho Chehab  every callpath to a kmalloc for a kernel compile)::
564ea272257SMauro Carvalho Chehab
565ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist
566ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=stacktrace:vals=bytes_req,bytes_alloc:sort=bytes_alloc:size=2048 [active]
567ea272257SMauro Carvalho Chehab
568ea272257SMauro Carvalho Chehab    { stacktrace:
569ea272257SMauro Carvalho Chehab         __kmalloc_track_caller+0x10b/0x1a0
570ea272257SMauro Carvalho Chehab         kmemdup+0x20/0x50
571ea272257SMauro Carvalho Chehab         hidraw_report_event+0x8a/0x120 [hid]
572ea272257SMauro Carvalho Chehab         hid_report_raw_event+0x3ea/0x440 [hid]
573ea272257SMauro Carvalho Chehab         hid_input_report+0x112/0x190 [hid]
574ea272257SMauro Carvalho Chehab         hid_irq_in+0xc2/0x260 [usbhid]
575ea272257SMauro Carvalho Chehab         __usb_hcd_giveback_urb+0x72/0x120
576ea272257SMauro Carvalho Chehab         usb_giveback_urb_bh+0x9e/0xe0
577ea272257SMauro Carvalho Chehab         tasklet_hi_action+0xf8/0x100
578ea272257SMauro Carvalho Chehab         __do_softirq+0x114/0x2c0
579ea272257SMauro Carvalho Chehab         irq_exit+0xa5/0xb0
580ea272257SMauro Carvalho Chehab         do_IRQ+0x5a/0xf0
581ea272257SMauro Carvalho Chehab         ret_from_intr+0x0/0x30
582ea272257SMauro Carvalho Chehab         cpuidle_enter+0x17/0x20
583ea272257SMauro Carvalho Chehab         cpu_startup_entry+0x315/0x3e0
584ea272257SMauro Carvalho Chehab         rest_init+0x7c/0x80
585ea272257SMauro Carvalho Chehab    } hitcount:          3  bytes_req:         21  bytes_alloc:         24
586ea272257SMauro Carvalho Chehab    { stacktrace:
587ea272257SMauro Carvalho Chehab         __kmalloc_track_caller+0x10b/0x1a0
588ea272257SMauro Carvalho Chehab         kmemdup+0x20/0x50
589ea272257SMauro Carvalho Chehab         hidraw_report_event+0x8a/0x120 [hid]
590ea272257SMauro Carvalho Chehab         hid_report_raw_event+0x3ea/0x440 [hid]
591ea272257SMauro Carvalho Chehab         hid_input_report+0x112/0x190 [hid]
592ea272257SMauro Carvalho Chehab         hid_irq_in+0xc2/0x260 [usbhid]
593ea272257SMauro Carvalho Chehab         __usb_hcd_giveback_urb+0x72/0x120
594ea272257SMauro Carvalho Chehab         usb_giveback_urb_bh+0x9e/0xe0
595ea272257SMauro Carvalho Chehab         tasklet_hi_action+0xf8/0x100
596ea272257SMauro Carvalho Chehab         __do_softirq+0x114/0x2c0
597ea272257SMauro Carvalho Chehab         irq_exit+0xa5/0xb0
598ea272257SMauro Carvalho Chehab         do_IRQ+0x5a/0xf0
599ea272257SMauro Carvalho Chehab         ret_from_intr+0x0/0x30
600ea272257SMauro Carvalho Chehab    } hitcount:          3  bytes_req:         21  bytes_alloc:         24
601ea272257SMauro Carvalho Chehab    { stacktrace:
602ea272257SMauro Carvalho Chehab         kmem_cache_alloc_trace+0xeb/0x150
603ea272257SMauro Carvalho Chehab         aa_alloc_task_context+0x27/0x40
604ea272257SMauro Carvalho Chehab         apparmor_cred_prepare+0x1f/0x50
605ea272257SMauro Carvalho Chehab         security_prepare_creds+0x16/0x20
606ea272257SMauro Carvalho Chehab         prepare_creds+0xdf/0x1a0
607ea272257SMauro Carvalho Chehab         SyS_capset+0xb5/0x200
608ea272257SMauro Carvalho Chehab         system_call_fastpath+0x12/0x6a
609ea272257SMauro Carvalho Chehab    } hitcount:          1  bytes_req:         32  bytes_alloc:         32
610ea272257SMauro Carvalho Chehab    .
611ea272257SMauro Carvalho Chehab    .
612ea272257SMauro Carvalho Chehab    .
613ea272257SMauro Carvalho Chehab    { stacktrace:
614ea272257SMauro Carvalho Chehab         __kmalloc+0x11b/0x1b0
615ea272257SMauro Carvalho Chehab         i915_gem_execbuffer2+0x6c/0x2c0 [i915]
616ea272257SMauro Carvalho Chehab         drm_ioctl+0x349/0x670 [drm]
617ea272257SMauro Carvalho Chehab         do_vfs_ioctl+0x2f0/0x4f0
618ea272257SMauro Carvalho Chehab         SyS_ioctl+0x81/0xa0
619ea272257SMauro Carvalho Chehab         system_call_fastpath+0x12/0x6a
620ea272257SMauro Carvalho Chehab    } hitcount:      17726  bytes_req:   13944120  bytes_alloc:   19593808
621ea272257SMauro Carvalho Chehab    { stacktrace:
622ea272257SMauro Carvalho Chehab         __kmalloc+0x11b/0x1b0
623ea272257SMauro Carvalho Chehab         load_elf_phdrs+0x76/0xa0
624ea272257SMauro Carvalho Chehab         load_elf_binary+0x102/0x1650
625ea272257SMauro Carvalho Chehab         search_binary_handler+0x97/0x1d0
626ea272257SMauro Carvalho Chehab         do_execveat_common.isra.34+0x551/0x6e0
627ea272257SMauro Carvalho Chehab         SyS_execve+0x3a/0x50
628ea272257SMauro Carvalho Chehab         return_from_execve+0x0/0x23
629ea272257SMauro Carvalho Chehab    } hitcount:      33348  bytes_req:   17152128  bytes_alloc:   20226048
630ea272257SMauro Carvalho Chehab    { stacktrace:
631ea272257SMauro Carvalho Chehab         kmem_cache_alloc_trace+0xeb/0x150
632ea272257SMauro Carvalho Chehab         apparmor_file_alloc_security+0x27/0x40
633ea272257SMauro Carvalho Chehab         security_file_alloc+0x16/0x20
634ea272257SMauro Carvalho Chehab         get_empty_filp+0x93/0x1c0
635ea272257SMauro Carvalho Chehab         path_openat+0x31/0x5f0
636ea272257SMauro Carvalho Chehab         do_filp_open+0x3a/0x90
637ea272257SMauro Carvalho Chehab         do_sys_open+0x128/0x220
638ea272257SMauro Carvalho Chehab         SyS_open+0x1e/0x20
639ea272257SMauro Carvalho Chehab         system_call_fastpath+0x12/0x6a
640ea272257SMauro Carvalho Chehab    } hitcount:    4766422  bytes_req:    9532844  bytes_alloc:   38131376
641ea272257SMauro Carvalho Chehab    { stacktrace:
642ea272257SMauro Carvalho Chehab         __kmalloc+0x11b/0x1b0
643ea272257SMauro Carvalho Chehab         seq_buf_alloc+0x1b/0x50
644ea272257SMauro Carvalho Chehab         seq_read+0x2cc/0x370
645ea272257SMauro Carvalho Chehab         proc_reg_read+0x3d/0x80
646ea272257SMauro Carvalho Chehab         __vfs_read+0x28/0xe0
647ea272257SMauro Carvalho Chehab         vfs_read+0x86/0x140
648ea272257SMauro Carvalho Chehab         SyS_read+0x46/0xb0
649ea272257SMauro Carvalho Chehab         system_call_fastpath+0x12/0x6a
650ea272257SMauro Carvalho Chehab    } hitcount:      19133  bytes_req:   78368768  bytes_alloc:   78368768
651ea272257SMauro Carvalho Chehab
652ea272257SMauro Carvalho Chehab    Totals:
653ea272257SMauro Carvalho Chehab        Hits: 6085872
654ea272257SMauro Carvalho Chehab        Entries: 253
655ea272257SMauro Carvalho Chehab        Dropped: 0
656ea272257SMauro Carvalho Chehab
657ea272257SMauro Carvalho Chehab  If you key a hist trigger on common_pid, in order for example to
658ea272257SMauro Carvalho Chehab  gather and display sorted totals for each process, you can use the
659ea272257SMauro Carvalho Chehab  special .execname modifier to display the executable names for the
660ea272257SMauro Carvalho Chehab  processes in the table rather than raw pids.  The example below
661ea272257SMauro Carvalho Chehab  keeps a per-process sum of total bytes read::
662ea272257SMauro Carvalho Chehab
663ea272257SMauro Carvalho Chehab    # echo 'hist:key=common_pid.execname:val=count:sort=count.descending' > \
664ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/syscalls/sys_enter_read/trigger
665ea272257SMauro Carvalho Chehab
666ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_read/hist
667ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=common_pid.execname:vals=count:sort=count.descending:size=2048 [active]
668ea272257SMauro Carvalho Chehab
669ea272257SMauro Carvalho Chehab    { common_pid: gnome-terminal  [      3196] } hitcount:        280  count:    1093512
670ea272257SMauro Carvalho Chehab    { common_pid: Xorg            [      1309] } hitcount:        525  count:     256640
671ea272257SMauro Carvalho Chehab    { common_pid: compiz          [      2889] } hitcount:         59  count:     254400
672ea272257SMauro Carvalho Chehab    { common_pid: bash            [      8710] } hitcount:          3  count:      66369
673ea272257SMauro Carvalho Chehab    { common_pid: dbus-daemon-lau [      8703] } hitcount:         49  count:      47739
674ea272257SMauro Carvalho Chehab    { common_pid: irqbalance      [      1252] } hitcount:         27  count:      27648
675ea272257SMauro Carvalho Chehab    { common_pid: 01ifupdown      [      8705] } hitcount:          3  count:      17216
676ea272257SMauro Carvalho Chehab    { common_pid: dbus-daemon     [       772] } hitcount:         10  count:      12396
677ea272257SMauro Carvalho Chehab    { common_pid: Socket Thread   [      8342] } hitcount:         11  count:      11264
678ea272257SMauro Carvalho Chehab    { common_pid: nm-dhcp-client. [      8701] } hitcount:          6  count:       7424
679ea272257SMauro Carvalho Chehab    { common_pid: gmain           [      1315] } hitcount:         18  count:       6336
680ea272257SMauro Carvalho Chehab    .
681ea272257SMauro Carvalho Chehab    .
682ea272257SMauro Carvalho Chehab    .
683ea272257SMauro Carvalho Chehab    { common_pid: postgres        [      1892] } hitcount:          2  count:         32
684ea272257SMauro Carvalho Chehab    { common_pid: postgres        [      1891] } hitcount:          2  count:         32
685ea272257SMauro Carvalho Chehab    { common_pid: gmain           [      8704] } hitcount:          2  count:         32
686ea272257SMauro Carvalho Chehab    { common_pid: upstart-dbus-br [      2740] } hitcount:         21  count:         21
687ea272257SMauro Carvalho Chehab    { common_pid: nm-dispatcher.a [      8696] } hitcount:          1  count:         16
688ea272257SMauro Carvalho Chehab    { common_pid: indicator-datet [      2904] } hitcount:          1  count:         16
689ea272257SMauro Carvalho Chehab    { common_pid: gdbus           [      2998] } hitcount:          1  count:         16
690ea272257SMauro Carvalho Chehab    { common_pid: rtkit-daemon    [      2052] } hitcount:          1  count:          8
691ea272257SMauro Carvalho Chehab    { common_pid: init            [         1] } hitcount:          2  count:          2
692ea272257SMauro Carvalho Chehab
693ea272257SMauro Carvalho Chehab    Totals:
694ea272257SMauro Carvalho Chehab        Hits: 2116
695ea272257SMauro Carvalho Chehab        Entries: 51
696ea272257SMauro Carvalho Chehab        Dropped: 0
697ea272257SMauro Carvalho Chehab
698ea272257SMauro Carvalho Chehab  Similarly, if you key a hist trigger on syscall id, for example to
699ea272257SMauro Carvalho Chehab  gather and display a list of systemwide syscall hits, you can use
700ea272257SMauro Carvalho Chehab  the special .syscall modifier to display the syscall names rather
701ea272257SMauro Carvalho Chehab  than raw ids.  The example below keeps a running total of syscall
702ea272257SMauro Carvalho Chehab  counts for the system during the run::
703ea272257SMauro Carvalho Chehab
704ea272257SMauro Carvalho Chehab    # echo 'hist:key=id.syscall:val=hitcount' > \
705ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/trigger
706ea272257SMauro Carvalho Chehab
707ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/hist
708ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=id.syscall:vals=hitcount:sort=hitcount:size=2048 [active]
709ea272257SMauro Carvalho Chehab
710ea272257SMauro Carvalho Chehab    { id: sys_fsync                     [ 74] } hitcount:          1
711ea272257SMauro Carvalho Chehab    { id: sys_newuname                  [ 63] } hitcount:          1
712ea272257SMauro Carvalho Chehab    { id: sys_prctl                     [157] } hitcount:          1
713ea272257SMauro Carvalho Chehab    { id: sys_statfs                    [137] } hitcount:          1
714ea272257SMauro Carvalho Chehab    { id: sys_symlink                   [ 88] } hitcount:          1
715ea272257SMauro Carvalho Chehab    { id: sys_sendmmsg                  [307] } hitcount:          1
716ea272257SMauro Carvalho Chehab    { id: sys_semctl                    [ 66] } hitcount:          1
717ea272257SMauro Carvalho Chehab    { id: sys_readlink                  [ 89] } hitcount:          3
718ea272257SMauro Carvalho Chehab    { id: sys_bind                      [ 49] } hitcount:          3
719ea272257SMauro Carvalho Chehab    { id: sys_getsockname               [ 51] } hitcount:          3
720ea272257SMauro Carvalho Chehab    { id: sys_unlink                    [ 87] } hitcount:          3
721ea272257SMauro Carvalho Chehab    { id: sys_rename                    [ 82] } hitcount:          4
722ea272257SMauro Carvalho Chehab    { id: unknown_syscall               [ 58] } hitcount:          4
723ea272257SMauro Carvalho Chehab    { id: sys_connect                   [ 42] } hitcount:          4
724ea272257SMauro Carvalho Chehab    { id: sys_getpid                    [ 39] } hitcount:          4
725ea272257SMauro Carvalho Chehab    .
726ea272257SMauro Carvalho Chehab    .
727ea272257SMauro Carvalho Chehab    .
728ea272257SMauro Carvalho Chehab    { id: sys_rt_sigprocmask            [ 14] } hitcount:        952
729ea272257SMauro Carvalho Chehab    { id: sys_futex                     [202] } hitcount:       1534
730ea272257SMauro Carvalho Chehab    { id: sys_write                     [  1] } hitcount:       2689
731ea272257SMauro Carvalho Chehab    { id: sys_setitimer                 [ 38] } hitcount:       2797
732ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0] } hitcount:       3202
733ea272257SMauro Carvalho Chehab    { id: sys_select                    [ 23] } hitcount:       3773
734ea272257SMauro Carvalho Chehab    { id: sys_writev                    [ 20] } hitcount:       4531
735ea272257SMauro Carvalho Chehab    { id: sys_poll                      [  7] } hitcount:       8314
736ea272257SMauro Carvalho Chehab    { id: sys_recvmsg                   [ 47] } hitcount:      13738
737ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16] } hitcount:      21843
738ea272257SMauro Carvalho Chehab
739ea272257SMauro Carvalho Chehab    Totals:
740ea272257SMauro Carvalho Chehab        Hits: 67612
741ea272257SMauro Carvalho Chehab        Entries: 72
742ea272257SMauro Carvalho Chehab        Dropped: 0
743ea272257SMauro Carvalho Chehab
744ea272257SMauro Carvalho Chehab  The syscall counts above provide a rough overall picture of system
745ea272257SMauro Carvalho Chehab  call activity on the system; we can see for example that the most
746ea272257SMauro Carvalho Chehab  popular system call on this system was the 'sys_ioctl' system call.
747ea272257SMauro Carvalho Chehab
748ea272257SMauro Carvalho Chehab  We can use 'compound' keys to refine that number and provide some
749ea272257SMauro Carvalho Chehab  further insight as to which processes exactly contribute to the
750ea272257SMauro Carvalho Chehab  overall ioctl count.
751ea272257SMauro Carvalho Chehab
752ea272257SMauro Carvalho Chehab  The command below keeps a hitcount for every unique combination of
753ea272257SMauro Carvalho Chehab  system call id and pid - the end result is essentially a table
754ea272257SMauro Carvalho Chehab  that keeps a per-pid sum of system call hits.  The results are
755ea272257SMauro Carvalho Chehab  sorted using the system call id as the primary key, and the
756ea272257SMauro Carvalho Chehab  hitcount sum as the secondary key::
757ea272257SMauro Carvalho Chehab
758ea272257SMauro Carvalho Chehab    # echo 'hist:key=id.syscall,common_pid.execname:val=hitcount:sort=id,hitcount' > \
759ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/trigger
760ea272257SMauro Carvalho Chehab
761ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/hist
762ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=id.syscall,common_pid.execname:vals=hitcount:sort=id.syscall,hitcount:size=2048 [active]
763ea272257SMauro Carvalho Chehab
764ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: rtkit-daemon    [      1877] } hitcount:          1
765ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: gdbus           [      2976] } hitcount:          1
766ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: console-kit-dae [      3400] } hitcount:          1
767ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: postgres        [      1865] } hitcount:          1
768ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: deja-dup-monito [      3543] } hitcount:          2
769ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: NetworkManager  [       890] } hitcount:          2
770ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: evolution-calen [      3048] } hitcount:          2
771ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: postgres        [      1864] } hitcount:          2
772ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: nm-applet       [      3022] } hitcount:          2
773ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: whoopsie        [      1212] } hitcount:          2
774ea272257SMauro Carvalho Chehab    .
775ea272257SMauro Carvalho Chehab    .
776ea272257SMauro Carvalho Chehab    .
777ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: bash            [      8479] } hitcount:          1
778ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: bash            [      3472] } hitcount:         12
779ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gnome-terminal  [      3199] } hitcount:         16
780ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: Xorg            [      1267] } hitcount:       1808
781ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: compiz          [      2994] } hitcount:       5580
782ea272257SMauro Carvalho Chehab    .
783ea272257SMauro Carvalho Chehab    .
784ea272257SMauro Carvalho Chehab    .
785ea272257SMauro Carvalho Chehab    { id: sys_waitid                    [247], common_pid: upstart-dbus-br [      2690] } hitcount:          3
786ea272257SMauro Carvalho Chehab    { id: sys_waitid                    [247], common_pid: upstart-dbus-br [      2688] } hitcount:         16
787ea272257SMauro Carvalho Chehab    { id: sys_inotify_add_watch         [254], common_pid: gmain           [       975] } hitcount:          2
788ea272257SMauro Carvalho Chehab    { id: sys_inotify_add_watch         [254], common_pid: gmain           [      3204] } hitcount:          4
789ea272257SMauro Carvalho Chehab    { id: sys_inotify_add_watch         [254], common_pid: gmain           [      2888] } hitcount:          4
790ea272257SMauro Carvalho Chehab    { id: sys_inotify_add_watch         [254], common_pid: gmain           [      3003] } hitcount:          4
791ea272257SMauro Carvalho Chehab    { id: sys_inotify_add_watch         [254], common_pid: gmain           [      2873] } hitcount:          4
792ea272257SMauro Carvalho Chehab    { id: sys_inotify_add_watch         [254], common_pid: gmain           [      3196] } hitcount:          6
793ea272257SMauro Carvalho Chehab    { id: sys_openat                    [257], common_pid: java            [      2623] } hitcount:          2
794ea272257SMauro Carvalho Chehab    { id: sys_eventfd2                  [290], common_pid: ibus-ui-gtk3    [      2760] } hitcount:          4
795ea272257SMauro Carvalho Chehab    { id: sys_eventfd2                  [290], common_pid: compiz          [      2994] } hitcount:          6
796ea272257SMauro Carvalho Chehab
797ea272257SMauro Carvalho Chehab    Totals:
798ea272257SMauro Carvalho Chehab        Hits: 31536
799ea272257SMauro Carvalho Chehab        Entries: 323
800ea272257SMauro Carvalho Chehab        Dropped: 0
801ea272257SMauro Carvalho Chehab
802ea272257SMauro Carvalho Chehab  The above list does give us a breakdown of the ioctl syscall by
803ea272257SMauro Carvalho Chehab  pid, but it also gives us quite a bit more than that, which we
804ea272257SMauro Carvalho Chehab  don't really care about at the moment.  Since we know the syscall
805ea272257SMauro Carvalho Chehab  id for sys_ioctl (16, displayed next to the sys_ioctl name), we
806ea272257SMauro Carvalho Chehab  can use that to filter out all the other syscalls::
807ea272257SMauro Carvalho Chehab
808ea272257SMauro Carvalho Chehab    # echo 'hist:key=id.syscall,common_pid.execname:val=hitcount:sort=id,hitcount if id == 16' > \
809ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/trigger
810ea272257SMauro Carvalho Chehab
811ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/hist
812ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=id.syscall,common_pid.execname:vals=hitcount:sort=id.syscall,hitcount:size=2048 if id == 16 [active]
813ea272257SMauro Carvalho Chehab
814ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gmain           [      2769] } hitcount:          1
815ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: evolution-addre [      8571] } hitcount:          1
816ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gmain           [      3003] } hitcount:          1
817ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gmain           [      2781] } hitcount:          1
818ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gmain           [      2829] } hitcount:          1
819ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: bash            [      8726] } hitcount:          1
820ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: bash            [      8508] } hitcount:          1
821ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gmain           [      2970] } hitcount:          1
822ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gmain           [      2768] } hitcount:          1
823ea272257SMauro Carvalho Chehab    .
824ea272257SMauro Carvalho Chehab    .
825ea272257SMauro Carvalho Chehab    .
826ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: pool            [      8559] } hitcount:         45
827ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: pool            [      8555] } hitcount:         48
828ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: pool            [      8551] } hitcount:         48
829ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: avahi-daemon    [       896] } hitcount:         66
830ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: Xorg            [      1267] } hitcount:      26674
831ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: compiz          [      2994] } hitcount:      73443
832ea272257SMauro Carvalho Chehab
833ea272257SMauro Carvalho Chehab    Totals:
834ea272257SMauro Carvalho Chehab        Hits: 101162
835ea272257SMauro Carvalho Chehab        Entries: 103
836ea272257SMauro Carvalho Chehab        Dropped: 0
837ea272257SMauro Carvalho Chehab
838ea272257SMauro Carvalho Chehab  The above output shows that 'compiz' and 'Xorg' are far and away
839ea272257SMauro Carvalho Chehab  the heaviest ioctl callers (which might lead to questions about
840ea272257SMauro Carvalho Chehab  whether they really need to be making all those calls and to
841ea272257SMauro Carvalho Chehab  possible avenues for further investigation.)
842ea272257SMauro Carvalho Chehab
843ea272257SMauro Carvalho Chehab  The compound key examples used a key and a sum value (hitcount) to
844ea272257SMauro Carvalho Chehab  sort the output, but we can just as easily use two keys instead.
845ea272257SMauro Carvalho Chehab  Here's an example where we use a compound key composed of the the
846ea272257SMauro Carvalho Chehab  common_pid and size event fields.  Sorting with pid as the primary
847ea272257SMauro Carvalho Chehab  key and 'size' as the secondary key allows us to display an
848ea272257SMauro Carvalho Chehab  ordered summary of the recvfrom sizes, with counts, received by
849ea272257SMauro Carvalho Chehab  each process::
850ea272257SMauro Carvalho Chehab
851ea272257SMauro Carvalho Chehab    # echo 'hist:key=common_pid.execname,size:val=hitcount:sort=common_pid,size' > \
852ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/syscalls/sys_enter_recvfrom/trigger
853ea272257SMauro Carvalho Chehab
854ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_recvfrom/hist
855ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=common_pid.execname,size:vals=hitcount:sort=common_pid.execname,size:size=2048 [active]
856ea272257SMauro Carvalho Chehab
857ea272257SMauro Carvalho Chehab    { common_pid: smbd            [       784], size:          4 } hitcount:          1
858ea272257SMauro Carvalho Chehab    { common_pid: dnsmasq         [      1412], size:       4096 } hitcount:        672
859ea272257SMauro Carvalho Chehab    { common_pid: postgres        [      1796], size:       1000 } hitcount:          6
860ea272257SMauro Carvalho Chehab    { common_pid: postgres        [      1867], size:       1000 } hitcount:         10
861ea272257SMauro Carvalho Chehab    { common_pid: bamfdaemon      [      2787], size:         28 } hitcount:          2
862ea272257SMauro Carvalho Chehab    { common_pid: bamfdaemon      [      2787], size:      14360 } hitcount:          1
863ea272257SMauro Carvalho Chehab    { common_pid: compiz          [      2994], size:          8 } hitcount:          1
864ea272257SMauro Carvalho Chehab    { common_pid: compiz          [      2994], size:         20 } hitcount:         11
865ea272257SMauro Carvalho Chehab    { common_pid: gnome-terminal  [      3199], size:          4 } hitcount:          2
866ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8817], size:          4 } hitcount:          1
867ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8817], size:          8 } hitcount:          5
868ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8817], size:        588 } hitcount:          2
869ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8817], size:        628 } hitcount:          1
870ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8817], size:       6944 } hitcount:          1
871ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8817], size:     408880 } hitcount:          2
872ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8822], size:          8 } hitcount:          2
873ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8822], size:        160 } hitcount:          2
874ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8822], size:        320 } hitcount:          2
875ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8822], size:        352 } hitcount:          1
876ea272257SMauro Carvalho Chehab    .
877ea272257SMauro Carvalho Chehab    .
878ea272257SMauro Carvalho Chehab    .
879ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8923], size:       1960 } hitcount:         10
880ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8923], size:       2048 } hitcount:         10
881ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8924], size:       1960 } hitcount:         10
882ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8924], size:       2048 } hitcount:         10
883ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8928], size:       1964 } hitcount:          4
884ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8928], size:       1965 } hitcount:          2
885ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8928], size:       2048 } hitcount:          6
886ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8929], size:       1982 } hitcount:          1
887ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8929], size:       2048 } hitcount:          1
888ea272257SMauro Carvalho Chehab
889ea272257SMauro Carvalho Chehab    Totals:
890ea272257SMauro Carvalho Chehab        Hits: 2016
891ea272257SMauro Carvalho Chehab        Entries: 224
892ea272257SMauro Carvalho Chehab        Dropped: 0
893ea272257SMauro Carvalho Chehab
894ea272257SMauro Carvalho Chehab  The above example also illustrates the fact that although a compound
895ea272257SMauro Carvalho Chehab  key is treated as a single entity for hashing purposes, the sub-keys
896ea272257SMauro Carvalho Chehab  it's composed of can be accessed independently.
897ea272257SMauro Carvalho Chehab
898ea272257SMauro Carvalho Chehab  The next example uses a string field as the hash key and
899ea272257SMauro Carvalho Chehab  demonstrates how you can manually pause and continue a hist trigger.
900ea272257SMauro Carvalho Chehab  In this example, we'll aggregate fork counts and don't expect a
901ea272257SMauro Carvalho Chehab  large number of entries in the hash table, so we'll drop it to a
902ea272257SMauro Carvalho Chehab  much smaller number, say 256::
903ea272257SMauro Carvalho Chehab
904ea272257SMauro Carvalho Chehab    # echo 'hist:key=child_comm:val=hitcount:size=256' > \
905ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/sched/sched_process_fork/trigger
906ea272257SMauro Carvalho Chehab
907ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/sched/sched_process_fork/hist
908ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=child_comm:vals=hitcount:sort=hitcount:size=256 [active]
909ea272257SMauro Carvalho Chehab
910ea272257SMauro Carvalho Chehab    { child_comm: dconf worker                        } hitcount:          1
911ea272257SMauro Carvalho Chehab    { child_comm: ibus-daemon                         } hitcount:          1
912ea272257SMauro Carvalho Chehab    { child_comm: whoopsie                            } hitcount:          1
913ea272257SMauro Carvalho Chehab    { child_comm: smbd                                } hitcount:          1
914ea272257SMauro Carvalho Chehab    { child_comm: gdbus                               } hitcount:          1
915ea272257SMauro Carvalho Chehab    { child_comm: kthreadd                            } hitcount:          1
916ea272257SMauro Carvalho Chehab    { child_comm: dconf worker                        } hitcount:          1
917ea272257SMauro Carvalho Chehab    { child_comm: evolution-alarm                     } hitcount:          2
918ea272257SMauro Carvalho Chehab    { child_comm: Socket Thread                       } hitcount:          2
919ea272257SMauro Carvalho Chehab    { child_comm: postgres                            } hitcount:          2
920ea272257SMauro Carvalho Chehab    { child_comm: bash                                } hitcount:          3
921ea272257SMauro Carvalho Chehab    { child_comm: compiz                              } hitcount:          3
922ea272257SMauro Carvalho Chehab    { child_comm: evolution-sourc                     } hitcount:          4
923ea272257SMauro Carvalho Chehab    { child_comm: dhclient                            } hitcount:          4
924ea272257SMauro Carvalho Chehab    { child_comm: pool                                } hitcount:          5
925ea272257SMauro Carvalho Chehab    { child_comm: nm-dispatcher.a                     } hitcount:          8
926ea272257SMauro Carvalho Chehab    { child_comm: firefox                             } hitcount:          8
927ea272257SMauro Carvalho Chehab    { child_comm: dbus-daemon                         } hitcount:          8
928ea272257SMauro Carvalho Chehab    { child_comm: glib-pacrunner                      } hitcount:         10
929ea272257SMauro Carvalho Chehab    { child_comm: evolution                           } hitcount:         23
930ea272257SMauro Carvalho Chehab
931ea272257SMauro Carvalho Chehab    Totals:
932ea272257SMauro Carvalho Chehab        Hits: 89
933ea272257SMauro Carvalho Chehab        Entries: 20
934ea272257SMauro Carvalho Chehab        Dropped: 0
935ea272257SMauro Carvalho Chehab
936ea272257SMauro Carvalho Chehab  If we want to pause the hist trigger, we can simply append :pause to
937ea272257SMauro Carvalho Chehab  the command that started the trigger.  Notice that the trigger info
938ea272257SMauro Carvalho Chehab  displays as [paused]::
939ea272257SMauro Carvalho Chehab
940ea272257SMauro Carvalho Chehab    # echo 'hist:key=child_comm:val=hitcount:size=256:pause' >> \
941ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/sched/sched_process_fork/trigger
942ea272257SMauro Carvalho Chehab
943ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/sched/sched_process_fork/hist
944ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=child_comm:vals=hitcount:sort=hitcount:size=256 [paused]
945ea272257SMauro Carvalho Chehab
946ea272257SMauro Carvalho Chehab    { child_comm: dconf worker                        } hitcount:          1
947ea272257SMauro Carvalho Chehab    { child_comm: kthreadd                            } hitcount:          1
948ea272257SMauro Carvalho Chehab    { child_comm: dconf worker                        } hitcount:          1
949ea272257SMauro Carvalho Chehab    { child_comm: gdbus                               } hitcount:          1
950ea272257SMauro Carvalho Chehab    { child_comm: ibus-daemon                         } hitcount:          1
951ea272257SMauro Carvalho Chehab    { child_comm: Socket Thread                       } hitcount:          2
952ea272257SMauro Carvalho Chehab    { child_comm: evolution-alarm                     } hitcount:          2
953ea272257SMauro Carvalho Chehab    { child_comm: smbd                                } hitcount:          2
954ea272257SMauro Carvalho Chehab    { child_comm: bash                                } hitcount:          3
955ea272257SMauro Carvalho Chehab    { child_comm: whoopsie                            } hitcount:          3
956ea272257SMauro Carvalho Chehab    { child_comm: compiz                              } hitcount:          3
957ea272257SMauro Carvalho Chehab    { child_comm: evolution-sourc                     } hitcount:          4
958ea272257SMauro Carvalho Chehab    { child_comm: pool                                } hitcount:          5
959ea272257SMauro Carvalho Chehab    { child_comm: postgres                            } hitcount:          6
960ea272257SMauro Carvalho Chehab    { child_comm: firefox                             } hitcount:          8
961ea272257SMauro Carvalho Chehab    { child_comm: dhclient                            } hitcount:         10
962ea272257SMauro Carvalho Chehab    { child_comm: emacs                               } hitcount:         12
963ea272257SMauro Carvalho Chehab    { child_comm: dbus-daemon                         } hitcount:         20
964ea272257SMauro Carvalho Chehab    { child_comm: nm-dispatcher.a                     } hitcount:         20
965ea272257SMauro Carvalho Chehab    { child_comm: evolution                           } hitcount:         35
966ea272257SMauro Carvalho Chehab    { child_comm: glib-pacrunner                      } hitcount:         59
967ea272257SMauro Carvalho Chehab
968ea272257SMauro Carvalho Chehab    Totals:
969ea272257SMauro Carvalho Chehab        Hits: 199
970ea272257SMauro Carvalho Chehab        Entries: 21
971ea272257SMauro Carvalho Chehab        Dropped: 0
972ea272257SMauro Carvalho Chehab
973ea272257SMauro Carvalho Chehab  To manually continue having the trigger aggregate events, append
974ea272257SMauro Carvalho Chehab  :cont instead.  Notice that the trigger info displays as [active]
975ea272257SMauro Carvalho Chehab  again, and the data has changed::
976ea272257SMauro Carvalho Chehab
977ea272257SMauro Carvalho Chehab    # echo 'hist:key=child_comm:val=hitcount:size=256:cont' >> \
978ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/sched/sched_process_fork/trigger
979ea272257SMauro Carvalho Chehab
980ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/sched/sched_process_fork/hist
981ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=child_comm:vals=hitcount:sort=hitcount:size=256 [active]
982ea272257SMauro Carvalho Chehab
983ea272257SMauro Carvalho Chehab    { child_comm: dconf worker                        } hitcount:          1
984ea272257SMauro Carvalho Chehab    { child_comm: dconf worker                        } hitcount:          1
985ea272257SMauro Carvalho Chehab    { child_comm: kthreadd                            } hitcount:          1
986ea272257SMauro Carvalho Chehab    { child_comm: gdbus                               } hitcount:          1
987ea272257SMauro Carvalho Chehab    { child_comm: ibus-daemon                         } hitcount:          1
988ea272257SMauro Carvalho Chehab    { child_comm: Socket Thread                       } hitcount:          2
989ea272257SMauro Carvalho Chehab    { child_comm: evolution-alarm                     } hitcount:          2
990ea272257SMauro Carvalho Chehab    { child_comm: smbd                                } hitcount:          2
991ea272257SMauro Carvalho Chehab    { child_comm: whoopsie                            } hitcount:          3
992ea272257SMauro Carvalho Chehab    { child_comm: compiz                              } hitcount:          3
993ea272257SMauro Carvalho Chehab    { child_comm: evolution-sourc                     } hitcount:          4
994ea272257SMauro Carvalho Chehab    { child_comm: bash                                } hitcount:          5
995ea272257SMauro Carvalho Chehab    { child_comm: pool                                } hitcount:          5
996ea272257SMauro Carvalho Chehab    { child_comm: postgres                            } hitcount:          6
997ea272257SMauro Carvalho Chehab    { child_comm: firefox                             } hitcount:          8
998ea272257SMauro Carvalho Chehab    { child_comm: dhclient                            } hitcount:         11
999ea272257SMauro Carvalho Chehab    { child_comm: emacs                               } hitcount:         12
1000ea272257SMauro Carvalho Chehab    { child_comm: dbus-daemon                         } hitcount:         22
1001ea272257SMauro Carvalho Chehab    { child_comm: nm-dispatcher.a                     } hitcount:         22
1002ea272257SMauro Carvalho Chehab    { child_comm: evolution                           } hitcount:         35
1003ea272257SMauro Carvalho Chehab    { child_comm: glib-pacrunner                      } hitcount:         59
1004ea272257SMauro Carvalho Chehab
1005ea272257SMauro Carvalho Chehab    Totals:
1006ea272257SMauro Carvalho Chehab        Hits: 206
1007ea272257SMauro Carvalho Chehab        Entries: 21
1008ea272257SMauro Carvalho Chehab        Dropped: 0
1009ea272257SMauro Carvalho Chehab
1010ea272257SMauro Carvalho Chehab  The previous example showed how to start and stop a hist trigger by
1011ea272257SMauro Carvalho Chehab  appending 'pause' and 'continue' to the hist trigger command.  A
1012ea272257SMauro Carvalho Chehab  hist trigger can also be started in a paused state by initially
1013ea272257SMauro Carvalho Chehab  starting the trigger with ':pause' appended.  This allows you to
1014ea272257SMauro Carvalho Chehab  start the trigger only when you're ready to start collecting data
1015ea272257SMauro Carvalho Chehab  and not before.  For example, you could start the trigger in a
1016ea272257SMauro Carvalho Chehab  paused state, then unpause it and do something you want to measure,
1017ea272257SMauro Carvalho Chehab  then pause the trigger again when done.
1018ea272257SMauro Carvalho Chehab
1019ea272257SMauro Carvalho Chehab  Of course, doing this manually can be difficult and error-prone, but
1020ea272257SMauro Carvalho Chehab  it is possible to automatically start and stop a hist trigger based
1021ea272257SMauro Carvalho Chehab  on some condition, via the enable_hist and disable_hist triggers.
1022ea272257SMauro Carvalho Chehab
1023ea272257SMauro Carvalho Chehab  For example, suppose we wanted to take a look at the relative
1024ea272257SMauro Carvalho Chehab  weights in terms of skb length for each callpath that leads to a
1025ea272257SMauro Carvalho Chehab  netif_receieve_skb event when downloading a decent-sized file using
1026ea272257SMauro Carvalho Chehab  wget.
1027ea272257SMauro Carvalho Chehab
1028ea272257SMauro Carvalho Chehab  First we set up an initially paused stacktrace trigger on the
1029ea272257SMauro Carvalho Chehab  netif_receive_skb event::
1030ea272257SMauro Carvalho Chehab
1031ea272257SMauro Carvalho Chehab    # echo 'hist:key=stacktrace:vals=len:pause' > \
1032ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1033ea272257SMauro Carvalho Chehab
1034ea272257SMauro Carvalho Chehab  Next, we set up an 'enable_hist' trigger on the sched_process_exec
1035ea272257SMauro Carvalho Chehab  event, with an 'if filename==/usr/bin/wget' filter.  The effect of
1036ea272257SMauro Carvalho Chehab  this new trigger is that it will 'unpause' the hist trigger we just
1037ea272257SMauro Carvalho Chehab  set up on netif_receive_skb if and only if it sees a
1038ea272257SMauro Carvalho Chehab  sched_process_exec event with a filename of '/usr/bin/wget'.  When
1039ea272257SMauro Carvalho Chehab  that happens, all netif_receive_skb events are aggregated into a
1040ea272257SMauro Carvalho Chehab  hash table keyed on stacktrace::
1041ea272257SMauro Carvalho Chehab
1042ea272257SMauro Carvalho Chehab    # echo 'enable_hist:net:netif_receive_skb if filename==/usr/bin/wget' > \
1043ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/sched/sched_process_exec/trigger
1044ea272257SMauro Carvalho Chehab
1045ea272257SMauro Carvalho Chehab  The aggregation continues until the netif_receive_skb is paused
1046ea272257SMauro Carvalho Chehab  again, which is what the following disable_hist event does by
1047ea272257SMauro Carvalho Chehab  creating a similar setup on the sched_process_exit event, using the
1048ea272257SMauro Carvalho Chehab  filter 'comm==wget'::
1049ea272257SMauro Carvalho Chehab
1050ea272257SMauro Carvalho Chehab    # echo 'disable_hist:net:netif_receive_skb if comm==wget' > \
1051ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/sched/sched_process_exit/trigger
1052ea272257SMauro Carvalho Chehab
1053ea272257SMauro Carvalho Chehab  Whenever a process exits and the comm field of the disable_hist
1054ea272257SMauro Carvalho Chehab  trigger filter matches 'comm==wget', the netif_receive_skb hist
1055ea272257SMauro Carvalho Chehab  trigger is disabled.
1056ea272257SMauro Carvalho Chehab
1057ea272257SMauro Carvalho Chehab  The overall effect is that netif_receive_skb events are aggregated
1058ea272257SMauro Carvalho Chehab  into the hash table for only the duration of the wget.  Executing a
1059ea272257SMauro Carvalho Chehab  wget command and then listing the 'hist' file will display the
1060ea272257SMauro Carvalho Chehab  output generated by the wget command::
1061ea272257SMauro Carvalho Chehab
1062ea272257SMauro Carvalho Chehab    $ wget https://www.kernel.org/pub/linux/kernel/v3.x/patch-3.19.xz
1063ea272257SMauro Carvalho Chehab
1064ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist
1065ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=stacktrace:vals=len:sort=hitcount:size=2048 [paused]
1066ea272257SMauro Carvalho Chehab
1067ea272257SMauro Carvalho Chehab    { stacktrace:
1068ea272257SMauro Carvalho Chehab         __netif_receive_skb_core+0x46d/0x990
1069ea272257SMauro Carvalho Chehab         __netif_receive_skb+0x18/0x60
1070ea272257SMauro Carvalho Chehab         netif_receive_skb_internal+0x23/0x90
1071ea272257SMauro Carvalho Chehab         napi_gro_receive+0xc8/0x100
1072ea272257SMauro Carvalho Chehab         ieee80211_deliver_skb+0xd6/0x270 [mac80211]
1073ea272257SMauro Carvalho Chehab         ieee80211_rx_handlers+0xccf/0x22f0 [mac80211]
1074ea272257SMauro Carvalho Chehab         ieee80211_prepare_and_rx_handle+0x4e7/0xc40 [mac80211]
1075ea272257SMauro Carvalho Chehab         ieee80211_rx+0x31d/0x900 [mac80211]
1076ea272257SMauro Carvalho Chehab         iwlagn_rx_reply_rx+0x3db/0x6f0 [iwldvm]
1077ea272257SMauro Carvalho Chehab         iwl_rx_dispatch+0x8e/0xf0 [iwldvm]
1078ea272257SMauro Carvalho Chehab         iwl_pcie_irq_handler+0xe3c/0x12f0 [iwlwifi]
1079ea272257SMauro Carvalho Chehab         irq_thread_fn+0x20/0x50
1080ea272257SMauro Carvalho Chehab         irq_thread+0x11f/0x150
1081ea272257SMauro Carvalho Chehab         kthread+0xd2/0xf0
1082ea272257SMauro Carvalho Chehab         ret_from_fork+0x42/0x70
1083ea272257SMauro Carvalho Chehab    } hitcount:         85  len:      28884
1084ea272257SMauro Carvalho Chehab    { stacktrace:
1085ea272257SMauro Carvalho Chehab         __netif_receive_skb_core+0x46d/0x990
1086ea272257SMauro Carvalho Chehab         __netif_receive_skb+0x18/0x60
1087ea272257SMauro Carvalho Chehab         netif_receive_skb_internal+0x23/0x90
1088ea272257SMauro Carvalho Chehab         napi_gro_complete+0xa4/0xe0
1089ea272257SMauro Carvalho Chehab         dev_gro_receive+0x23a/0x360
1090ea272257SMauro Carvalho Chehab         napi_gro_receive+0x30/0x100
1091ea272257SMauro Carvalho Chehab         ieee80211_deliver_skb+0xd6/0x270 [mac80211]
1092ea272257SMauro Carvalho Chehab         ieee80211_rx_handlers+0xccf/0x22f0 [mac80211]
1093ea272257SMauro Carvalho Chehab         ieee80211_prepare_and_rx_handle+0x4e7/0xc40 [mac80211]
1094ea272257SMauro Carvalho Chehab         ieee80211_rx+0x31d/0x900 [mac80211]
1095ea272257SMauro Carvalho Chehab         iwlagn_rx_reply_rx+0x3db/0x6f0 [iwldvm]
1096ea272257SMauro Carvalho Chehab         iwl_rx_dispatch+0x8e/0xf0 [iwldvm]
1097ea272257SMauro Carvalho Chehab         iwl_pcie_irq_handler+0xe3c/0x12f0 [iwlwifi]
1098ea272257SMauro Carvalho Chehab         irq_thread_fn+0x20/0x50
1099ea272257SMauro Carvalho Chehab         irq_thread+0x11f/0x150
1100ea272257SMauro Carvalho Chehab         kthread+0xd2/0xf0
1101ea272257SMauro Carvalho Chehab    } hitcount:         98  len:     664329
1102ea272257SMauro Carvalho Chehab    { stacktrace:
1103ea272257SMauro Carvalho Chehab         __netif_receive_skb_core+0x46d/0x990
1104ea272257SMauro Carvalho Chehab         __netif_receive_skb+0x18/0x60
1105ea272257SMauro Carvalho Chehab         process_backlog+0xa8/0x150
1106ea272257SMauro Carvalho Chehab         net_rx_action+0x15d/0x340
1107ea272257SMauro Carvalho Chehab         __do_softirq+0x114/0x2c0
1108ea272257SMauro Carvalho Chehab         do_softirq_own_stack+0x1c/0x30
1109ea272257SMauro Carvalho Chehab         do_softirq+0x65/0x70
1110ea272257SMauro Carvalho Chehab         __local_bh_enable_ip+0xb5/0xc0
1111ea272257SMauro Carvalho Chehab         ip_finish_output+0x1f4/0x840
1112ea272257SMauro Carvalho Chehab         ip_output+0x6b/0xc0
1113ea272257SMauro Carvalho Chehab         ip_local_out_sk+0x31/0x40
1114ea272257SMauro Carvalho Chehab         ip_send_skb+0x1a/0x50
1115ea272257SMauro Carvalho Chehab         udp_send_skb+0x173/0x2a0
1116ea272257SMauro Carvalho Chehab         udp_sendmsg+0x2bf/0x9f0
1117ea272257SMauro Carvalho Chehab         inet_sendmsg+0x64/0xa0
1118ea272257SMauro Carvalho Chehab         sock_sendmsg+0x3d/0x50
1119ea272257SMauro Carvalho Chehab    } hitcount:        115  len:      13030
1120ea272257SMauro Carvalho Chehab    { stacktrace:
1121ea272257SMauro Carvalho Chehab         __netif_receive_skb_core+0x46d/0x990
1122ea272257SMauro Carvalho Chehab         __netif_receive_skb+0x18/0x60
1123ea272257SMauro Carvalho Chehab         netif_receive_skb_internal+0x23/0x90
1124ea272257SMauro Carvalho Chehab         napi_gro_complete+0xa4/0xe0
1125ea272257SMauro Carvalho Chehab         napi_gro_flush+0x6d/0x90
1126ea272257SMauro Carvalho Chehab         iwl_pcie_irq_handler+0x92a/0x12f0 [iwlwifi]
1127ea272257SMauro Carvalho Chehab         irq_thread_fn+0x20/0x50
1128ea272257SMauro Carvalho Chehab         irq_thread+0x11f/0x150
1129ea272257SMauro Carvalho Chehab         kthread+0xd2/0xf0
1130ea272257SMauro Carvalho Chehab         ret_from_fork+0x42/0x70
1131ea272257SMauro Carvalho Chehab    } hitcount:        934  len:    5512212
1132ea272257SMauro Carvalho Chehab
1133ea272257SMauro Carvalho Chehab    Totals:
1134ea272257SMauro Carvalho Chehab        Hits: 1232
1135ea272257SMauro Carvalho Chehab        Entries: 4
1136ea272257SMauro Carvalho Chehab        Dropped: 0
1137ea272257SMauro Carvalho Chehab
1138ea272257SMauro Carvalho Chehab  The above shows all the netif_receive_skb callpaths and their total
1139ea272257SMauro Carvalho Chehab  lengths for the duration of the wget command.
1140ea272257SMauro Carvalho Chehab
1141ea272257SMauro Carvalho Chehab  The 'clear' hist trigger param can be used to clear the hash table.
1142ea272257SMauro Carvalho Chehab  Suppose we wanted to try another run of the previous example but
1143ea272257SMauro Carvalho Chehab  this time also wanted to see the complete list of events that went
1144ea272257SMauro Carvalho Chehab  into the histogram.  In order to avoid having to set everything up
1145ea272257SMauro Carvalho Chehab  again, we can just clear the histogram first::
1146ea272257SMauro Carvalho Chehab
1147ea272257SMauro Carvalho Chehab    # echo 'hist:key=stacktrace:vals=len:clear' >> \
1148ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1149ea272257SMauro Carvalho Chehab
1150ea272257SMauro Carvalho Chehab  Just to verify that it is in fact cleared, here's what we now see in
1151ea272257SMauro Carvalho Chehab  the hist file::
1152ea272257SMauro Carvalho Chehab
1153ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist
1154ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=stacktrace:vals=len:sort=hitcount:size=2048 [paused]
1155ea272257SMauro Carvalho Chehab
1156ea272257SMauro Carvalho Chehab    Totals:
1157ea272257SMauro Carvalho Chehab        Hits: 0
1158ea272257SMauro Carvalho Chehab        Entries: 0
1159ea272257SMauro Carvalho Chehab        Dropped: 0
1160ea272257SMauro Carvalho Chehab
1161ea272257SMauro Carvalho Chehab  Since we want to see the detailed list of every netif_receive_skb
1162ea272257SMauro Carvalho Chehab  event occurring during the new run, which are in fact the same
1163ea272257SMauro Carvalho Chehab  events being aggregated into the hash table, we add some additional
1164ea272257SMauro Carvalho Chehab  'enable_event' events to the triggering sched_process_exec and
1165ea272257SMauro Carvalho Chehab  sched_process_exit events as such::
1166ea272257SMauro Carvalho Chehab
1167ea272257SMauro Carvalho Chehab    # echo 'enable_event:net:netif_receive_skb if filename==/usr/bin/wget' > \
1168ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/sched/sched_process_exec/trigger
1169ea272257SMauro Carvalho Chehab
1170ea272257SMauro Carvalho Chehab    # echo 'disable_event:net:netif_receive_skb if comm==wget' > \
1171ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/sched/sched_process_exit/trigger
1172ea272257SMauro Carvalho Chehab
1173ea272257SMauro Carvalho Chehab  If you read the trigger files for the sched_process_exec and
1174ea272257SMauro Carvalho Chehab  sched_process_exit triggers, you should see two triggers for each:
1175ea272257SMauro Carvalho Chehab  one enabling/disabling the hist aggregation and the other
1176ea272257SMauro Carvalho Chehab  enabling/disabling the logging of events::
1177ea272257SMauro Carvalho Chehab
1178ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/sched/sched_process_exec/trigger
1179ea272257SMauro Carvalho Chehab    enable_event:net:netif_receive_skb:unlimited if filename==/usr/bin/wget
1180ea272257SMauro Carvalho Chehab    enable_hist:net:netif_receive_skb:unlimited if filename==/usr/bin/wget
1181ea272257SMauro Carvalho Chehab
1182ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/sched/sched_process_exit/trigger
1183ea272257SMauro Carvalho Chehab    enable_event:net:netif_receive_skb:unlimited if comm==wget
1184ea272257SMauro Carvalho Chehab    disable_hist:net:netif_receive_skb:unlimited if comm==wget
1185ea272257SMauro Carvalho Chehab
1186ea272257SMauro Carvalho Chehab  In other words, whenever either of the sched_process_exec or
1187ea272257SMauro Carvalho Chehab  sched_process_exit events is hit and matches 'wget', it enables or
1188ea272257SMauro Carvalho Chehab  disables both the histogram and the event log, and what you end up
1189ea272257SMauro Carvalho Chehab  with is a hash table and set of events just covering the specified
1190ea272257SMauro Carvalho Chehab  duration.  Run the wget command again::
1191ea272257SMauro Carvalho Chehab
1192ea272257SMauro Carvalho Chehab    $ wget https://www.kernel.org/pub/linux/kernel/v3.x/patch-3.19.xz
1193ea272257SMauro Carvalho Chehab
1194ea272257SMauro Carvalho Chehab  Displaying the 'hist' file should show something similar to what you
1195ea272257SMauro Carvalho Chehab  saw in the last run, but this time you should also see the
1196ea272257SMauro Carvalho Chehab  individual events in the trace file::
1197ea272257SMauro Carvalho Chehab
1198ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/trace
1199ea272257SMauro Carvalho Chehab
1200ea272257SMauro Carvalho Chehab    # tracer: nop
1201ea272257SMauro Carvalho Chehab    #
1202ea272257SMauro Carvalho Chehab    # entries-in-buffer/entries-written: 183/1426   #P:4
1203ea272257SMauro Carvalho Chehab    #
1204ea272257SMauro Carvalho Chehab    #                              _-----=> irqs-off
1205ea272257SMauro Carvalho Chehab    #                             / _----=> need-resched
1206ea272257SMauro Carvalho Chehab    #                            | / _---=> hardirq/softirq
1207ea272257SMauro Carvalho Chehab    #                            || / _--=> preempt-depth
1208ea272257SMauro Carvalho Chehab    #                            ||| /     delay
1209ea272257SMauro Carvalho Chehab    #           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
1210ea272257SMauro Carvalho Chehab    #              | |       |   ||||       |         |
1211ea272257SMauro Carvalho Chehab                wget-15108 [000] ..s1 31769.606929: netif_receive_skb: dev=lo skbaddr=ffff88009c353100 len=60
1212ea272257SMauro Carvalho Chehab                wget-15108 [000] ..s1 31769.606999: netif_receive_skb: dev=lo skbaddr=ffff88009c353200 len=60
1213ea272257SMauro Carvalho Chehab             dnsmasq-1382  [000] ..s1 31769.677652: netif_receive_skb: dev=lo skbaddr=ffff88009c352b00 len=130
1214ea272257SMauro Carvalho Chehab             dnsmasq-1382  [000] ..s1 31769.685917: netif_receive_skb: dev=lo skbaddr=ffff88009c352200 len=138
1215ea272257SMauro Carvalho Chehab    ##### CPU 2 buffer started ####
1216ea272257SMauro Carvalho Chehab      irq/29-iwlwifi-559   [002] ..s. 31772.031529: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d433d00 len=2948
1217ea272257SMauro Carvalho Chehab      irq/29-iwlwifi-559   [002] ..s. 31772.031572: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d432200 len=1500
1218ea272257SMauro Carvalho Chehab      irq/29-iwlwifi-559   [002] ..s. 31772.032196: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d433100 len=2948
1219ea272257SMauro Carvalho Chehab      irq/29-iwlwifi-559   [002] ..s. 31772.032761: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d433000 len=2948
1220ea272257SMauro Carvalho Chehab      irq/29-iwlwifi-559   [002] ..s. 31772.033220: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d432e00 len=1500
1221ea272257SMauro Carvalho Chehab    .
1222ea272257SMauro Carvalho Chehab    .
1223ea272257SMauro Carvalho Chehab    .
1224ea272257SMauro Carvalho Chehab
1225ea272257SMauro Carvalho Chehab  The following example demonstrates how multiple hist triggers can be
1226ea272257SMauro Carvalho Chehab  attached to a given event.  This capability can be useful for
1227ea272257SMauro Carvalho Chehab  creating a set of different summaries derived from the same set of
1228ea272257SMauro Carvalho Chehab  events, or for comparing the effects of different filters, among
1229ea272257SMauro Carvalho Chehab  other things::
1230ea272257SMauro Carvalho Chehab
1231ea272257SMauro Carvalho Chehab    # echo 'hist:keys=skbaddr.hex:vals=len if len < 0' >> \
1232ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1233ea272257SMauro Carvalho Chehab    # echo 'hist:keys=skbaddr.hex:vals=len if len > 4096' >> \
1234ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1235ea272257SMauro Carvalho Chehab    # echo 'hist:keys=skbaddr.hex:vals=len if len == 256' >> \
1236ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1237ea272257SMauro Carvalho Chehab    # echo 'hist:keys=skbaddr.hex:vals=len' >> \
1238ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1239ea272257SMauro Carvalho Chehab    # echo 'hist:keys=len:vals=common_preempt_count' >> \
1240ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1241ea272257SMauro Carvalho Chehab
1242ea272257SMauro Carvalho Chehab  The above set of commands create four triggers differing only in
1243ea272257SMauro Carvalho Chehab  their filters, along with a completely different though fairly
1244ea272257SMauro Carvalho Chehab  nonsensical trigger.  Note that in order to append multiple hist
1245ea272257SMauro Carvalho Chehab  triggers to the same file, you should use the '>>' operator to
1246ea272257SMauro Carvalho Chehab  append them ('>' will also add the new hist trigger, but will remove
1247ea272257SMauro Carvalho Chehab  any existing hist triggers beforehand).
1248ea272257SMauro Carvalho Chehab
1249ea272257SMauro Carvalho Chehab  Displaying the contents of the 'hist' file for the event shows the
1250ea272257SMauro Carvalho Chehab  contents of all five histograms::
1251ea272257SMauro Carvalho Chehab
1252ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist
1253ea272257SMauro Carvalho Chehab
1254ea272257SMauro Carvalho Chehab    # event histogram
1255ea272257SMauro Carvalho Chehab    #
1256ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=len:vals=hitcount,common_preempt_count:sort=hitcount:size=2048 [active]
1257ea272257SMauro Carvalho Chehab    #
1258ea272257SMauro Carvalho Chehab
1259ea272257SMauro Carvalho Chehab    { len:        176 } hitcount:          1  common_preempt_count:          0
1260ea272257SMauro Carvalho Chehab    { len:        223 } hitcount:          1  common_preempt_count:          0
1261ea272257SMauro Carvalho Chehab    { len:       4854 } hitcount:          1  common_preempt_count:          0
1262ea272257SMauro Carvalho Chehab    { len:        395 } hitcount:          1  common_preempt_count:          0
1263ea272257SMauro Carvalho Chehab    { len:        177 } hitcount:          1  common_preempt_count:          0
1264ea272257SMauro Carvalho Chehab    { len:        446 } hitcount:          1  common_preempt_count:          0
1265ea272257SMauro Carvalho Chehab    { len:       1601 } hitcount:          1  common_preempt_count:          0
1266ea272257SMauro Carvalho Chehab    .
1267ea272257SMauro Carvalho Chehab    .
1268ea272257SMauro Carvalho Chehab    .
1269ea272257SMauro Carvalho Chehab    { len:       1280 } hitcount:         66  common_preempt_count:          0
1270ea272257SMauro Carvalho Chehab    { len:        116 } hitcount:         81  common_preempt_count:         40
1271ea272257SMauro Carvalho Chehab    { len:        708 } hitcount:        112  common_preempt_count:          0
1272ea272257SMauro Carvalho Chehab    { len:         46 } hitcount:        221  common_preempt_count:          0
1273ea272257SMauro Carvalho Chehab    { len:       1264 } hitcount:        458  common_preempt_count:          0
1274ea272257SMauro Carvalho Chehab
1275ea272257SMauro Carvalho Chehab    Totals:
1276ea272257SMauro Carvalho Chehab        Hits: 1428
1277ea272257SMauro Carvalho Chehab        Entries: 147
1278ea272257SMauro Carvalho Chehab        Dropped: 0
1279ea272257SMauro Carvalho Chehab
1280ea272257SMauro Carvalho Chehab
1281ea272257SMauro Carvalho Chehab    # event histogram
1282ea272257SMauro Carvalho Chehab    #
1283ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active]
1284ea272257SMauro Carvalho Chehab    #
1285ea272257SMauro Carvalho Chehab
1286ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800baee5e00 } hitcount:          1  len:        130
1287ea272257SMauro Carvalho Chehab    { skbaddr: ffff88005f3d5600 } hitcount:          1  len:       1280
1288ea272257SMauro Carvalho Chehab    { skbaddr: ffff88005f3d4900 } hitcount:          1  len:       1280
1289ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fed6300 } hitcount:          1  len:        115
1290ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0ad00 } hitcount:          1  len:        115
1291ea272257SMauro Carvalho Chehab    { skbaddr: ffff88008cdb1900 } hitcount:          1  len:         46
1292ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064b5ef00 } hitcount:          1  len:        118
1293ea272257SMauro Carvalho Chehab    { skbaddr: ffff880044e3c700 } hitcount:          1  len:         60
1294ea272257SMauro Carvalho Chehab    { skbaddr: ffff880100065900 } hitcount:          1  len:         46
1295ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d46bd500 } hitcount:          1  len:        116
1296ea272257SMauro Carvalho Chehab    { skbaddr: ffff88005f3d5f00 } hitcount:          1  len:       1280
1297ea272257SMauro Carvalho Chehab    { skbaddr: ffff880100064700 } hitcount:          1  len:        365
1298ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800badb6f00 } hitcount:          1  len:         60
1299ea272257SMauro Carvalho Chehab    .
1300ea272257SMauro Carvalho Chehab    .
1301ea272257SMauro Carvalho Chehab    .
1302ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0be00 } hitcount:         27  len:      24677
1303ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0a400 } hitcount:         27  len:      23052
1304ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0b700 } hitcount:         31  len:      25589
1305ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0b600 } hitcount:         32  len:      27326
1306ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a462800 } hitcount:         68  len:      71678
1307ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a463700 } hitcount:         70  len:      72678
1308ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a462b00 } hitcount:         71  len:      77589
1309ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a463600 } hitcount:         73  len:      71307
1310ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a462200 } hitcount:         81  len:      81032
1311ea272257SMauro Carvalho Chehab
1312ea272257SMauro Carvalho Chehab    Totals:
1313ea272257SMauro Carvalho Chehab        Hits: 1451
1314ea272257SMauro Carvalho Chehab        Entries: 318
1315ea272257SMauro Carvalho Chehab        Dropped: 0
1316ea272257SMauro Carvalho Chehab
1317ea272257SMauro Carvalho Chehab
1318ea272257SMauro Carvalho Chehab    # event histogram
1319ea272257SMauro Carvalho Chehab    #
1320ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len == 256 [active]
1321ea272257SMauro Carvalho Chehab    #
1322ea272257SMauro Carvalho Chehab
1323ea272257SMauro Carvalho Chehab
1324ea272257SMauro Carvalho Chehab    Totals:
1325ea272257SMauro Carvalho Chehab        Hits: 0
1326ea272257SMauro Carvalho Chehab        Entries: 0
1327ea272257SMauro Carvalho Chehab        Dropped: 0
1328ea272257SMauro Carvalho Chehab
1329ea272257SMauro Carvalho Chehab
1330ea272257SMauro Carvalho Chehab    # event histogram
1331ea272257SMauro Carvalho Chehab    #
1332ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len > 4096 [active]
1333ea272257SMauro Carvalho Chehab    #
1334ea272257SMauro Carvalho Chehab
1335ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fd2c300 } hitcount:          1  len:       7212
1336ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcce00 } hitcount:          1  len:       7212
1337ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcd700 } hitcount:          1  len:       7212
1338ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcda00 } hitcount:          1  len:      21492
1339ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800ae2e2d00 } hitcount:          1  len:       7212
1340ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcdb00 } hitcount:          1  len:       7212
1341ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a4df500 } hitcount:          1  len:       4854
1342ea272257SMauro Carvalho Chehab    { skbaddr: ffff88008ce47b00 } hitcount:          1  len:      18636
1343ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800ae2e2200 } hitcount:          1  len:      12924
1344ea272257SMauro Carvalho Chehab    { skbaddr: ffff88005f3e1000 } hitcount:          1  len:       4356
1345ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcdc00 } hitcount:          2  len:      24420
1346ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcc200 } hitcount:          2  len:      12996
1347ea272257SMauro Carvalho Chehab
1348ea272257SMauro Carvalho Chehab    Totals:
1349ea272257SMauro Carvalho Chehab        Hits: 14
1350ea272257SMauro Carvalho Chehab        Entries: 12
1351ea272257SMauro Carvalho Chehab        Dropped: 0
1352ea272257SMauro Carvalho Chehab
1353ea272257SMauro Carvalho Chehab
1354ea272257SMauro Carvalho Chehab    # event histogram
1355ea272257SMauro Carvalho Chehab    #
1356ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len < 0 [active]
1357ea272257SMauro Carvalho Chehab    #
1358ea272257SMauro Carvalho Chehab
1359ea272257SMauro Carvalho Chehab
1360ea272257SMauro Carvalho Chehab    Totals:
1361ea272257SMauro Carvalho Chehab        Hits: 0
1362ea272257SMauro Carvalho Chehab        Entries: 0
1363ea272257SMauro Carvalho Chehab        Dropped: 0
1364ea272257SMauro Carvalho Chehab
1365ea272257SMauro Carvalho Chehab  Named triggers can be used to have triggers share a common set of
1366ea272257SMauro Carvalho Chehab  histogram data.  This capability is mostly useful for combining the
1367ea272257SMauro Carvalho Chehab  output of events generated by tracepoints contained inside inline
1368ea272257SMauro Carvalho Chehab  functions, but names can be used in a hist trigger on any event.
1369ea272257SMauro Carvalho Chehab  For example, these two triggers when hit will update the same 'len'
1370ea272257SMauro Carvalho Chehab  field in the shared 'foo' histogram data::
1371ea272257SMauro Carvalho Chehab
1372ea272257SMauro Carvalho Chehab    # echo 'hist:name=foo:keys=skbaddr.hex:vals=len' > \
1373ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1374ea272257SMauro Carvalho Chehab    # echo 'hist:name=foo:keys=skbaddr.hex:vals=len' > \
1375ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/net/netif_rx/trigger
1376ea272257SMauro Carvalho Chehab
1377ea272257SMauro Carvalho Chehab  You can see that they're updating common histogram data by reading
1378ea272257SMauro Carvalho Chehab  each event's hist files at the same time::
1379ea272257SMauro Carvalho Chehab
1380ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist;
1381ea272257SMauro Carvalho Chehab      cat /sys/kernel/debug/tracing/events/net/netif_rx/hist
1382ea272257SMauro Carvalho Chehab
1383ea272257SMauro Carvalho Chehab    # event histogram
1384ea272257SMauro Carvalho Chehab    #
1385ea272257SMauro Carvalho Chehab    # trigger info: hist:name=foo:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active]
1386ea272257SMauro Carvalho Chehab    #
1387ea272257SMauro Carvalho Chehab
1388ea272257SMauro Carvalho Chehab    { skbaddr: ffff88000ad53500 } hitcount:          1  len:         46
1389ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800af5a1500 } hitcount:          1  len:         76
1390ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d62a1900 } hitcount:          1  len:         46
1391ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bccb00 } hitcount:          1  len:        468
1392ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d3c69900 } hitcount:          1  len:         46
1393ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009ff09100 } hitcount:          1  len:         52
1394ea272257SMauro Carvalho Chehab    { skbaddr: ffff88010f13ab00 } hitcount:          1  len:        168
1395ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a54f400 } hitcount:          1  len:         46
1396ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcc500 } hitcount:          1  len:        260
1397ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064505000 } hitcount:          1  len:         46
1398ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800baf24e00 } hitcount:          1  len:         32
1399ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0ad00 } hitcount:          1  len:         46
1400ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d3edff00 } hitcount:          1  len:         44
1401ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0b400 } hitcount:          1  len:        168
1402ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1c55a00 } hitcount:          1  len:         40
1403ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcd100 } hitcount:          1  len:         40
1404ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064505f00 } hitcount:          1  len:        174
1405ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bff200 } hitcount:          1  len:        160
1406ea272257SMauro Carvalho Chehab    { skbaddr: ffff880044e3cc00 } hitcount:          1  len:         76
1407ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bfe700 } hitcount:          1  len:         46
1408ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcdc00 } hitcount:          1  len:         32
1409ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f64800 } hitcount:          1  len:         46
1410ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcde00 } hitcount:          1  len:        988
1411ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a5dea00 } hitcount:          1  len:         46
1412ea272257SMauro Carvalho Chehab    { skbaddr: ffff88002e37a200 } hitcount:          1  len:         44
1413ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f32c00 } hitcount:          2  len:        676
1414ea272257SMauro Carvalho Chehab    { skbaddr: ffff88000ad52600 } hitcount:          2  len:        107
1415ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f91e00 } hitcount:          2  len:         92
1416ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800af5a0200 } hitcount:          2  len:        142
1417ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcc600 } hitcount:          2  len:        220
1418ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800ba36f500 } hitcount:          2  len:         92
1419ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d021f800 } hitcount:          2  len:         92
1420ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f33600 } hitcount:          2  len:        675
1421ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bfff00 } hitcount:          3  len:        138
1422ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d62a1300 } hitcount:          3  len:        138
1423ea272257SMauro Carvalho Chehab    { skbaddr: ffff88002e37a100 } hitcount:          4  len:        184
1424ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064504400 } hitcount:          4  len:        184
1425ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bfec00 } hitcount:          4  len:        184
1426ea272257SMauro Carvalho Chehab    { skbaddr: ffff88000ad53700 } hitcount:          5  len:        230
1427ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcdb00 } hitcount:          5  len:        196
1428ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f90000 } hitcount:          6  len:        276
1429ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a54f900 } hitcount:          6  len:        276
1430ea272257SMauro Carvalho Chehab
1431ea272257SMauro Carvalho Chehab    Totals:
1432ea272257SMauro Carvalho Chehab        Hits: 81
1433ea272257SMauro Carvalho Chehab        Entries: 42
1434ea272257SMauro Carvalho Chehab        Dropped: 0
1435ea272257SMauro Carvalho Chehab    # event histogram
1436ea272257SMauro Carvalho Chehab    #
1437ea272257SMauro Carvalho Chehab    # trigger info: hist:name=foo:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active]
1438ea272257SMauro Carvalho Chehab    #
1439ea272257SMauro Carvalho Chehab
1440ea272257SMauro Carvalho Chehab    { skbaddr: ffff88000ad53500 } hitcount:          1  len:         46
1441ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800af5a1500 } hitcount:          1  len:         76
1442ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d62a1900 } hitcount:          1  len:         46
1443ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bccb00 } hitcount:          1  len:        468
1444ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d3c69900 } hitcount:          1  len:         46
1445ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009ff09100 } hitcount:          1  len:         52
1446ea272257SMauro Carvalho Chehab    { skbaddr: ffff88010f13ab00 } hitcount:          1  len:        168
1447ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a54f400 } hitcount:          1  len:         46
1448ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcc500 } hitcount:          1  len:        260
1449ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064505000 } hitcount:          1  len:         46
1450ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800baf24e00 } hitcount:          1  len:         32
1451ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0ad00 } hitcount:          1  len:         46
1452ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d3edff00 } hitcount:          1  len:         44
1453ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0b400 } hitcount:          1  len:        168
1454ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1c55a00 } hitcount:          1  len:         40
1455ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcd100 } hitcount:          1  len:         40
1456ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064505f00 } hitcount:          1  len:        174
1457ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bff200 } hitcount:          1  len:        160
1458ea272257SMauro Carvalho Chehab    { skbaddr: ffff880044e3cc00 } hitcount:          1  len:         76
1459ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bfe700 } hitcount:          1  len:         46
1460ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcdc00 } hitcount:          1  len:         32
1461ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f64800 } hitcount:          1  len:         46
1462ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcde00 } hitcount:          1  len:        988
1463ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a5dea00 } hitcount:          1  len:         46
1464ea272257SMauro Carvalho Chehab    { skbaddr: ffff88002e37a200 } hitcount:          1  len:         44
1465ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f32c00 } hitcount:          2  len:        676
1466ea272257SMauro Carvalho Chehab    { skbaddr: ffff88000ad52600 } hitcount:          2  len:        107
1467ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f91e00 } hitcount:          2  len:         92
1468ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800af5a0200 } hitcount:          2  len:        142
1469ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcc600 } hitcount:          2  len:        220
1470ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800ba36f500 } hitcount:          2  len:         92
1471ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d021f800 } hitcount:          2  len:         92
1472ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f33600 } hitcount:          2  len:        675
1473ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bfff00 } hitcount:          3  len:        138
1474ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d62a1300 } hitcount:          3  len:        138
1475ea272257SMauro Carvalho Chehab    { skbaddr: ffff88002e37a100 } hitcount:          4  len:        184
1476ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064504400 } hitcount:          4  len:        184
1477ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bfec00 } hitcount:          4  len:        184
1478ea272257SMauro Carvalho Chehab    { skbaddr: ffff88000ad53700 } hitcount:          5  len:        230
1479ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcdb00 } hitcount:          5  len:        196
1480ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f90000 } hitcount:          6  len:        276
1481ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a54f900 } hitcount:          6  len:        276
1482ea272257SMauro Carvalho Chehab
1483ea272257SMauro Carvalho Chehab    Totals:
1484ea272257SMauro Carvalho Chehab        Hits: 81
1485ea272257SMauro Carvalho Chehab        Entries: 42
1486ea272257SMauro Carvalho Chehab        Dropped: 0
1487ea272257SMauro Carvalho Chehab
1488ea272257SMauro Carvalho Chehab  And here's an example that shows how to combine histogram data from
1489ea272257SMauro Carvalho Chehab  any two events even if they don't share any 'compatible' fields
1490ea272257SMauro Carvalho Chehab  other than 'hitcount' and 'stacktrace'.  These commands create a
1491ea272257SMauro Carvalho Chehab  couple of triggers named 'bar' using those fields::
1492ea272257SMauro Carvalho Chehab
1493ea272257SMauro Carvalho Chehab    # echo 'hist:name=bar:key=stacktrace:val=hitcount' > \
1494ea272257SMauro Carvalho Chehab           /sys/kernel/debug/tracing/events/sched/sched_process_fork/trigger
1495ea272257SMauro Carvalho Chehab    # echo 'hist:name=bar:key=stacktrace:val=hitcount' > \
1496ea272257SMauro Carvalho Chehab          /sys/kernel/debug/tracing/events/net/netif_rx/trigger
1497ea272257SMauro Carvalho Chehab
1498ea272257SMauro Carvalho Chehab  And displaying the output of either shows some interesting if
1499ea272257SMauro Carvalho Chehab  somewhat confusing output::
1500ea272257SMauro Carvalho Chehab
1501ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/sched/sched_process_fork/hist
1502ea272257SMauro Carvalho Chehab    # cat /sys/kernel/debug/tracing/events/net/netif_rx/hist
1503ea272257SMauro Carvalho Chehab
1504ea272257SMauro Carvalho Chehab    # event histogram
1505ea272257SMauro Carvalho Chehab    #
1506ea272257SMauro Carvalho Chehab    # trigger info: hist:name=bar:keys=stacktrace:vals=hitcount:sort=hitcount:size=2048 [active]
1507ea272257SMauro Carvalho Chehab    #
1508ea272257SMauro Carvalho Chehab
1509ea272257SMauro Carvalho Chehab    { stacktrace:
1510ea272257SMauro Carvalho Chehab             _do_fork+0x18e/0x330
1511ea272257SMauro Carvalho Chehab             kernel_thread+0x29/0x30
1512ea272257SMauro Carvalho Chehab             kthreadd+0x154/0x1b0
1513ea272257SMauro Carvalho Chehab             ret_from_fork+0x3f/0x70
1514ea272257SMauro Carvalho Chehab    } hitcount:          1
1515ea272257SMauro Carvalho Chehab    { stacktrace:
1516ea272257SMauro Carvalho Chehab             netif_rx_internal+0xb2/0xd0
1517ea272257SMauro Carvalho Chehab             netif_rx_ni+0x20/0x70
1518ea272257SMauro Carvalho Chehab             dev_loopback_xmit+0xaa/0xd0
1519ea272257SMauro Carvalho Chehab             ip_mc_output+0x126/0x240
1520ea272257SMauro Carvalho Chehab             ip_local_out_sk+0x31/0x40
1521ea272257SMauro Carvalho Chehab             igmp_send_report+0x1e9/0x230
1522ea272257SMauro Carvalho Chehab             igmp_timer_expire+0xe9/0x120
1523ea272257SMauro Carvalho Chehab             call_timer_fn+0x39/0xf0
1524ea272257SMauro Carvalho Chehab             run_timer_softirq+0x1e1/0x290
1525ea272257SMauro Carvalho Chehab             __do_softirq+0xfd/0x290
1526ea272257SMauro Carvalho Chehab             irq_exit+0x98/0xb0
1527ea272257SMauro Carvalho Chehab             smp_apic_timer_interrupt+0x4a/0x60
1528ea272257SMauro Carvalho Chehab             apic_timer_interrupt+0x6d/0x80
1529ea272257SMauro Carvalho Chehab             cpuidle_enter+0x17/0x20
1530ea272257SMauro Carvalho Chehab             call_cpuidle+0x3b/0x60
1531ea272257SMauro Carvalho Chehab             cpu_startup_entry+0x22d/0x310
1532ea272257SMauro Carvalho Chehab    } hitcount:          1
1533ea272257SMauro Carvalho Chehab    { stacktrace:
1534ea272257SMauro Carvalho Chehab             netif_rx_internal+0xb2/0xd0
1535ea272257SMauro Carvalho Chehab             netif_rx_ni+0x20/0x70
1536ea272257SMauro Carvalho Chehab             dev_loopback_xmit+0xaa/0xd0
1537ea272257SMauro Carvalho Chehab             ip_mc_output+0x17f/0x240
1538ea272257SMauro Carvalho Chehab             ip_local_out_sk+0x31/0x40
1539ea272257SMauro Carvalho Chehab             ip_send_skb+0x1a/0x50
1540ea272257SMauro Carvalho Chehab             udp_send_skb+0x13e/0x270
1541ea272257SMauro Carvalho Chehab             udp_sendmsg+0x2bf/0x980
1542ea272257SMauro Carvalho Chehab             inet_sendmsg+0x67/0xa0
1543ea272257SMauro Carvalho Chehab             sock_sendmsg+0x38/0x50
1544ea272257SMauro Carvalho Chehab             SYSC_sendto+0xef/0x170
1545ea272257SMauro Carvalho Chehab             SyS_sendto+0xe/0x10
1546ea272257SMauro Carvalho Chehab             entry_SYSCALL_64_fastpath+0x12/0x6a
1547ea272257SMauro Carvalho Chehab    } hitcount:          2
1548ea272257SMauro Carvalho Chehab    { stacktrace:
1549ea272257SMauro Carvalho Chehab             netif_rx_internal+0xb2/0xd0
1550ea272257SMauro Carvalho Chehab             netif_rx+0x1c/0x60
1551ea272257SMauro Carvalho Chehab             loopback_xmit+0x6c/0xb0
1552ea272257SMauro Carvalho Chehab             dev_hard_start_xmit+0x219/0x3a0
1553ea272257SMauro Carvalho Chehab             __dev_queue_xmit+0x415/0x4f0
1554ea272257SMauro Carvalho Chehab             dev_queue_xmit_sk+0x13/0x20
1555ea272257SMauro Carvalho Chehab             ip_finish_output2+0x237/0x340
1556ea272257SMauro Carvalho Chehab             ip_finish_output+0x113/0x1d0
1557ea272257SMauro Carvalho Chehab             ip_output+0x66/0xc0
1558ea272257SMauro Carvalho Chehab             ip_local_out_sk+0x31/0x40
1559ea272257SMauro Carvalho Chehab             ip_send_skb+0x1a/0x50
1560ea272257SMauro Carvalho Chehab             udp_send_skb+0x16d/0x270
1561ea272257SMauro Carvalho Chehab             udp_sendmsg+0x2bf/0x980
1562ea272257SMauro Carvalho Chehab             inet_sendmsg+0x67/0xa0
1563ea272257SMauro Carvalho Chehab             sock_sendmsg+0x38/0x50
1564ea272257SMauro Carvalho Chehab             ___sys_sendmsg+0x14e/0x270
1565ea272257SMauro Carvalho Chehab    } hitcount:         76
1566ea272257SMauro Carvalho Chehab    { stacktrace:
1567ea272257SMauro Carvalho Chehab             netif_rx_internal+0xb2/0xd0
1568ea272257SMauro Carvalho Chehab             netif_rx+0x1c/0x60
1569ea272257SMauro Carvalho Chehab             loopback_xmit+0x6c/0xb0
1570ea272257SMauro Carvalho Chehab             dev_hard_start_xmit+0x219/0x3a0
1571ea272257SMauro Carvalho Chehab             __dev_queue_xmit+0x415/0x4f0
1572ea272257SMauro Carvalho Chehab             dev_queue_xmit_sk+0x13/0x20
1573ea272257SMauro Carvalho Chehab             ip_finish_output2+0x237/0x340
1574ea272257SMauro Carvalho Chehab             ip_finish_output+0x113/0x1d0
1575ea272257SMauro Carvalho Chehab             ip_output+0x66/0xc0
1576ea272257SMauro Carvalho Chehab             ip_local_out_sk+0x31/0x40
1577ea272257SMauro Carvalho Chehab             ip_send_skb+0x1a/0x50
1578ea272257SMauro Carvalho Chehab             udp_send_skb+0x16d/0x270
1579ea272257SMauro Carvalho Chehab             udp_sendmsg+0x2bf/0x980
1580ea272257SMauro Carvalho Chehab             inet_sendmsg+0x67/0xa0
1581ea272257SMauro Carvalho Chehab             sock_sendmsg+0x38/0x50
1582ea272257SMauro Carvalho Chehab             ___sys_sendmsg+0x269/0x270
1583ea272257SMauro Carvalho Chehab    } hitcount:         77
1584ea272257SMauro Carvalho Chehab    { stacktrace:
1585ea272257SMauro Carvalho Chehab             netif_rx_internal+0xb2/0xd0
1586ea272257SMauro Carvalho Chehab             netif_rx+0x1c/0x60
1587ea272257SMauro Carvalho Chehab             loopback_xmit+0x6c/0xb0
1588ea272257SMauro Carvalho Chehab             dev_hard_start_xmit+0x219/0x3a0
1589ea272257SMauro Carvalho Chehab             __dev_queue_xmit+0x415/0x4f0
1590ea272257SMauro Carvalho Chehab             dev_queue_xmit_sk+0x13/0x20
1591ea272257SMauro Carvalho Chehab             ip_finish_output2+0x237/0x340
1592ea272257SMauro Carvalho Chehab             ip_finish_output+0x113/0x1d0
1593ea272257SMauro Carvalho Chehab             ip_output+0x66/0xc0
1594ea272257SMauro Carvalho Chehab             ip_local_out_sk+0x31/0x40
1595ea272257SMauro Carvalho Chehab             ip_send_skb+0x1a/0x50
1596ea272257SMauro Carvalho Chehab             udp_send_skb+0x16d/0x270
1597ea272257SMauro Carvalho Chehab             udp_sendmsg+0x2bf/0x980
1598ea272257SMauro Carvalho Chehab             inet_sendmsg+0x67/0xa0
1599ea272257SMauro Carvalho Chehab             sock_sendmsg+0x38/0x50
1600ea272257SMauro Carvalho Chehab             SYSC_sendto+0xef/0x170
1601ea272257SMauro Carvalho Chehab    } hitcount:         88
1602ea272257SMauro Carvalho Chehab    { stacktrace:
1603ea272257SMauro Carvalho Chehab             _do_fork+0x18e/0x330
1604ea272257SMauro Carvalho Chehab             SyS_clone+0x19/0x20
1605ea272257SMauro Carvalho Chehab             entry_SYSCALL_64_fastpath+0x12/0x6a
1606ea272257SMauro Carvalho Chehab    } hitcount:        244
1607ea272257SMauro Carvalho Chehab
1608ea272257SMauro Carvalho Chehab    Totals:
1609ea272257SMauro Carvalho Chehab        Hits: 489
1610ea272257SMauro Carvalho Chehab        Entries: 7
1611ea272257SMauro Carvalho Chehab        Dropped: 0
1612ea272257SMauro Carvalho Chehab
1613ea272257SMauro Carvalho Chehab2.2 Inter-event hist triggers
1614ea272257SMauro Carvalho Chehab-----------------------------
1615ea272257SMauro Carvalho Chehab
1616ea272257SMauro Carvalho ChehabInter-event hist triggers are hist triggers that combine values from
1617ea272257SMauro Carvalho Chehabone or more other events and create a histogram using that data.  Data
1618ea272257SMauro Carvalho Chehabfrom an inter-event histogram can in turn become the source for
1619ea272257SMauro Carvalho Chehabfurther combined histograms, thus providing a chain of related
1620ea272257SMauro Carvalho Chehabhistograms, which is important for some applications.
1621ea272257SMauro Carvalho Chehab
1622ea272257SMauro Carvalho ChehabThe most important example of an inter-event quantity that can be used
1623ea272257SMauro Carvalho Chehabin this manner is latency, which is simply a difference in timestamps
1624ea272257SMauro Carvalho Chehabbetween two events.  Although latency is the most important
1625ea272257SMauro Carvalho Chehabinter-event quantity, note that because the support is completely
1626ea272257SMauro Carvalho Chehabgeneral across the trace event subsystem, any event field can be used
1627ea272257SMauro Carvalho Chehabin an inter-event quantity.
1628ea272257SMauro Carvalho Chehab
1629ea272257SMauro Carvalho ChehabAn example of a histogram that combines data from other histograms
1630ea272257SMauro Carvalho Chehabinto a useful chain would be a 'wakeupswitch latency' histogram that
1631ea272257SMauro Carvalho Chehabcombines a 'wakeup latency' histogram and a 'switch latency'
1632ea272257SMauro Carvalho Chehabhistogram.
1633ea272257SMauro Carvalho Chehab
1634ea272257SMauro Carvalho ChehabNormally, a hist trigger specification consists of a (possibly
1635ea272257SMauro Carvalho Chehabcompound) key along with one or more numeric values, which are
1636ea272257SMauro Carvalho Chehabcontinually updated sums associated with that key.  A histogram
1637ea272257SMauro Carvalho Chehabspecification in this case consists of individual key and value
1638ea272257SMauro Carvalho Chehabspecifications that refer to trace event fields associated with a
1639ea272257SMauro Carvalho Chehabsingle event type.
1640ea272257SMauro Carvalho Chehab
1641ea272257SMauro Carvalho ChehabThe inter-event hist trigger extension allows fields from multiple
1642ea272257SMauro Carvalho Chehabevents to be referenced and combined into a multi-event histogram
1643ea272257SMauro Carvalho Chehabspecification.  In support of this overall goal, a few enabling
1644ea272257SMauro Carvalho Chehabfeatures have been added to the hist trigger support:
1645ea272257SMauro Carvalho Chehab
1646ea272257SMauro Carvalho Chehab  - In order to compute an inter-event quantity, a value from one
1647ea272257SMauro Carvalho Chehab    event needs to saved and then referenced from another event.  This
1648ea272257SMauro Carvalho Chehab    requires the introduction of support for histogram 'variables'.
1649ea272257SMauro Carvalho Chehab
1650ea272257SMauro Carvalho Chehab  - The computation of inter-event quantities and their combination
1651ea272257SMauro Carvalho Chehab    require some minimal amount of support for applying simple
1652ea272257SMauro Carvalho Chehab    expressions to variables (+ and -).
1653ea272257SMauro Carvalho Chehab
1654ea272257SMauro Carvalho Chehab  - A histogram consisting of inter-event quantities isn't logically a
1655ea272257SMauro Carvalho Chehab    histogram on either event (so having the 'hist' file for either
1656ea272257SMauro Carvalho Chehab    event host the histogram output doesn't really make sense).  To
1657ea272257SMauro Carvalho Chehab    address the idea that the histogram is associated with a
1658ea272257SMauro Carvalho Chehab    combination of events, support is added allowing the creation of
1659ea272257SMauro Carvalho Chehab    'synthetic' events that are events derived from other events.
1660ea272257SMauro Carvalho Chehab    These synthetic events are full-fledged events just like any other
1661ea272257SMauro Carvalho Chehab    and can be used as such, as for instance to create the
1662ea272257SMauro Carvalho Chehab    'combination' histograms mentioned previously.
1663ea272257SMauro Carvalho Chehab
1664ea272257SMauro Carvalho Chehab  - A set of 'actions' can be associated with histogram entries -
1665ea272257SMauro Carvalho Chehab    these can be used to generate the previously mentioned synthetic
1666ea272257SMauro Carvalho Chehab    events, but can also be used for other purposes, such as for
1667ea272257SMauro Carvalho Chehab    example saving context when a 'max' latency has been hit.
1668ea272257SMauro Carvalho Chehab
1669ea272257SMauro Carvalho Chehab  - Trace events don't have a 'timestamp' associated with them, but
1670ea272257SMauro Carvalho Chehab    there is an implicit timestamp saved along with an event in the
1671ea272257SMauro Carvalho Chehab    underlying ftrace ring buffer.  This timestamp is now exposed as a
1672ea272257SMauro Carvalho Chehab    a synthetic field named 'common_timestamp' which can be used in
1673ea272257SMauro Carvalho Chehab    histograms as if it were any other event field; it isn't an actual
1674ea272257SMauro Carvalho Chehab    field in the trace format but rather is a synthesized value that
1675ea272257SMauro Carvalho Chehab    nonetheless can be used as if it were an actual field.  By default
1676ea272257SMauro Carvalho Chehab    it is in units of nanoseconds; appending '.usecs' to a
1677ea272257SMauro Carvalho Chehab    common_timestamp field changes the units to microseconds.
1678ea272257SMauro Carvalho Chehab
1679ea272257SMauro Carvalho ChehabA note on inter-event timestamps: If common_timestamp is used in a
1680ea272257SMauro Carvalho Chehabhistogram, the trace buffer is automatically switched over to using
1681ea272257SMauro Carvalho Chehababsolute timestamps and the "global" trace clock, in order to avoid
1682ea272257SMauro Carvalho Chehabbogus timestamp differences with other clocks that aren't coherent
1683ea272257SMauro Carvalho Chehabacross CPUs.  This can be overridden by specifying one of the other
1684ea272257SMauro Carvalho Chehabtrace clocks instead, using the "clock=XXX" hist trigger attribute,
1685ea272257SMauro Carvalho Chehabwhere XXX is any of the clocks listed in the tracing/trace_clock
1686ea272257SMauro Carvalho Chehabpseudo-file.
1687ea272257SMauro Carvalho Chehab
1688ea272257SMauro Carvalho ChehabThese features are described in more detail in the following sections.
1689ea272257SMauro Carvalho Chehab
1690ea272257SMauro Carvalho Chehab2.2.1 Histogram Variables
1691ea272257SMauro Carvalho Chehab-------------------------
1692ea272257SMauro Carvalho Chehab
1693ea272257SMauro Carvalho ChehabVariables are simply named locations used for saving and retrieving
1694ea272257SMauro Carvalho Chehabvalues between matching events.  A 'matching' event is defined as an
1695ea272257SMauro Carvalho Chehabevent that has a matching key - if a variable is saved for a histogram
1696ea272257SMauro Carvalho Chehabentry corresponding to that key, any subsequent event with a matching
1697ea272257SMauro Carvalho Chehabkey can access that variable.
1698ea272257SMauro Carvalho Chehab
1699ea272257SMauro Carvalho ChehabA variable's value is normally available to any subsequent event until
1700ea272257SMauro Carvalho Chehabit is set to something else by a subsequent event.  The one exception
1701ea272257SMauro Carvalho Chehabto that rule is that any variable used in an expression is essentially
1702ea272257SMauro Carvalho Chehab'read-once' - once it's used by an expression in a subsequent event,
1703ea272257SMauro Carvalho Chehabit's reset to its 'unset' state, which means it can't be used again
1704ea272257SMauro Carvalho Chehabunless it's set again.  This ensures not only that an event doesn't
1705ea272257SMauro Carvalho Chehabuse an uninitialized variable in a calculation, but that that variable
1706ea272257SMauro Carvalho Chehabis used only once and not for any unrelated subsequent match.
1707ea272257SMauro Carvalho Chehab
1708ea272257SMauro Carvalho ChehabThe basic syntax for saving a variable is to simply prefix a unique
1709ea272257SMauro Carvalho Chehabvariable name not corresponding to any keyword along with an '=' sign
1710ea272257SMauro Carvalho Chehabto any event field.
1711ea272257SMauro Carvalho Chehab
1712ea272257SMauro Carvalho ChehabEither keys or values can be saved and retrieved in this way.  This
1713ea272257SMauro Carvalho Chehabcreates a variable named 'ts0' for a histogram entry with the key
1714ea272257SMauro Carvalho Chehab'next_pid'::
1715ea272257SMauro Carvalho Chehab
1716ea272257SMauro Carvalho Chehab  # echo 'hist:keys=next_pid:vals=$ts0:ts0=common_timestamp ... >> \
1717ea272257SMauro Carvalho Chehab	event/trigger
1718ea272257SMauro Carvalho Chehab
1719ea272257SMauro Carvalho ChehabThe ts0 variable can be accessed by any subsequent event having the
1720ea272257SMauro Carvalho Chehabsame pid as 'next_pid'.
1721ea272257SMauro Carvalho Chehab
1722ea272257SMauro Carvalho ChehabVariable references are formed by prepending the variable name with
1723ea272257SMauro Carvalho Chehabthe '$' sign.  Thus for example, the ts0 variable above would be
1724ea272257SMauro Carvalho Chehabreferenced as '$ts0' in expressions.
1725ea272257SMauro Carvalho Chehab
1726ea272257SMauro Carvalho ChehabBecause 'vals=' is used, the common_timestamp variable value above
1727ea272257SMauro Carvalho Chehabwill also be summed as a normal histogram value would (though for a
1728ea272257SMauro Carvalho Chehabtimestamp it makes little sense).
1729ea272257SMauro Carvalho Chehab
1730ea272257SMauro Carvalho ChehabThe below shows that a key value can also be saved in the same way::
1731ea272257SMauro Carvalho Chehab
1732ea272257SMauro Carvalho Chehab  # echo 'hist:timer_pid=common_pid:key=timer_pid ...' >> event/trigger
1733ea272257SMauro Carvalho Chehab
1734ea272257SMauro Carvalho ChehabIf a variable isn't a key variable or prefixed with 'vals=', the
1735ea272257SMauro Carvalho Chehabassociated event field will be saved in a variable but won't be summed
1736ea272257SMauro Carvalho Chehabas a value::
1737ea272257SMauro Carvalho Chehab
1738ea272257SMauro Carvalho Chehab  # echo 'hist:keys=next_pid:ts1=common_timestamp ...' >> event/trigger
1739ea272257SMauro Carvalho Chehab
1740ea272257SMauro Carvalho ChehabMultiple variables can be assigned at the same time.  The below would
1741ea272257SMauro Carvalho Chehabresult in both ts0 and b being created as variables, with both
1742ea272257SMauro Carvalho Chehabcommon_timestamp and field1 additionally being summed as values::
1743ea272257SMauro Carvalho Chehab
1744ea272257SMauro Carvalho Chehab  # echo 'hist:keys=pid:vals=$ts0,$b:ts0=common_timestamp,b=field1 ...' >> \
1745ea272257SMauro Carvalho Chehab	event/trigger
1746ea272257SMauro Carvalho Chehab
1747ea272257SMauro Carvalho ChehabNote that variable assignments can appear either preceding or
1748ea272257SMauro Carvalho Chehabfollowing their use.  The command below behaves identically to the
1749ea272257SMauro Carvalho Chehabcommand above::
1750ea272257SMauro Carvalho Chehab
1751ea272257SMauro Carvalho Chehab  # echo 'hist:keys=pid:ts0=common_timestamp,b=field1:vals=$ts0,$b ...' >> \
1752ea272257SMauro Carvalho Chehab	event/trigger
1753ea272257SMauro Carvalho Chehab
1754ea272257SMauro Carvalho ChehabAny number of variables not bound to a 'vals=' prefix can also be
1755ea272257SMauro Carvalho Chehabassigned by simply separating them with colons.  Below is the same
1756ea272257SMauro Carvalho Chehabthing but without the values being summed in the histogram::
1757ea272257SMauro Carvalho Chehab
1758ea272257SMauro Carvalho Chehab  # echo 'hist:keys=pid:ts0=common_timestamp:b=field1 ...' >> event/trigger
1759ea272257SMauro Carvalho Chehab
1760ea272257SMauro Carvalho ChehabVariables set as above can be referenced and used in expressions on
1761ea272257SMauro Carvalho Chehabanother event.
1762ea272257SMauro Carvalho Chehab
1763ea272257SMauro Carvalho ChehabFor example, here's how a latency can be calculated::
1764ea272257SMauro Carvalho Chehab
1765ea272257SMauro Carvalho Chehab  # echo 'hist:keys=pid,prio:ts0=common_timestamp ...' >> event1/trigger
1766ea272257SMauro Carvalho Chehab  # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp-$ts0 ...' >> event2/trigger
1767ea272257SMauro Carvalho Chehab
1768aea74de4SMasanari IidaIn the first line above, the event's timestamp is saved into the
1769ea272257SMauro Carvalho Chehabvariable ts0.  In the next line, ts0 is subtracted from the second
1770ea272257SMauro Carvalho Chehabevent's timestamp to produce the latency, which is then assigned into
1771ea272257SMauro Carvalho Chehabyet another variable, 'wakeup_lat'.  The hist trigger below in turn
1772ea272257SMauro Carvalho Chehabmakes use of the wakeup_lat variable to compute a combined latency
1773ea272257SMauro Carvalho Chehabusing the same key and variable from yet another event::
1774ea272257SMauro Carvalho Chehab
1775ea272257SMauro Carvalho Chehab  # echo 'hist:key=pid:wakeupswitch_lat=$wakeup_lat+$switchtime_lat ...' >> event3/trigger
1776ea272257SMauro Carvalho Chehab
1777ea272257SMauro Carvalho Chehab2.2.2 Synthetic Events
1778ea272257SMauro Carvalho Chehab----------------------
1779ea272257SMauro Carvalho Chehab
1780ea272257SMauro Carvalho ChehabSynthetic events are user-defined events generated from hist trigger
1781ea272257SMauro Carvalho Chehabvariables or fields associated with one or more other events.  Their
1782ea272257SMauro Carvalho Chehabpurpose is to provide a mechanism for displaying data spanning
1783ea272257SMauro Carvalho Chehabmultiple events consistent with the existing and already familiar
1784ea272257SMauro Carvalho Chehabusage for normal events.
1785ea272257SMauro Carvalho Chehab
1786ea272257SMauro Carvalho ChehabTo define a synthetic event, the user writes a simple specification
1787ea272257SMauro Carvalho Chehabconsisting of the name of the new event along with one or more
1788ea272257SMauro Carvalho Chehabvariables and their types, which can be any valid field type,
1789ea272257SMauro Carvalho Chehabseparated by semicolons, to the tracing/synthetic_events file.
1790ea272257SMauro Carvalho Chehab
1791ea272257SMauro Carvalho ChehabFor instance, the following creates a new event named 'wakeup_latency'
1792ea272257SMauro Carvalho Chehabwith 3 fields: lat, pid, and prio.  Each of those fields is simply a
1793ea272257SMauro Carvalho Chehabvariable reference to a variable on another event::
1794ea272257SMauro Carvalho Chehab
1795ea272257SMauro Carvalho Chehab  # echo 'wakeup_latency \
1796ea272257SMauro Carvalho Chehab          u64 lat; \
1797ea272257SMauro Carvalho Chehab          pid_t pid; \
1798ea272257SMauro Carvalho Chehab	  int prio' >> \
1799ea272257SMauro Carvalho Chehab	  /sys/kernel/debug/tracing/synthetic_events
1800ea272257SMauro Carvalho Chehab
1801ea272257SMauro Carvalho ChehabReading the tracing/synthetic_events file lists all the currently
1802ea272257SMauro Carvalho Chehabdefined synthetic events, in this case the event defined above::
1803ea272257SMauro Carvalho Chehab
1804ea272257SMauro Carvalho Chehab  # cat /sys/kernel/debug/tracing/synthetic_events
1805ea272257SMauro Carvalho Chehab    wakeup_latency u64 lat; pid_t pid; int prio
1806ea272257SMauro Carvalho Chehab
1807ea272257SMauro Carvalho ChehabAn existing synthetic event definition can be removed by prepending
1808ea272257SMauro Carvalho Chehabthe command that defined it with a '!'::
1809ea272257SMauro Carvalho Chehab
1810ea272257SMauro Carvalho Chehab  # echo '!wakeup_latency u64 lat pid_t pid int prio' >> \
1811ea272257SMauro Carvalho Chehab    /sys/kernel/debug/tracing/synthetic_events
1812ea272257SMauro Carvalho Chehab
1813ea272257SMauro Carvalho ChehabAt this point, there isn't yet an actual 'wakeup_latency' event
1814aea74de4SMasanari Iidainstantiated in the event subsystem - for this to happen, a 'hist
1815ea272257SMauro Carvalho Chehabtrigger action' needs to be instantiated and bound to actual fields
1816ea272257SMauro Carvalho Chehaband variables defined on other events (see Section 2.2.3 below on
1817ea272257SMauro Carvalho Chehabhow that is done using hist trigger 'onmatch' action). Once that is
1818ea272257SMauro Carvalho Chehabdone, the 'wakeup_latency' synthetic event instance is created.
1819ea272257SMauro Carvalho Chehab
1820ea272257SMauro Carvalho ChehabA histogram can now be defined for the new synthetic event::
1821ea272257SMauro Carvalho Chehab
1822ea272257SMauro Carvalho Chehab  # echo 'hist:keys=pid,prio,lat.log2:sort=pid,lat' >> \
1823ea272257SMauro Carvalho Chehab        /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/trigger
1824ea272257SMauro Carvalho Chehab
1825ea272257SMauro Carvalho ChehabThe new event is created under the tracing/events/synthetic/ directory
1826ea272257SMauro Carvalho Chehaband looks and behaves just like any other event::
1827ea272257SMauro Carvalho Chehab
1828ea272257SMauro Carvalho Chehab  # ls /sys/kernel/debug/tracing/events/synthetic/wakeup_latency
1829ea272257SMauro Carvalho Chehab        enable  filter  format  hist  id  trigger
1830ea272257SMauro Carvalho Chehab
1831ea272257SMauro Carvalho ChehabLike any other event, once a histogram is enabled for the event, the
1832ea272257SMauro Carvalho Chehaboutput can be displayed by reading the event's 'hist' file.
1833ea272257SMauro Carvalho Chehab
18345032b381STom Zanussi2.2.3 Hist trigger 'handlers' and 'actions'
18355032b381STom Zanussi-------------------------------------------
1836ea272257SMauro Carvalho Chehab
18375032b381STom ZanussiA hist trigger 'action' is a function that's executed (in most cases
18385032b381STom Zanussiconditionally) whenever a histogram entry is added or updated.
1839ea272257SMauro Carvalho Chehab
18405032b381STom ZanussiWhen a histogram entry is added or updated, a hist trigger 'handler'
18415032b381STom Zanussiis what decides whether the corresponding action is actually invoked
18425032b381STom Zanussior not.
1843ea272257SMauro Carvalho Chehab
18445032b381STom ZanussiHist trigger handlers and actions are paired together in the general
18455032b381STom Zanussiform:
18465032b381STom Zanussi
18475032b381STom Zanussi  <handler>.<action>
18485032b381STom Zanussi
18495032b381STom ZanussiTo specify a handler.action pair for a given event, simply specify
18505032b381STom Zanussithat handler.action pair between colons in the hist trigger
18515032b381STom Zanussispecification.
18525032b381STom Zanussi
18535032b381STom ZanussiIn theory, any handler can be combined with any action, but in
18545032b381STom Zanussipractice, not every handler.action combination is currently supported;
18555032b381STom Zanussiif a given handler.action combination isn't supported, the hist
18565032b381STom Zanussitrigger will fail with -EINVAL;
18575032b381STom Zanussi
18585032b381STom ZanussiThe default 'handler.action' if none is explicity specified is as it
18595032b381STom Zanussialways has been, to simply update the set of values associated with an
18605032b381STom Zanussientry.  Some applications, however, may want to perform additional
18615032b381STom Zanussiactions at that point, such as generate another event, or compare and
18625032b381STom Zanussisave a maximum.
18635032b381STom Zanussi
18645032b381STom ZanussiThe supported handlers and actions are listed below, and each is
18655032b381STom Zanussidescribed in more detail in the following paragraphs, in the context
18665032b381STom Zanussiof descriptions of some common and useful handler.action combinations.
18675032b381STom Zanussi
18685032b381STom ZanussiThe available handlers are:
18695032b381STom Zanussi
18705032b381STom Zanussi  - onmatch(matching.event)    - invoke action on any addition or update
18715032b381STom Zanussi  - onmax(var)                 - invoke action if var exceeds current max
1872ff0d35e2STom Zanussi  - onchange(var)              - invoke action if var changes
18735032b381STom Zanussi
18745032b381STom ZanussiThe available actions are:
18755032b381STom Zanussi
18765032b381STom Zanussi  - <synthetic_event_name>(param list)         - generate synthetic event
18775032b381STom Zanussi  - save(field,...)                            - save current event fields
1878fd451a3dSTom Zanussi  - snapshot()                                 - snapshot the trace buffer
18795032b381STom Zanussi
18805032b381STom ZanussiThe following commonly-used handler.action pairs are available:
1881ea272257SMauro Carvalho Chehab
1882ea272257SMauro Carvalho Chehab  - onmatch(matching.event).<synthetic_event_name>(param list)
1883ea272257SMauro Carvalho Chehab
1884ea272257SMauro Carvalho Chehab    The 'onmatch(matching.event).<synthetic_event_name>(params)' hist
1885ea272257SMauro Carvalho Chehab    trigger action is invoked whenever an event matches and the
1886ea272257SMauro Carvalho Chehab    histogram entry would be added or updated.  It causes the named
1887ea272257SMauro Carvalho Chehab    synthetic event to be generated with the values given in the
1888ea272257SMauro Carvalho Chehab    'param list'.  The result is the generation of a synthetic event
1889ea272257SMauro Carvalho Chehab    that consists of the values contained in those variables at the
1890ea272257SMauro Carvalho Chehab    time the invoking event was hit.
1891ea272257SMauro Carvalho Chehab
1892ea272257SMauro Carvalho Chehab    The 'param list' consists of one or more parameters which may be
1893ea272257SMauro Carvalho Chehab    either variables or fields defined on either the 'matching.event'
1894ea272257SMauro Carvalho Chehab    or the target event.  The variables or fields specified in the
1895ea272257SMauro Carvalho Chehab    param list may be either fully-qualified or unqualified.  If a
1896ea272257SMauro Carvalho Chehab    variable is specified as unqualified, it must be unique between
1897ea272257SMauro Carvalho Chehab    the two events.  A field name used as a param can be unqualified
1898ea272257SMauro Carvalho Chehab    if it refers to the target event, but must be fully qualified if
1899ea272257SMauro Carvalho Chehab    it refers to the matching event.  A fully-qualified name is of the
1900ea272257SMauro Carvalho Chehab    form 'system.event_name.$var_name' or 'system.event_name.field'.
1901ea272257SMauro Carvalho Chehab
1902ea272257SMauro Carvalho Chehab    The 'matching.event' specification is simply the fully qualified
1903ea272257SMauro Carvalho Chehab    event name of the event that matches the target event for the
1904ea272257SMauro Carvalho Chehab    onmatch() functionality, in the form 'system.event_name'.
1905ea272257SMauro Carvalho Chehab
1906ea272257SMauro Carvalho Chehab    Finally, the number and type of variables/fields in the 'param
1907ea272257SMauro Carvalho Chehab    list' must match the number and types of the fields in the
1908ea272257SMauro Carvalho Chehab    synthetic event being generated.
1909ea272257SMauro Carvalho Chehab
1910ea272257SMauro Carvalho Chehab    As an example the below defines a simple synthetic event and uses
1911ea272257SMauro Carvalho Chehab    a variable defined on the sched_wakeup_new event as a parameter
1912ea272257SMauro Carvalho Chehab    when invoking the synthetic event.  Here we define the synthetic
1913ea272257SMauro Carvalho Chehab    event::
1914ea272257SMauro Carvalho Chehab
1915ea272257SMauro Carvalho Chehab      # echo 'wakeup_new_test pid_t pid' >> \
1916ea272257SMauro Carvalho Chehab             /sys/kernel/debug/tracing/synthetic_events
1917ea272257SMauro Carvalho Chehab
1918ea272257SMauro Carvalho Chehab      # cat /sys/kernel/debug/tracing/synthetic_events
1919ea272257SMauro Carvalho Chehab            wakeup_new_test pid_t pid
1920ea272257SMauro Carvalho Chehab
1921ea272257SMauro Carvalho Chehab    The following hist trigger both defines the missing testpid
1922ea272257SMauro Carvalho Chehab    variable and specifies an onmatch() action that generates a
1923ea272257SMauro Carvalho Chehab    wakeup_new_test synthetic event whenever a sched_wakeup_new event
1924ea272257SMauro Carvalho Chehab    occurs, which because of the 'if comm == "cyclictest"' filter only
1925ea272257SMauro Carvalho Chehab    happens when the executable is cyclictest::
1926ea272257SMauro Carvalho Chehab
1927ea272257SMauro Carvalho Chehab      # echo 'hist:keys=$testpid:testpid=pid:onmatch(sched.sched_wakeup_new).\
1928ea272257SMauro Carvalho Chehab              wakeup_new_test($testpid) if comm=="cyclictest"' >> \
1929ea272257SMauro Carvalho Chehab              /sys/kernel/debug/tracing/events/sched/sched_wakeup_new/trigger
1930ea272257SMauro Carvalho Chehab
1931ea272257SMauro Carvalho Chehab    Creating and displaying a histogram based on those events is now
1932ea272257SMauro Carvalho Chehab    just a matter of using the fields and new synthetic event in the
1933ea272257SMauro Carvalho Chehab    tracing/events/synthetic directory, as usual::
1934ea272257SMauro Carvalho Chehab
1935ea272257SMauro Carvalho Chehab      # echo 'hist:keys=pid:sort=pid' >> \
1936ea272257SMauro Carvalho Chehab             /sys/kernel/debug/tracing/events/synthetic/wakeup_new_test/trigger
1937ea272257SMauro Carvalho Chehab
1938ea272257SMauro Carvalho Chehab    Running 'cyclictest' should cause wakeup_new events to generate
1939ea272257SMauro Carvalho Chehab    wakeup_new_test synthetic events which should result in histogram
1940ea272257SMauro Carvalho Chehab    output in the wakeup_new_test event's hist file::
1941ea272257SMauro Carvalho Chehab
1942ea272257SMauro Carvalho Chehab      # cat /sys/kernel/debug/tracing/events/synthetic/wakeup_new_test/hist
1943ea272257SMauro Carvalho Chehab
1944ea272257SMauro Carvalho Chehab    A more typical usage would be to use two events to calculate a
1945ea272257SMauro Carvalho Chehab    latency.  The following example uses a set of hist triggers to
1946ea272257SMauro Carvalho Chehab    produce a 'wakeup_latency' histogram.
1947ea272257SMauro Carvalho Chehab
1948ea272257SMauro Carvalho Chehab    First, we define a 'wakeup_latency' synthetic event::
1949ea272257SMauro Carvalho Chehab
1950ea272257SMauro Carvalho Chehab      # echo 'wakeup_latency u64 lat; pid_t pid; int prio' >> \
1951ea272257SMauro Carvalho Chehab              /sys/kernel/debug/tracing/synthetic_events
1952ea272257SMauro Carvalho Chehab
1953ea272257SMauro Carvalho Chehab    Next, we specify that whenever we see a sched_waking event for a
1954ea272257SMauro Carvalho Chehab    cyclictest thread, save the timestamp in a 'ts0' variable::
1955ea272257SMauro Carvalho Chehab
1956ea272257SMauro Carvalho Chehab      # echo 'hist:keys=$saved_pid:saved_pid=pid:ts0=common_timestamp.usecs \
1957ea272257SMauro Carvalho Chehab              if comm=="cyclictest"' >> \
1958ea272257SMauro Carvalho Chehab	      /sys/kernel/debug/tracing/events/sched/sched_waking/trigger
1959ea272257SMauro Carvalho Chehab
1960ea272257SMauro Carvalho Chehab    Then, when the corresponding thread is actually scheduled onto the
1961ea272257SMauro Carvalho Chehab    CPU by a sched_switch event, calculate the latency and use that
1962ea272257SMauro Carvalho Chehab    along with another variable and an event field to generate a
1963ea272257SMauro Carvalho Chehab    wakeup_latency synthetic event::
1964ea272257SMauro Carvalho Chehab
1965ea272257SMauro Carvalho Chehab      # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:\
1966ea272257SMauro Carvalho Chehab              onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,\
1967ea272257SMauro Carvalho Chehab	              $saved_pid,next_prio) if next_comm=="cyclictest"' >> \
1968ea272257SMauro Carvalho Chehab	      /sys/kernel/debug/tracing/events/sched/sched_switch/trigger
1969ea272257SMauro Carvalho Chehab
1970ea272257SMauro Carvalho Chehab    We also need to create a histogram on the wakeup_latency synthetic
1971ea272257SMauro Carvalho Chehab    event in order to aggregate the generated synthetic event data::
1972ea272257SMauro Carvalho Chehab
1973ea272257SMauro Carvalho Chehab      # echo 'hist:keys=pid,prio,lat:sort=pid,lat' >> \
1974ea272257SMauro Carvalho Chehab              /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/trigger
1975ea272257SMauro Carvalho Chehab
1976ea272257SMauro Carvalho Chehab    Finally, once we've run cyclictest to actually generate some
1977ea272257SMauro Carvalho Chehab    events, we can see the output by looking at the wakeup_latency
1978ea272257SMauro Carvalho Chehab    synthetic event's hist file::
1979ea272257SMauro Carvalho Chehab
1980ea272257SMauro Carvalho Chehab      # cat /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/hist
1981ea272257SMauro Carvalho Chehab
1982ea272257SMauro Carvalho Chehab  - onmax(var).save(field,..	.)
1983ea272257SMauro Carvalho Chehab
1984ea272257SMauro Carvalho Chehab    The 'onmax(var).save(field,...)' hist trigger action is invoked
1985ea272257SMauro Carvalho Chehab    whenever the value of 'var' associated with a histogram entry
1986ea272257SMauro Carvalho Chehab    exceeds the current maximum contained in that variable.
1987ea272257SMauro Carvalho Chehab
1988ea272257SMauro Carvalho Chehab    The end result is that the trace event fields specified as the
1989ea272257SMauro Carvalho Chehab    onmax.save() params will be saved if 'var' exceeds the current
1990ea272257SMauro Carvalho Chehab    maximum for that hist trigger entry.  This allows context from the
1991ea272257SMauro Carvalho Chehab    event that exhibited the new maximum to be saved for later
1992ea272257SMauro Carvalho Chehab    reference.  When the histogram is displayed, additional fields
1993ea272257SMauro Carvalho Chehab    displaying the saved values will be printed.
1994ea272257SMauro Carvalho Chehab
1995ea272257SMauro Carvalho Chehab    As an example the below defines a couple of hist triggers, one for
1996ea272257SMauro Carvalho Chehab    sched_waking and another for sched_switch, keyed on pid.  Whenever
1997ea272257SMauro Carvalho Chehab    a sched_waking occurs, the timestamp is saved in the entry
1998ea272257SMauro Carvalho Chehab    corresponding to the current pid, and when the scheduler switches
1999ea272257SMauro Carvalho Chehab    back to that pid, the timestamp difference is calculated.  If the
2000ea272257SMauro Carvalho Chehab    resulting latency, stored in wakeup_lat, exceeds the current
2001ea272257SMauro Carvalho Chehab    maximum latency, the values specified in the save() fields are
2002ea272257SMauro Carvalho Chehab    recorded::
2003ea272257SMauro Carvalho Chehab
2004ea272257SMauro Carvalho Chehab      # echo 'hist:keys=pid:ts0=common_timestamp.usecs \
2005ea272257SMauro Carvalho Chehab              if comm=="cyclictest"' >> \
2006ea272257SMauro Carvalho Chehab              /sys/kernel/debug/tracing/events/sched/sched_waking/trigger
2007ea272257SMauro Carvalho Chehab
2008ea272257SMauro Carvalho Chehab      # echo 'hist:keys=next_pid:\
2009ea272257SMauro Carvalho Chehab              wakeup_lat=common_timestamp.usecs-$ts0:\
2010ea272257SMauro Carvalho Chehab              onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) \
2011ea272257SMauro Carvalho Chehab              if next_comm=="cyclictest"' >> \
2012ea272257SMauro Carvalho Chehab              /sys/kernel/debug/tracing/events/sched/sched_switch/trigger
2013ea272257SMauro Carvalho Chehab
2014ea272257SMauro Carvalho Chehab    When the histogram is displayed, the max value and the saved
2015ea272257SMauro Carvalho Chehab    values corresponding to the max are displayed following the rest
2016ea272257SMauro Carvalho Chehab    of the fields::
2017ea272257SMauro Carvalho Chehab
2018ea272257SMauro Carvalho Chehab      # cat /sys/kernel/debug/tracing/events/sched/sched_switch/hist
2019ea272257SMauro Carvalho Chehab        { next_pid:       2255 } hitcount:        239
2020ea272257SMauro Carvalho Chehab          common_timestamp-ts0:          0
2021ea272257SMauro Carvalho Chehab          max:         27
2022ea272257SMauro Carvalho Chehab	  next_comm: cyclictest
2023ea272257SMauro Carvalho Chehab          prev_pid:          0  prev_prio:        120  prev_comm: swapper/1
2024ea272257SMauro Carvalho Chehab
2025ea272257SMauro Carvalho Chehab        { next_pid:       2256 } hitcount:       2355
2026ea272257SMauro Carvalho Chehab          common_timestamp-ts0: 0
2027ea272257SMauro Carvalho Chehab          max:         49  next_comm: cyclictest
2028ea272257SMauro Carvalho Chehab          prev_pid:          0  prev_prio:        120  prev_comm: swapper/0
2029ea272257SMauro Carvalho Chehab
2030ea272257SMauro Carvalho Chehab        Totals:
2031ea272257SMauro Carvalho Chehab            Hits: 12970
2032ea272257SMauro Carvalho Chehab            Entries: 2
2033ea272257SMauro Carvalho Chehab            Dropped: 0
2034ea272257SMauro Carvalho Chehab
2035fd451a3dSTom Zanussi  - onmax(var).snapshot()
2036fd451a3dSTom Zanussi
2037fd451a3dSTom Zanussi    The 'onmax(var).snapshot()' hist trigger action is invoked
2038fd451a3dSTom Zanussi    whenever the value of 'var' associated with a histogram entry
2039fd451a3dSTom Zanussi    exceeds the current maximum contained in that variable.
2040fd451a3dSTom Zanussi
2041fd451a3dSTom Zanussi    The end result is that a global snapshot of the trace buffer will
2042fd451a3dSTom Zanussi    be saved in the tracing/snapshot file if 'var' exceeds the current
2043fd451a3dSTom Zanussi    maximum for any hist trigger entry.
2044fd451a3dSTom Zanussi
2045fd451a3dSTom Zanussi    Note that in this case the maximum is a global maximum for the
2046fd451a3dSTom Zanussi    current trace instance, which is the maximum across all buckets of
2047fd451a3dSTom Zanussi    the histogram.  The key of the specific trace event that caused
2048fd451a3dSTom Zanussi    the global maximum and the global maximum itself are displayed,
2049fd451a3dSTom Zanussi    along with a message stating that a snapshot has been taken and
2050fd451a3dSTom Zanussi    where to find it.  The user can use the key information displayed
2051fd451a3dSTom Zanussi    to locate the corresponding bucket in the histogram for even more
2052fd451a3dSTom Zanussi    detail.
2053fd451a3dSTom Zanussi
2054fd451a3dSTom Zanussi    As an example the below defines a couple of hist triggers, one for
2055fd451a3dSTom Zanussi    sched_waking and another for sched_switch, keyed on pid.  Whenever
2056fd451a3dSTom Zanussi    a sched_waking event occurs, the timestamp is saved in the entry
2057fd451a3dSTom Zanussi    corresponding to the current pid, and when the scheduler switches
2058fd451a3dSTom Zanussi    back to that pid, the timestamp difference is calculated.  If the
2059fd451a3dSTom Zanussi    resulting latency, stored in wakeup_lat, exceeds the current
2060fd451a3dSTom Zanussi    maximum latency, a snapshot is taken.  As part of the setup, all
2061fd451a3dSTom Zanussi    the scheduler events are also enabled, which are the events that
2062fd451a3dSTom Zanussi    will show up in the snapshot when it is taken at some point:
2063fd451a3dSTom Zanussi
2064fd451a3dSTom Zanussi    # echo 1 > /sys/kernel/debug/tracing/events/sched/enable
2065fd451a3dSTom Zanussi
2066fd451a3dSTom Zanussi    # echo 'hist:keys=pid:ts0=common_timestamp.usecs \
2067fd451a3dSTom Zanussi            if comm=="cyclictest"' >> \
2068fd451a3dSTom Zanussi            /sys/kernel/debug/tracing/events/sched/sched_waking/trigger
2069fd451a3dSTom Zanussi
2070fd451a3dSTom Zanussi    # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0: \
2071fd451a3dSTom Zanussi            onmax($wakeup_lat).save(next_prio,next_comm,prev_pid,prev_prio, \
2072fd451a3dSTom Zanussi	    prev_comm):onmax($wakeup_lat).snapshot() \
2073fd451a3dSTom Zanussi	    if next_comm=="cyclictest"' >> \
2074fd451a3dSTom Zanussi	    /sys/kernel/debug/tracing/events/sched/sched_switch/trigger
2075fd451a3dSTom Zanussi
2076fd451a3dSTom Zanussi    When the histogram is displayed, for each bucket the max value
2077fd451a3dSTom Zanussi    and the saved values corresponding to the max are displayed
2078fd451a3dSTom Zanussi    following the rest of the fields.
2079fd451a3dSTom Zanussi
2080fd451a3dSTom Zanussi    If a snaphot was taken, there is also a message indicating that,
2081fd451a3dSTom Zanussi    along with the value and event that triggered the global maximum:
2082fd451a3dSTom Zanussi
2083fd451a3dSTom Zanussi    # cat /sys/kernel/debug/tracing/events/sched/sched_switch/hist
2084fd451a3dSTom Zanussi      { next_pid:       2101 } hitcount:        200
2085fd451a3dSTom Zanussi	max:         52  next_prio:        120  next_comm: cyclictest \
2086fd451a3dSTom Zanussi        prev_pid:          0  prev_prio:        120  prev_comm: swapper/6
2087fd451a3dSTom Zanussi
2088fd451a3dSTom Zanussi      { next_pid:       2103 } hitcount:       1326
2089fd451a3dSTom Zanussi	max:        572  next_prio:         19  next_comm: cyclictest \
2090fd451a3dSTom Zanussi        prev_pid:          0  prev_prio:        120  prev_comm: swapper/1
2091fd451a3dSTom Zanussi
2092fd451a3dSTom Zanussi      { next_pid:       2102 } hitcount:       1982 \
2093fd451a3dSTom Zanussi	max:         74  next_prio:         19  next_comm: cyclictest \
2094fd451a3dSTom Zanussi        prev_pid:          0  prev_prio:        120  prev_comm: swapper/5
2095fd451a3dSTom Zanussi
2096fd451a3dSTom Zanussi    Snapshot taken (see tracing/snapshot).  Details:
2097fd451a3dSTom Zanussi	triggering value { onmax($wakeup_lat) }:        572	\
2098fd451a3dSTom Zanussi	triggered by event with key: { next_pid:       2103 }
2099fd451a3dSTom Zanussi
2100fd451a3dSTom Zanussi    Totals:
2101fd451a3dSTom Zanussi        Hits: 3508
2102fd451a3dSTom Zanussi        Entries: 3
2103fd451a3dSTom Zanussi        Dropped: 0
2104fd451a3dSTom Zanussi
2105fd451a3dSTom Zanussi    In the above case, the event that triggered the global maximum has
2106fd451a3dSTom Zanussi    the key with next_pid == 2103.  If you look at the bucket that has
2107fd451a3dSTom Zanussi    2103 as the key, you'll find the additional values save()'d along
2108fd451a3dSTom Zanussi    with the local maximum for that bucket, which should be the same
2109fd451a3dSTom Zanussi    as the global maximum (since that was the same value that
2110fd451a3dSTom Zanussi    triggered the global snapshot).
2111fd451a3dSTom Zanussi
2112fd451a3dSTom Zanussi    And finally, looking at the snapshot data should show at or near
2113fd451a3dSTom Zanussi    the end the event that triggered the snapshot (in this case you
2114fd451a3dSTom Zanussi    can verify the timestamps between the sched_waking and
2115fd451a3dSTom Zanussi    sched_switch events, which should match the time displayed in the
2116fd451a3dSTom Zanussi    global maximum):
2117fd451a3dSTom Zanussi
2118fd451a3dSTom Zanussi    # cat /sys/kernel/debug/tracing/snapshot
2119fd451a3dSTom Zanussi
2120fd451a3dSTom Zanussi     <...>-2103  [005] d..3   309.873125: sched_switch: prev_comm=cyclictest prev_pid=2103 prev_prio=19 prev_state=D ==> next_comm=swapper/5 next_pid=0 next_prio=120
2121fd451a3dSTom Zanussi     <idle>-0     [005] d.h3   309.873611: sched_waking: comm=cyclictest pid=2102 prio=19 target_cpu=005
2122fd451a3dSTom Zanussi     <idle>-0     [005] dNh4   309.873613: sched_wakeup: comm=cyclictest pid=2102 prio=19 target_cpu=005
2123fd451a3dSTom Zanussi     <idle>-0     [005] d..3   309.873616: sched_switch: prev_comm=swapper/5 prev_pid=0 prev_prio=120 prev_state=S ==> next_comm=cyclictest next_pid=2102 next_prio=19
2124fd451a3dSTom Zanussi     <...>-2102  [005] d..3   309.873625: sched_switch: prev_comm=cyclictest prev_pid=2102 prev_prio=19 prev_state=D ==> next_comm=swapper/5 next_pid=0 next_prio=120
2125fd451a3dSTom Zanussi     <idle>-0     [005] d.h3   309.874624: sched_waking: comm=cyclictest pid=2102 prio=19 target_cpu=005
2126fd451a3dSTom Zanussi     <idle>-0     [005] dNh4   309.874626: sched_wakeup: comm=cyclictest pid=2102 prio=19 target_cpu=005
2127fd451a3dSTom Zanussi     <idle>-0     [005] dNh3   309.874628: sched_waking: comm=cyclictest pid=2103 prio=19 target_cpu=005
2128fd451a3dSTom Zanussi     <idle>-0     [005] dNh4   309.874630: sched_wakeup: comm=cyclictest pid=2103 prio=19 target_cpu=005
2129fd451a3dSTom Zanussi     <idle>-0     [005] d..3   309.874633: sched_switch: prev_comm=swapper/5 prev_pid=0 prev_prio=120 prev_state=S ==> next_comm=cyclictest next_pid=2102 next_prio=19
2130fd451a3dSTom Zanussi     <idle>-0     [004] d.h3   309.874757: sched_waking: comm=gnome-terminal- pid=1699 prio=120 target_cpu=004
2131fd451a3dSTom Zanussi     <idle>-0     [004] dNh4   309.874762: sched_wakeup: comm=gnome-terminal- pid=1699 prio=120 target_cpu=004
2132fd451a3dSTom Zanussi     <idle>-0     [004] d..3   309.874766: sched_switch: prev_comm=swapper/4 prev_pid=0 prev_prio=120 prev_state=S ==> next_comm=gnome-terminal- next_pid=1699 next_prio=120
2133fd451a3dSTom Zanussi gnome-terminal--1699  [004] d.h2   309.874941: sched_stat_runtime: comm=gnome-terminal- pid=1699 runtime=180706 [ns] vruntime=1126870572 [ns]
2134fd451a3dSTom Zanussi     <idle>-0     [003] d.s4   309.874956: sched_waking: comm=rcu_sched pid=9 prio=120 target_cpu=007
2135fd451a3dSTom Zanussi     <idle>-0     [003] d.s5   309.874960: sched_wake_idle_without_ipi: cpu=7
2136fd451a3dSTom Zanussi     <idle>-0     [003] d.s5   309.874961: sched_wakeup: comm=rcu_sched pid=9 prio=120 target_cpu=007
2137fd451a3dSTom Zanussi     <idle>-0     [007] d..3   309.874963: sched_switch: prev_comm=swapper/7 prev_pid=0 prev_prio=120 prev_state=S ==> next_comm=rcu_sched next_pid=9 next_prio=120
2138fd451a3dSTom Zanussi  rcu_sched-9     [007] d..3   309.874973: sched_stat_runtime: comm=rcu_sched pid=9 runtime=13646 [ns] vruntime=22531430286 [ns]
2139fd451a3dSTom Zanussi  rcu_sched-9     [007] d..3   309.874978: sched_switch: prev_comm=rcu_sched prev_pid=9 prev_prio=120 prev_state=R+ ==> next_comm=swapper/7 next_pid=0 next_prio=120
2140fd451a3dSTom Zanussi      <...>-2102  [005] d..4   309.874994: sched_migrate_task: comm=cyclictest pid=2103 prio=19 orig_cpu=5 dest_cpu=1
2141fd451a3dSTom Zanussi      <...>-2102  [005] d..4   309.875185: sched_wake_idle_without_ipi: cpu=1
2142fd451a3dSTom Zanussi     <idle>-0     [001] d..3   309.875200: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=S ==> next_comm=cyclictest next_pid=2103 next_prio=19
2143fd451a3dSTom Zanussi
2144ff0d35e2STom Zanussi  - onchange(var).save(field,..	.)
2145ff0d35e2STom Zanussi
2146ff0d35e2STom Zanussi    The 'onchange(var).save(field,...)' hist trigger action is invoked
2147ff0d35e2STom Zanussi    whenever the value of 'var' associated with a histogram entry
2148ff0d35e2STom Zanussi    changes.
2149ff0d35e2STom Zanussi
2150ff0d35e2STom Zanussi    The end result is that the trace event fields specified as the
2151ff0d35e2STom Zanussi    onchange.save() params will be saved if 'var' changes for that
2152ff0d35e2STom Zanussi    hist trigger entry.  This allows context from the event that
2153ff0d35e2STom Zanussi    changed the value to be saved for later reference.  When the
2154ff0d35e2STom Zanussi    histogram is displayed, additional fields displaying the saved
2155ff0d35e2STom Zanussi    values will be printed.
2156ff0d35e2STom Zanussi
2157ff0d35e2STom Zanussi  - onchange(var).snapshot()
2158ff0d35e2STom Zanussi
2159ff0d35e2STom Zanussi    The 'onchange(var).snapshot()' hist trigger action is invoked
2160ff0d35e2STom Zanussi    whenever the value of 'var' associated with a histogram entry
2161ff0d35e2STom Zanussi    changes.
2162ff0d35e2STom Zanussi
2163ff0d35e2STom Zanussi    The end result is that a global snapshot of the trace buffer will
2164ff0d35e2STom Zanussi    be saved in the tracing/snapshot file if 'var' changes for any
2165ff0d35e2STom Zanussi    hist trigger entry.
2166ff0d35e2STom Zanussi
2167ff0d35e2STom Zanussi    Note that in this case the changed value is a global variable
2168ff0d35e2STom Zanussi    associated withe current trace instance.  The key of the specific
2169ff0d35e2STom Zanussi    trace event that caused the value to change and the global value
2170ff0d35e2STom Zanussi    itself are displayed, along with a message stating that a snapshot
2171ff0d35e2STom Zanussi    has been taken and where to find it.  The user can use the key
2172ff0d35e2STom Zanussi    information displayed to locate the corresponding bucket in the
2173ff0d35e2STom Zanussi    histogram for even more detail.
2174ff0d35e2STom Zanussi
2175ff0d35e2STom Zanussi    As an example the below defines a hist trigger on the tcp_probe
2176ff0d35e2STom Zanussi    event, keyed on dport.  Whenever a tcp_probe event occurs, the
2177ff0d35e2STom Zanussi    cwnd field is checked against the current value stored in the
2178ff0d35e2STom Zanussi    $cwnd variable.  If the value has changed, a snapshot is taken.
2179ff0d35e2STom Zanussi    As part of the setup, all the scheduler and tcp events are also
2180ff0d35e2STom Zanussi    enabled, which are the events that will show up in the snapshot
2181ff0d35e2STom Zanussi    when it is taken at some point:
2182ff0d35e2STom Zanussi
2183ff0d35e2STom Zanussi    # echo 1 > /sys/kernel/debug/tracing/events/sched/enable
2184ff0d35e2STom Zanussi    # echo 1 > /sys/kernel/debug/tracing/events/tcp/enable
2185ff0d35e2STom Zanussi
2186ff0d35e2STom Zanussi    # echo 'hist:keys=dport:cwnd=snd_cwnd: \
2187ff0d35e2STom Zanussi            onchange($cwnd).save(snd_wnd,srtt,rcv_wnd): \
2188ff0d35e2STom Zanussi	    onchange($cwnd).snapshot()' >> \
2189ff0d35e2STom Zanussi	    /sys/kernel/debug/tracing/events/tcp/tcp_probe/trigger
2190ff0d35e2STom Zanussi
2191ff0d35e2STom Zanussi    When the histogram is displayed, for each bucket the tracked value
2192ff0d35e2STom Zanussi    and the saved values corresponding to that value are displayed
2193ff0d35e2STom Zanussi    following the rest of the fields.
2194ff0d35e2STom Zanussi
2195ff0d35e2STom Zanussi    If a snaphot was taken, there is also a message indicating that,
2196ff0d35e2STom Zanussi    along with the value and event that triggered the snapshot:
2197ff0d35e2STom Zanussi
2198ff0d35e2STom Zanussi    # cat /sys/kernel/debug/tracing/events/tcp/tcp_probe/hist
2199ff0d35e2STom Zanussi      { dport:       1521 } hitcount:          8
2200ff0d35e2STom Zanussi	changed:         10  snd_wnd:      35456  srtt:     154262  rcv_wnd:      42112
2201ff0d35e2STom Zanussi
2202ff0d35e2STom Zanussi      { dport:         80 } hitcount:         23
2203ff0d35e2STom Zanussi	changed:         10  snd_wnd:      28960  srtt:      19604  rcv_wnd:      29312
2204ff0d35e2STom Zanussi
2205ff0d35e2STom Zanussi      { dport:       9001 } hitcount:        172
2206ff0d35e2STom Zanussi	changed:         10  snd_wnd:      48384  srtt:     260444  rcv_wnd:      55168
2207ff0d35e2STom Zanussi
2208ff0d35e2STom Zanussi      { dport:        443 } hitcount:        211
2209ff0d35e2STom Zanussi	changed:         10  snd_wnd:      26960  srtt:      17379  rcv_wnd:      28800
2210ff0d35e2STom Zanussi
2211ff0d35e2STom Zanussi    Snapshot taken (see tracing/snapshot).  Details:
2212ff0d35e2STom Zanussi        triggering value { onchange($cwnd) }:         10
2213ff0d35e2STom Zanussi        triggered by event with key: { dport:         80 }
2214ff0d35e2STom Zanussi
2215ff0d35e2STom Zanussi    Totals:
2216ff0d35e2STom Zanussi        Hits: 414
2217ff0d35e2STom Zanussi        Entries: 4
2218ff0d35e2STom Zanussi        Dropped: 0
2219ff0d35e2STom Zanussi
2220ff0d35e2STom Zanussi    In the above case, the event that triggered the snapshot has the
2221ff0d35e2STom Zanussi    key with dport == 80.  If you look at the bucket that has 80 as
2222ff0d35e2STom Zanussi    the key, you'll find the additional values save()'d along with the
2223ff0d35e2STom Zanussi    changed value for that bucket, which should be the same as the
2224ff0d35e2STom Zanussi    global changed value (since that was the same value that triggered
2225ff0d35e2STom Zanussi    the global snapshot).
2226ff0d35e2STom Zanussi
2227ff0d35e2STom Zanussi    And finally, looking at the snapshot data should show at or near
2228ff0d35e2STom Zanussi    the end the event that triggered the snapshot:
2229ff0d35e2STom Zanussi
2230ff0d35e2STom Zanussi    # cat /sys/kernel/debug/tracing/snapshot
2231ff0d35e2STom Zanussi
2232ff0d35e2STom Zanussi       gnome-shell-1261  [006] dN.3    49.823113: sched_stat_runtime: comm=gnome-shell pid=1261 runtime=49347 [ns] vruntime=1835730389 [ns]
2233ff0d35e2STom Zanussi     kworker/u16:4-773   [003] d..3    49.823114: sched_switch: prev_comm=kworker/u16:4 prev_pid=773 prev_prio=120 prev_state=R+ ==> next_comm=kworker/3:2 next_pid=135 next_prio=120
2234ff0d35e2STom Zanussi       gnome-shell-1261  [006] d..3    49.823114: sched_switch: prev_comm=gnome-shell prev_pid=1261 prev_prio=120 prev_state=R+ ==> next_comm=kworker/6:2 next_pid=387 next_prio=120
2235ff0d35e2STom Zanussi       kworker/3:2-135   [003] d..3    49.823118: sched_stat_runtime: comm=kworker/3:2 pid=135 runtime=5339 [ns] vruntime=17815800388 [ns]
2236ff0d35e2STom Zanussi       kworker/6:2-387   [006] d..3    49.823120: sched_stat_runtime: comm=kworker/6:2 pid=387 runtime=9594 [ns] vruntime=14589605367 [ns]
2237ff0d35e2STom Zanussi       kworker/6:2-387   [006] d..3    49.823122: sched_switch: prev_comm=kworker/6:2 prev_pid=387 prev_prio=120 prev_state=R+ ==> next_comm=gnome-shell next_pid=1261 next_prio=120
2238ff0d35e2STom Zanussi       kworker/3:2-135   [003] d..3    49.823123: sched_switch: prev_comm=kworker/3:2 prev_pid=135 prev_prio=120 prev_state=T ==> next_comm=swapper/3 next_pid=0 next_prio=120
2239ff0d35e2STom Zanussi            <idle>-0     [004] ..s7    49.823798: tcp_probe: src=10.0.0.10:54326 dest=23.215.104.193:80 mark=0x0 length=32 snd_nxt=0xe3ae2ff5 snd_una=0xe3ae2ecd snd_cwnd=10 ssthresh=2147483647 snd_wnd=28960 srtt=19604 rcv_wnd=29312
2240ff0d35e2STom Zanussi
2241ea272257SMauro Carvalho Chehab3. User space creating a trigger
2242ea272257SMauro Carvalho Chehab--------------------------------
2243ea272257SMauro Carvalho Chehab
2244ea272257SMauro Carvalho ChehabWriting into /sys/kernel/tracing/trace_marker writes into the ftrace
2245ea272257SMauro Carvalho Chehabring buffer. This can also act like an event, by writing into the trigger
2246ea272257SMauro Carvalho Chehabfile located in /sys/kernel/tracing/events/ftrace/print/
2247ea272257SMauro Carvalho Chehab
2248ea272257SMauro Carvalho ChehabModifying cyclictest to write into the trace_marker file before it sleeps
2249ea272257SMauro Carvalho Chehaband after it wakes up, something like this::
2250ea272257SMauro Carvalho Chehab
2251ea272257SMauro Carvalho Chehab  static void traceputs(char *str)
2252ea272257SMauro Carvalho Chehab  {
2253ea272257SMauro Carvalho Chehab	/* tracemark_fd is the trace_marker file descriptor */
2254ea272257SMauro Carvalho Chehab	if (tracemark_fd < 0)
2255ea272257SMauro Carvalho Chehab		return;
2256ea272257SMauro Carvalho Chehab	/* write the tracemark message */
2257ea272257SMauro Carvalho Chehab	write(tracemark_fd, str, strlen(str));
2258ea272257SMauro Carvalho Chehab  }
2259ea272257SMauro Carvalho Chehab
2260ea272257SMauro Carvalho ChehabAnd later add something like::
2261ea272257SMauro Carvalho Chehab
2262ea272257SMauro Carvalho Chehab	traceputs("start");
2263ea272257SMauro Carvalho Chehab	clock_nanosleep(...);
2264ea272257SMauro Carvalho Chehab	traceputs("end");
2265ea272257SMauro Carvalho Chehab
2266ea272257SMauro Carvalho ChehabWe can make a histogram from this::
2267ea272257SMauro Carvalho Chehab
2268ea272257SMauro Carvalho Chehab # cd /sys/kernel/tracing
2269ea272257SMauro Carvalho Chehab # echo 'latency u64 lat' > synthetic_events
2270ea272257SMauro Carvalho Chehab # echo 'hist:keys=common_pid:ts0=common_timestamp.usecs if buf == "start"' > events/ftrace/print/trigger
2271ea272257SMauro Carvalho Chehab # echo 'hist:keys=common_pid:lat=common_timestamp.usecs-$ts0:onmatch(ftrace.print).latency($lat) if buf == "end"' >> events/ftrace/print/trigger
2272ea272257SMauro Carvalho Chehab # echo 'hist:keys=lat,common_pid:sort=lat' > events/synthetic/latency/trigger
2273ea272257SMauro Carvalho Chehab
2274ea272257SMauro Carvalho ChehabThe above created a synthetic event called "latency" and two histograms
2275ea272257SMauro Carvalho Chehabagainst the trace_marker, one gets triggered when "start" is written into the
2276ea272257SMauro Carvalho Chehabtrace_marker file and the other when "end" is written. If the pids match, then
2277ea272257SMauro Carvalho Chehabit will call the "latency" synthetic event with the calculated latency as its
2278ea272257SMauro Carvalho Chehabparameter. Finally, a histogram is added to the latency synthetic event to
2279ea272257SMauro Carvalho Chehabrecord the calculated latency along with the pid.
2280ea272257SMauro Carvalho Chehab
2281ea272257SMauro Carvalho ChehabNow running cyclictest with::
2282ea272257SMauro Carvalho Chehab
2283ea272257SMauro Carvalho Chehab # ./cyclictest -p80 -d0 -i250 -n -a -t --tracemark -b 1000
2284ea272257SMauro Carvalho Chehab
2285ea272257SMauro Carvalho Chehab -p80  : run threads at priority 80
2286ea272257SMauro Carvalho Chehab -d0   : have all threads run at the same interval
2287ea272257SMauro Carvalho Chehab -i250 : start the interval at 250 microseconds (all threads will do this)
2288ea272257SMauro Carvalho Chehab -n    : sleep with nanosleep
2289ea272257SMauro Carvalho Chehab -a    : affine all threads to a separate CPU
2290ea272257SMauro Carvalho Chehab -t    : one thread per available CPU
2291ea272257SMauro Carvalho Chehab --tracemark : enable trace mark writing
2292ea272257SMauro Carvalho Chehab -b 1000 : stop if any latency is greater than 1000 microseconds
2293ea272257SMauro Carvalho Chehab
2294ea272257SMauro Carvalho ChehabNote, the -b 1000 is used just to make --tracemark available.
2295ea272257SMauro Carvalho Chehab
2296ea272257SMauro Carvalho ChehabThen we can see the histogram created by this with::
2297ea272257SMauro Carvalho Chehab
2298ea272257SMauro Carvalho Chehab # cat events/synthetic/latency/hist
2299ea272257SMauro Carvalho Chehab # event histogram
2300ea272257SMauro Carvalho Chehab #
2301ea272257SMauro Carvalho Chehab # trigger info: hist:keys=lat,common_pid:vals=hitcount:sort=lat:size=2048 [active]
2302ea272257SMauro Carvalho Chehab #
2303ea272257SMauro Carvalho Chehab
2304ea272257SMauro Carvalho Chehab { lat:        107, common_pid:       2039 } hitcount:          1
2305ea272257SMauro Carvalho Chehab { lat:        122, common_pid:       2041 } hitcount:          1
2306ea272257SMauro Carvalho Chehab { lat:        166, common_pid:       2039 } hitcount:          1
2307ea272257SMauro Carvalho Chehab { lat:        174, common_pid:       2039 } hitcount:          1
2308ea272257SMauro Carvalho Chehab { lat:        194, common_pid:       2041 } hitcount:          1
2309ea272257SMauro Carvalho Chehab { lat:        196, common_pid:       2036 } hitcount:          1
2310ea272257SMauro Carvalho Chehab { lat:        197, common_pid:       2038 } hitcount:          1
2311ea272257SMauro Carvalho Chehab { lat:        198, common_pid:       2039 } hitcount:          1
2312ea272257SMauro Carvalho Chehab { lat:        199, common_pid:       2039 } hitcount:          1
2313ea272257SMauro Carvalho Chehab { lat:        200, common_pid:       2041 } hitcount:          1
2314ea272257SMauro Carvalho Chehab { lat:        201, common_pid:       2039 } hitcount:          2
2315ea272257SMauro Carvalho Chehab { lat:        202, common_pid:       2038 } hitcount:          1
2316ea272257SMauro Carvalho Chehab { lat:        202, common_pid:       2043 } hitcount:          1
2317ea272257SMauro Carvalho Chehab { lat:        203, common_pid:       2039 } hitcount:          1
2318ea272257SMauro Carvalho Chehab { lat:        203, common_pid:       2036 } hitcount:          1
2319ea272257SMauro Carvalho Chehab { lat:        203, common_pid:       2041 } hitcount:          1
2320ea272257SMauro Carvalho Chehab { lat:        206, common_pid:       2038 } hitcount:          2
2321ea272257SMauro Carvalho Chehab { lat:        207, common_pid:       2039 } hitcount:          1
2322ea272257SMauro Carvalho Chehab { lat:        207, common_pid:       2036 } hitcount:          1
2323ea272257SMauro Carvalho Chehab { lat:        208, common_pid:       2040 } hitcount:          1
2324ea272257SMauro Carvalho Chehab { lat:        209, common_pid:       2043 } hitcount:          1
2325ea272257SMauro Carvalho Chehab { lat:        210, common_pid:       2039 } hitcount:          1
2326ea272257SMauro Carvalho Chehab { lat:        211, common_pid:       2039 } hitcount:          4
2327ea272257SMauro Carvalho Chehab { lat:        212, common_pid:       2043 } hitcount:          1
2328ea272257SMauro Carvalho Chehab { lat:        212, common_pid:       2039 } hitcount:          2
2329ea272257SMauro Carvalho Chehab { lat:        213, common_pid:       2039 } hitcount:          1
2330ea272257SMauro Carvalho Chehab { lat:        214, common_pid:       2038 } hitcount:          1
2331ea272257SMauro Carvalho Chehab { lat:        214, common_pid:       2039 } hitcount:          2
2332ea272257SMauro Carvalho Chehab { lat:        214, common_pid:       2042 } hitcount:          1
2333ea272257SMauro Carvalho Chehab { lat:        215, common_pid:       2039 } hitcount:          1
2334ea272257SMauro Carvalho Chehab { lat:        217, common_pid:       2036 } hitcount:          1
2335ea272257SMauro Carvalho Chehab { lat:        217, common_pid:       2040 } hitcount:          1
2336ea272257SMauro Carvalho Chehab { lat:        217, common_pid:       2039 } hitcount:          1
2337ea272257SMauro Carvalho Chehab { lat:        218, common_pid:       2039 } hitcount:          6
2338ea272257SMauro Carvalho Chehab { lat:        219, common_pid:       2039 } hitcount:          9
2339ea272257SMauro Carvalho Chehab { lat:        220, common_pid:       2039 } hitcount:         11
2340ea272257SMauro Carvalho Chehab { lat:        221, common_pid:       2039 } hitcount:          5
2341ea272257SMauro Carvalho Chehab { lat:        221, common_pid:       2042 } hitcount:          1
2342ea272257SMauro Carvalho Chehab { lat:        222, common_pid:       2039 } hitcount:          7
2343ea272257SMauro Carvalho Chehab { lat:        223, common_pid:       2036 } hitcount:          1
2344ea272257SMauro Carvalho Chehab { lat:        223, common_pid:       2039 } hitcount:          3
2345ea272257SMauro Carvalho Chehab { lat:        224, common_pid:       2039 } hitcount:          4
2346ea272257SMauro Carvalho Chehab { lat:        224, common_pid:       2037 } hitcount:          1
2347ea272257SMauro Carvalho Chehab { lat:        224, common_pid:       2036 } hitcount:          2
2348ea272257SMauro Carvalho Chehab { lat:        225, common_pid:       2039 } hitcount:          5
2349ea272257SMauro Carvalho Chehab { lat:        225, common_pid:       2042 } hitcount:          1
2350ea272257SMauro Carvalho Chehab { lat:        226, common_pid:       2039 } hitcount:          7
2351ea272257SMauro Carvalho Chehab { lat:        226, common_pid:       2036 } hitcount:          4
2352ea272257SMauro Carvalho Chehab { lat:        227, common_pid:       2039 } hitcount:          6
2353ea272257SMauro Carvalho Chehab { lat:        227, common_pid:       2036 } hitcount:         12
2354ea272257SMauro Carvalho Chehab { lat:        227, common_pid:       2043 } hitcount:          1
2355ea272257SMauro Carvalho Chehab { lat:        228, common_pid:       2039 } hitcount:          7
2356ea272257SMauro Carvalho Chehab { lat:        228, common_pid:       2036 } hitcount:         14
2357ea272257SMauro Carvalho Chehab { lat:        229, common_pid:       2039 } hitcount:          9
2358ea272257SMauro Carvalho Chehab { lat:        229, common_pid:       2036 } hitcount:          8
2359ea272257SMauro Carvalho Chehab { lat:        229, common_pid:       2038 } hitcount:          1
2360ea272257SMauro Carvalho Chehab { lat:        230, common_pid:       2039 } hitcount:         11
2361ea272257SMauro Carvalho Chehab { lat:        230, common_pid:       2036 } hitcount:          6
2362ea272257SMauro Carvalho Chehab { lat:        230, common_pid:       2043 } hitcount:          1
2363ea272257SMauro Carvalho Chehab { lat:        230, common_pid:       2042 } hitcount:          2
2364ea272257SMauro Carvalho Chehab { lat:        231, common_pid:       2041 } hitcount:          1
2365ea272257SMauro Carvalho Chehab { lat:        231, common_pid:       2036 } hitcount:          6
2366ea272257SMauro Carvalho Chehab { lat:        231, common_pid:       2043 } hitcount:          1
2367ea272257SMauro Carvalho Chehab { lat:        231, common_pid:       2039 } hitcount:          8
2368ea272257SMauro Carvalho Chehab { lat:        232, common_pid:       2037 } hitcount:          1
2369ea272257SMauro Carvalho Chehab { lat:        232, common_pid:       2039 } hitcount:          6
2370ea272257SMauro Carvalho Chehab { lat:        232, common_pid:       2040 } hitcount:          2
2371ea272257SMauro Carvalho Chehab { lat:        232, common_pid:       2036 } hitcount:          5
2372ea272257SMauro Carvalho Chehab { lat:        232, common_pid:       2043 } hitcount:          1
2373ea272257SMauro Carvalho Chehab { lat:        233, common_pid:       2036 } hitcount:          5
2374ea272257SMauro Carvalho Chehab { lat:        233, common_pid:       2039 } hitcount:         11
2375ea272257SMauro Carvalho Chehab { lat:        234, common_pid:       2039 } hitcount:          4
2376ea272257SMauro Carvalho Chehab { lat:        234, common_pid:       2038 } hitcount:          2
2377ea272257SMauro Carvalho Chehab { lat:        234, common_pid:       2043 } hitcount:          2
2378ea272257SMauro Carvalho Chehab { lat:        234, common_pid:       2036 } hitcount:         11
2379ea272257SMauro Carvalho Chehab { lat:        234, common_pid:       2040 } hitcount:          1
2380ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2037 } hitcount:          2
2381ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2036 } hitcount:          8
2382ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2043 } hitcount:          2
2383ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2039 } hitcount:          5
2384ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2042 } hitcount:          2
2385ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2040 } hitcount:          4
2386ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2041 } hitcount:          1
2387ea272257SMauro Carvalho Chehab { lat:        236, common_pid:       2036 } hitcount:          7
2388ea272257SMauro Carvalho Chehab { lat:        236, common_pid:       2037 } hitcount:          1
2389ea272257SMauro Carvalho Chehab { lat:        236, common_pid:       2041 } hitcount:          5
2390ea272257SMauro Carvalho Chehab { lat:        236, common_pid:       2039 } hitcount:          3
2391ea272257SMauro Carvalho Chehab { lat:        236, common_pid:       2043 } hitcount:          9
2392ea272257SMauro Carvalho Chehab { lat:        236, common_pid:       2040 } hitcount:          7
2393ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2037 } hitcount:          1
2394ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2040 } hitcount:          1
2395ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2036 } hitcount:          9
2396ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2039 } hitcount:          3
2397ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2043 } hitcount:          8
2398ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2042 } hitcount:          2
2399ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2041 } hitcount:          2
2400ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2043 } hitcount:         10
2401ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2040 } hitcount:          1
2402ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2037 } hitcount:          9
2403ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2038 } hitcount:          1
2404ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2039 } hitcount:          1
2405ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2042 } hitcount:          3
2406ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2036 } hitcount:          7
2407ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2041 } hitcount:          1
2408ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2043 } hitcount:         11
2409ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2037 } hitcount:         11
2410ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2038 } hitcount:          6
2411ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2036 } hitcount:          7
2412ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2040 } hitcount:          1
2413ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2042 } hitcount:          9
2414ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2037 } hitcount:         29
2415ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2043 } hitcount:         15
2416ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2040 } hitcount:         44
2417ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2039 } hitcount:          1
2418ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2041 } hitcount:          2
2419ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2038 } hitcount:          1
2420ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2036 } hitcount:         10
2421ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2042 } hitcount:         13
2422ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2036 } hitcount:         21
2423ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2041 } hitcount:         36
2424ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2037 } hitcount:         34
2425ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2042 } hitcount:         14
2426ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2040 } hitcount:         94
2427ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2039 } hitcount:         12
2428ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2038 } hitcount:          2
2429ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2043 } hitcount:         28
2430ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2040 } hitcount:        109
2431ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2041 } hitcount:        506
2432ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2039 } hitcount:        155
2433ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2042 } hitcount:         21
2434ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2037 } hitcount:         52
2435ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2043 } hitcount:         21
2436ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2036 } hitcount:         16
2437ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2038 } hitcount:        156
2438ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2037 } hitcount:         46
2439ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2039 } hitcount:         40
2440ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2042 } hitcount:        119
2441ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2041 } hitcount:        611
2442ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2036 } hitcount:         69
2443ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2038 } hitcount:        784
2444ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2040 } hitcount:        323
2445ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2043 } hitcount:         14
2446ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2043 } hitcount:         35
2447ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2042 } hitcount:        305
2448ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2039 } hitcount:          8
2449ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2040 } hitcount:       4515
2450ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2038 } hitcount:        371
2451ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2037 } hitcount:         31
2452ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2036 } hitcount:        114
2453ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2041 } hitcount:       3396
2454ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2036 } hitcount:        700
2455ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2041 } hitcount:       2772
2456ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2037 } hitcount:        268
2457ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2039 } hitcount:        472
2458ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2038 } hitcount:       2758
2459ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2042 } hitcount:       3833
2460ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2040 } hitcount:       3105
2461ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2043 } hitcount:        645
2462ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2038 } hitcount:       3451
2463ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2041 } hitcount:        142
2464ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2037 } hitcount:       5101
2465ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2040 } hitcount:         68
2466ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2043 } hitcount:       5099
2467ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2039 } hitcount:       5608
2468ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2042 } hitcount:       3723
2469ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2036 } hitcount:       4738
2470ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2042 } hitcount:        312
2471ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2043 } hitcount:       2385
2472ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2041 } hitcount:        452
2473ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2038 } hitcount:        792
2474ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2040 } hitcount:         78
2475ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2036 } hitcount:       2375
2476ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2039 } hitcount:       1834
2477ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2037 } hitcount:       2655
2478ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2037 } hitcount:         36
2479ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2042 } hitcount:         11
2480ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2038 } hitcount:        122
2481ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2036 } hitcount:        135
2482ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2039 } hitcount:         26
2483ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2041 } hitcount:        503
2484ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2043 } hitcount:         66
2485ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2040 } hitcount:         46
2486ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2037 } hitcount:         29
2487ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2038 } hitcount:          1
2488ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2043 } hitcount:         29
2489ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2039 } hitcount:          8
2490ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2042 } hitcount:         56
2491ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2040 } hitcount:         27
2492ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2041 } hitcount:         11
2493ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2036 } hitcount:         27
2494ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2038 } hitcount:          1
2495ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2036 } hitcount:         30
2496ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2040 } hitcount:         19
2497ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2043 } hitcount:         22
2498ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2042 } hitcount:         20
2499ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2041 } hitcount:          1
2500ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2039 } hitcount:          6
2501ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2037 } hitcount:         48
2502ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2037 } hitcount:         43
2503ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2039 } hitcount:          1
2504ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2036 } hitcount:         12
2505ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2042 } hitcount:          2
2506ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2041 } hitcount:          1
2507ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2043 } hitcount:         15
2508ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2040 } hitcount:          3
2509ea272257SMauro Carvalho Chehab { lat:        252, common_pid:       2040 } hitcount:          1
2510ea272257SMauro Carvalho Chehab { lat:        252, common_pid:       2036 } hitcount:         12
2511ea272257SMauro Carvalho Chehab { lat:        252, common_pid:       2037 } hitcount:         21
2512ea272257SMauro Carvalho Chehab { lat:        252, common_pid:       2043 } hitcount:         14
2513ea272257SMauro Carvalho Chehab { lat:        253, common_pid:       2037 } hitcount:         21
2514ea272257SMauro Carvalho Chehab { lat:        253, common_pid:       2039 } hitcount:          2
2515ea272257SMauro Carvalho Chehab { lat:        253, common_pid:       2036 } hitcount:          9
2516ea272257SMauro Carvalho Chehab { lat:        253, common_pid:       2043 } hitcount:          6
2517ea272257SMauro Carvalho Chehab { lat:        253, common_pid:       2040 } hitcount:          1
2518ea272257SMauro Carvalho Chehab { lat:        254, common_pid:       2036 } hitcount:          8
2519ea272257SMauro Carvalho Chehab { lat:        254, common_pid:       2043 } hitcount:          3
2520ea272257SMauro Carvalho Chehab { lat:        254, common_pid:       2041 } hitcount:          1
2521ea272257SMauro Carvalho Chehab { lat:        254, common_pid:       2042 } hitcount:          1
2522ea272257SMauro Carvalho Chehab { lat:        254, common_pid:       2039 } hitcount:          1
2523ea272257SMauro Carvalho Chehab { lat:        254, common_pid:       2037 } hitcount:         12
2524ea272257SMauro Carvalho Chehab { lat:        255, common_pid:       2043 } hitcount:          1
2525ea272257SMauro Carvalho Chehab { lat:        255, common_pid:       2037 } hitcount:          2
2526ea272257SMauro Carvalho Chehab { lat:        255, common_pid:       2036 } hitcount:          2
2527ea272257SMauro Carvalho Chehab { lat:        255, common_pid:       2039 } hitcount:          8
2528ea272257SMauro Carvalho Chehab { lat:        256, common_pid:       2043 } hitcount:          1
2529ea272257SMauro Carvalho Chehab { lat:        256, common_pid:       2036 } hitcount:          4
2530ea272257SMauro Carvalho Chehab { lat:        256, common_pid:       2039 } hitcount:          6
2531ea272257SMauro Carvalho Chehab { lat:        257, common_pid:       2039 } hitcount:          5
2532ea272257SMauro Carvalho Chehab { lat:        257, common_pid:       2036 } hitcount:          4
2533ea272257SMauro Carvalho Chehab { lat:        258, common_pid:       2039 } hitcount:          5
2534ea272257SMauro Carvalho Chehab { lat:        258, common_pid:       2036 } hitcount:          2
2535ea272257SMauro Carvalho Chehab { lat:        259, common_pid:       2036 } hitcount:          7
2536ea272257SMauro Carvalho Chehab { lat:        259, common_pid:       2039 } hitcount:          7
2537ea272257SMauro Carvalho Chehab { lat:        260, common_pid:       2036 } hitcount:          8
2538ea272257SMauro Carvalho Chehab { lat:        260, common_pid:       2039 } hitcount:          6
2539ea272257SMauro Carvalho Chehab { lat:        261, common_pid:       2036 } hitcount:          5
2540ea272257SMauro Carvalho Chehab { lat:        261, common_pid:       2039 } hitcount:          7
2541ea272257SMauro Carvalho Chehab { lat:        262, common_pid:       2039 } hitcount:          5
2542ea272257SMauro Carvalho Chehab { lat:        262, common_pid:       2036 } hitcount:          5
2543ea272257SMauro Carvalho Chehab { lat:        263, common_pid:       2039 } hitcount:          7
2544ea272257SMauro Carvalho Chehab { lat:        263, common_pid:       2036 } hitcount:          7
2545ea272257SMauro Carvalho Chehab { lat:        264, common_pid:       2039 } hitcount:          9
2546ea272257SMauro Carvalho Chehab { lat:        264, common_pid:       2036 } hitcount:          9
2547ea272257SMauro Carvalho Chehab { lat:        265, common_pid:       2036 } hitcount:          5
2548ea272257SMauro Carvalho Chehab { lat:        265, common_pid:       2039 } hitcount:          1
2549ea272257SMauro Carvalho Chehab { lat:        266, common_pid:       2036 } hitcount:          1
2550ea272257SMauro Carvalho Chehab { lat:        266, common_pid:       2039 } hitcount:          3
2551ea272257SMauro Carvalho Chehab { lat:        267, common_pid:       2036 } hitcount:          1
2552ea272257SMauro Carvalho Chehab { lat:        267, common_pid:       2039 } hitcount:          3
2553ea272257SMauro Carvalho Chehab { lat:        268, common_pid:       2036 } hitcount:          1
2554ea272257SMauro Carvalho Chehab { lat:        268, common_pid:       2039 } hitcount:          6
2555ea272257SMauro Carvalho Chehab { lat:        269, common_pid:       2036 } hitcount:          1
2556ea272257SMauro Carvalho Chehab { lat:        269, common_pid:       2043 } hitcount:          1
2557ea272257SMauro Carvalho Chehab { lat:        269, common_pid:       2039 } hitcount:          2
2558ea272257SMauro Carvalho Chehab { lat:        270, common_pid:       2040 } hitcount:          1
2559ea272257SMauro Carvalho Chehab { lat:        270, common_pid:       2039 } hitcount:          6
2560ea272257SMauro Carvalho Chehab { lat:        271, common_pid:       2041 } hitcount:          1
2561ea272257SMauro Carvalho Chehab { lat:        271, common_pid:       2039 } hitcount:          5
2562ea272257SMauro Carvalho Chehab { lat:        272, common_pid:       2039 } hitcount:         10
2563ea272257SMauro Carvalho Chehab { lat:        273, common_pid:       2039 } hitcount:          8
2564ea272257SMauro Carvalho Chehab { lat:        274, common_pid:       2039 } hitcount:          2
2565ea272257SMauro Carvalho Chehab { lat:        275, common_pid:       2039 } hitcount:          1
2566ea272257SMauro Carvalho Chehab { lat:        276, common_pid:       2039 } hitcount:          2
2567ea272257SMauro Carvalho Chehab { lat:        276, common_pid:       2037 } hitcount:          1
2568ea272257SMauro Carvalho Chehab { lat:        276, common_pid:       2038 } hitcount:          1
2569ea272257SMauro Carvalho Chehab { lat:        277, common_pid:       2039 } hitcount:          1
2570ea272257SMauro Carvalho Chehab { lat:        277, common_pid:       2042 } hitcount:          1
2571ea272257SMauro Carvalho Chehab { lat:        278, common_pid:       2039 } hitcount:          1
2572ea272257SMauro Carvalho Chehab { lat:        279, common_pid:       2039 } hitcount:          4
2573ea272257SMauro Carvalho Chehab { lat:        279, common_pid:       2043 } hitcount:          1
2574ea272257SMauro Carvalho Chehab { lat:        280, common_pid:       2039 } hitcount:          3
2575ea272257SMauro Carvalho Chehab { lat:        283, common_pid:       2036 } hitcount:          2
2576ea272257SMauro Carvalho Chehab { lat:        284, common_pid:       2039 } hitcount:          1
2577ea272257SMauro Carvalho Chehab { lat:        284, common_pid:       2043 } hitcount:          1
2578ea272257SMauro Carvalho Chehab { lat:        288, common_pid:       2039 } hitcount:          1
2579ea272257SMauro Carvalho Chehab { lat:        289, common_pid:       2039 } hitcount:          1
2580ea272257SMauro Carvalho Chehab { lat:        300, common_pid:       2039 } hitcount:          1
2581ea272257SMauro Carvalho Chehab { lat:        384, common_pid:       2039 } hitcount:          1
2582ea272257SMauro Carvalho Chehab
2583ea272257SMauro Carvalho Chehab Totals:
2584ea272257SMauro Carvalho Chehab     Hits: 67625
2585ea272257SMauro Carvalho Chehab     Entries: 278
2586ea272257SMauro Carvalho Chehab     Dropped: 0
2587ea272257SMauro Carvalho Chehab
2588ea272257SMauro Carvalho ChehabNote, the writes are around the sleep, so ideally they will all be of 250
2589ea272257SMauro Carvalho Chehabmicroseconds. If you are wondering how there are several that are under
2590ea272257SMauro Carvalho Chehab250 microseconds, that is because the way cyclictest works, is if one
2591ea272257SMauro Carvalho Chehabiteration comes in late, the next one will set the timer to wake up less that
2592ea272257SMauro Carvalho Chehab250. That is, if an iteration came in 50 microseconds late, the next wake up
2593ea272257SMauro Carvalho Chehabwill be at 200 microseconds.
2594ea272257SMauro Carvalho Chehab
2595ea272257SMauro Carvalho ChehabBut this could easily be done in userspace. To make this even more
2596ea272257SMauro Carvalho Chehabinteresting, we can mix the histogram between events that happened in the
2597ea272257SMauro Carvalho Chehabkernel with trace_marker::
2598ea272257SMauro Carvalho Chehab
2599ea272257SMauro Carvalho Chehab # cd /sys/kernel/tracing
2600ea272257SMauro Carvalho Chehab # echo 'latency u64 lat' > synthetic_events
2601ea272257SMauro Carvalho Chehab # echo 'hist:keys=pid:ts0=common_timestamp.usecs' > events/sched/sched_waking/trigger
2602ea272257SMauro Carvalho Chehab # echo 'hist:keys=common_pid:lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).latency($lat) if buf == "end"' > events/ftrace/print/trigger
2603ea272257SMauro Carvalho Chehab # echo 'hist:keys=lat,common_pid:sort=lat' > events/synthetic/latency/trigger
2604ea272257SMauro Carvalho Chehab
2605ea272257SMauro Carvalho ChehabThe difference this time is that instead of using the trace_marker to start
2606ea272257SMauro Carvalho Chehabthe latency, the sched_waking event is used, matching the common_pid for the
2607ea272257SMauro Carvalho Chehabtrace_marker write with the pid that is being woken by sched_waking.
2608ea272257SMauro Carvalho Chehab
2609ea272257SMauro Carvalho ChehabAfter running cyclictest again with the same parameters, we now have::
2610ea272257SMauro Carvalho Chehab
2611ea272257SMauro Carvalho Chehab # cat events/synthetic/latency/hist
2612ea272257SMauro Carvalho Chehab # event histogram
2613ea272257SMauro Carvalho Chehab #
2614ea272257SMauro Carvalho Chehab # trigger info: hist:keys=lat,common_pid:vals=hitcount:sort=lat:size=2048 [active]
2615ea272257SMauro Carvalho Chehab #
2616ea272257SMauro Carvalho Chehab
2617ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2302 } hitcount:        640
2618ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2299 } hitcount:         42
2619ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2303 } hitcount:         18
2620ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2305 } hitcount:        166
2621ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2306 } hitcount:          1
2622ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2301 } hitcount:         91
2623ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2300 } hitcount:         17
2624ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2303 } hitcount:       8296
2625ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2304 } hitcount:       6864
2626ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2305 } hitcount:       9464
2627ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2301 } hitcount:       9213
2628ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2306 } hitcount:       6246
2629ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2302 } hitcount:       8797
2630ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2299 } hitcount:       8771
2631ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2300 } hitcount:       8119
2632ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2305 } hitcount:       1519
2633ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2299 } hitcount:       2346
2634ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2303 } hitcount:       2841
2635ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2301 } hitcount:       1846
2636ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2304 } hitcount:       3861
2637ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2302 } hitcount:       1210
2638ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2300 } hitcount:       2762
2639ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2306 } hitcount:       4247
2640ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2299 } hitcount:         16
2641ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2306 } hitcount:        333
2642ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2303 } hitcount:         16
2643ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2304 } hitcount:        168
2644ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2302 } hitcount:        240
2645ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2301 } hitcount:         28
2646ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2300 } hitcount:         95
2647ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2305 } hitcount:         18
2648ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2303 } hitcount:          5
2649ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2305 } hitcount:          8
2650ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2306 } hitcount:        221
2651ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2302 } hitcount:         76
2652ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2304 } hitcount:         26
2653ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2300 } hitcount:        125
2654ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2299 } hitcount:          2
2655ea272257SMauro Carvalho Chehab { lat:         12, common_pid:       2305 } hitcount:          3
2656ea272257SMauro Carvalho Chehab { lat:         12, common_pid:       2300 } hitcount:          6
2657ea272257SMauro Carvalho Chehab { lat:         12, common_pid:       2306 } hitcount:         90
2658ea272257SMauro Carvalho Chehab { lat:         12, common_pid:       2302 } hitcount:          4
2659ea272257SMauro Carvalho Chehab { lat:         12, common_pid:       2303 } hitcount:          1
2660ea272257SMauro Carvalho Chehab { lat:         12, common_pid:       2304 } hitcount:        122
2661ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2300 } hitcount:         12
2662ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2301 } hitcount:          1
2663ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2306 } hitcount:         32
2664ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2302 } hitcount:          5
2665ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2305 } hitcount:          1
2666ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2303 } hitcount:          1
2667ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2304 } hitcount:         61
2668ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2303 } hitcount:          4
2669ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2306 } hitcount:          5
2670ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2305 } hitcount:          4
2671ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2304 } hitcount:         62
2672ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2302 } hitcount:         19
2673ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2300 } hitcount:         33
2674ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2299 } hitcount:          1
2675ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2301 } hitcount:          4
2676ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2305 } hitcount:          1
2677ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2302 } hitcount:         25
2678ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2300 } hitcount:         11
2679ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2299 } hitcount:          5
2680ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2301 } hitcount:          1
2681ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2304 } hitcount:          8
2682ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2303 } hitcount:          1
2683ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2306 } hitcount:          6
2684ea272257SMauro Carvalho Chehab { lat:         16, common_pid:       2302 } hitcount:         31
2685ea272257SMauro Carvalho Chehab { lat:         16, common_pid:       2306 } hitcount:          3
2686ea272257SMauro Carvalho Chehab { lat:         16, common_pid:       2300 } hitcount:          5
2687ea272257SMauro Carvalho Chehab { lat:         17, common_pid:       2302 } hitcount:          6
2688ea272257SMauro Carvalho Chehab { lat:         17, common_pid:       2303 } hitcount:          1
2689ea272257SMauro Carvalho Chehab { lat:         18, common_pid:       2304 } hitcount:          1
2690ea272257SMauro Carvalho Chehab { lat:         18, common_pid:       2302 } hitcount:          8
2691ea272257SMauro Carvalho Chehab { lat:         18, common_pid:       2299 } hitcount:          1
2692ea272257SMauro Carvalho Chehab { lat:         18, common_pid:       2301 } hitcount:          1
2693ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2303 } hitcount:          4
2694ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2304 } hitcount:          5
2695ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2302 } hitcount:          4
2696ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2299 } hitcount:          3
2697ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2306 } hitcount:          1
2698ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2300 } hitcount:          4
2699ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2305 } hitcount:          5
2700ea272257SMauro Carvalho Chehab { lat:         20, common_pid:       2299 } hitcount:          2
2701ea272257SMauro Carvalho Chehab { lat:         20, common_pid:       2302 } hitcount:          3
2702ea272257SMauro Carvalho Chehab { lat:         20, common_pid:       2305 } hitcount:          1
2703ea272257SMauro Carvalho Chehab { lat:         20, common_pid:       2300 } hitcount:          2
2704ea272257SMauro Carvalho Chehab { lat:         20, common_pid:       2301 } hitcount:          2
2705ea272257SMauro Carvalho Chehab { lat:         20, common_pid:       2303 } hitcount:          3
2706ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2305 } hitcount:          1
2707ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2299 } hitcount:          5
2708ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2303 } hitcount:          4
2709ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2302 } hitcount:          7
2710ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2300 } hitcount:          1
2711ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2301 } hitcount:          5
2712ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2304 } hitcount:          2
2713ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2302 } hitcount:          5
2714ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2303 } hitcount:          1
2715ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2306 } hitcount:          3
2716ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2301 } hitcount:          2
2717ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2300 } hitcount:          1
2718ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2299 } hitcount:          1
2719ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2305 } hitcount:          1
2720ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2304 } hitcount:          1
2721ea272257SMauro Carvalho Chehab { lat:         23, common_pid:       2299 } hitcount:          1
2722ea272257SMauro Carvalho Chehab { lat:         23, common_pid:       2306 } hitcount:          2
2723ea272257SMauro Carvalho Chehab { lat:         23, common_pid:       2302 } hitcount:          6
2724ea272257SMauro Carvalho Chehab { lat:         24, common_pid:       2302 } hitcount:          3
2725ea272257SMauro Carvalho Chehab { lat:         24, common_pid:       2300 } hitcount:          1
2726ea272257SMauro Carvalho Chehab { lat:         24, common_pid:       2306 } hitcount:          2
2727ea272257SMauro Carvalho Chehab { lat:         24, common_pid:       2305 } hitcount:          1
2728ea272257SMauro Carvalho Chehab { lat:         24, common_pid:       2299 } hitcount:          1
2729ea272257SMauro Carvalho Chehab { lat:         25, common_pid:       2300 } hitcount:          1
2730ea272257SMauro Carvalho Chehab { lat:         25, common_pid:       2302 } hitcount:          4
2731ea272257SMauro Carvalho Chehab { lat:         26, common_pid:       2302 } hitcount:          2
2732ea272257SMauro Carvalho Chehab { lat:         27, common_pid:       2305 } hitcount:          1
2733ea272257SMauro Carvalho Chehab { lat:         27, common_pid:       2300 } hitcount:          1
2734ea272257SMauro Carvalho Chehab { lat:         27, common_pid:       2302 } hitcount:          3
2735ea272257SMauro Carvalho Chehab { lat:         28, common_pid:       2306 } hitcount:          1
2736ea272257SMauro Carvalho Chehab { lat:         28, common_pid:       2302 } hitcount:          4
2737ea272257SMauro Carvalho Chehab { lat:         29, common_pid:       2302 } hitcount:          1
2738ea272257SMauro Carvalho Chehab { lat:         29, common_pid:       2300 } hitcount:          2
2739ea272257SMauro Carvalho Chehab { lat:         29, common_pid:       2306 } hitcount:          1
2740ea272257SMauro Carvalho Chehab { lat:         29, common_pid:       2304 } hitcount:          1
2741ea272257SMauro Carvalho Chehab { lat:         30, common_pid:       2302 } hitcount:          4
2742ea272257SMauro Carvalho Chehab { lat:         31, common_pid:       2302 } hitcount:          6
2743ea272257SMauro Carvalho Chehab { lat:         32, common_pid:       2302 } hitcount:          1
2744ea272257SMauro Carvalho Chehab { lat:         33, common_pid:       2299 } hitcount:          1
2745ea272257SMauro Carvalho Chehab { lat:         33, common_pid:       2302 } hitcount:          3
2746ea272257SMauro Carvalho Chehab { lat:         34, common_pid:       2302 } hitcount:          2
2747ea272257SMauro Carvalho Chehab { lat:         35, common_pid:       2302 } hitcount:          1
2748ea272257SMauro Carvalho Chehab { lat:         35, common_pid:       2304 } hitcount:          1
2749ea272257SMauro Carvalho Chehab { lat:         36, common_pid:       2302 } hitcount:          4
2750ea272257SMauro Carvalho Chehab { lat:         37, common_pid:       2302 } hitcount:          6
2751ea272257SMauro Carvalho Chehab { lat:         38, common_pid:       2302 } hitcount:          2
2752ea272257SMauro Carvalho Chehab { lat:         39, common_pid:       2302 } hitcount:          2
2753ea272257SMauro Carvalho Chehab { lat:         39, common_pid:       2304 } hitcount:          1
2754ea272257SMauro Carvalho Chehab { lat:         40, common_pid:       2304 } hitcount:          2
2755ea272257SMauro Carvalho Chehab { lat:         40, common_pid:       2302 } hitcount:          5
2756ea272257SMauro Carvalho Chehab { lat:         41, common_pid:       2304 } hitcount:          1
2757ea272257SMauro Carvalho Chehab { lat:         41, common_pid:       2302 } hitcount:          8
2758ea272257SMauro Carvalho Chehab { lat:         42, common_pid:       2302 } hitcount:          6
2759ea272257SMauro Carvalho Chehab { lat:         42, common_pid:       2304 } hitcount:          1
2760ea272257SMauro Carvalho Chehab { lat:         43, common_pid:       2302 } hitcount:          3
2761ea272257SMauro Carvalho Chehab { lat:         43, common_pid:       2304 } hitcount:          4
2762ea272257SMauro Carvalho Chehab { lat:         44, common_pid:       2302 } hitcount:          6
2763ea272257SMauro Carvalho Chehab { lat:         45, common_pid:       2302 } hitcount:          5
2764ea272257SMauro Carvalho Chehab { lat:         46, common_pid:       2302 } hitcount:          5
2765ea272257SMauro Carvalho Chehab { lat:         47, common_pid:       2302 } hitcount:          7
2766ea272257SMauro Carvalho Chehab { lat:         48, common_pid:       2301 } hitcount:          1
2767ea272257SMauro Carvalho Chehab { lat:         48, common_pid:       2302 } hitcount:          9
2768ea272257SMauro Carvalho Chehab { lat:         49, common_pid:       2302 } hitcount:          3
2769ea272257SMauro Carvalho Chehab { lat:         50, common_pid:       2302 } hitcount:          1
2770ea272257SMauro Carvalho Chehab { lat:         50, common_pid:       2301 } hitcount:          1
2771ea272257SMauro Carvalho Chehab { lat:         51, common_pid:       2302 } hitcount:          2
2772ea272257SMauro Carvalho Chehab { lat:         51, common_pid:       2301 } hitcount:          1
2773ea272257SMauro Carvalho Chehab { lat:         61, common_pid:       2302 } hitcount:          1
2774ea272257SMauro Carvalho Chehab { lat:        110, common_pid:       2302 } hitcount:          1
2775ea272257SMauro Carvalho Chehab
2776ea272257SMauro Carvalho Chehab Totals:
2777ea272257SMauro Carvalho Chehab     Hits: 89565
2778ea272257SMauro Carvalho Chehab     Entries: 158
2779ea272257SMauro Carvalho Chehab     Dropped: 0
2780ea272257SMauro Carvalho Chehab
2781ea272257SMauro Carvalho ChehabThis doesn't tell us any information about how late cyclictest may have
2782ea272257SMauro Carvalho Chehabwoken up, but it does show us a nice histogram of how long it took from
2783ea272257SMauro Carvalho Chehabthe time that cyclictest was woken to the time it made it into user space.
2784