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]
288c2b9979SMasami Hiramatsu (Google)          [:clear][:name=histname1][:nohitcount][:<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.
38*4b512860SSteven Rostedt (Google)  Keys can be any field, or the special string 'common_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
42a635beeaSZheng Yejian  keys consisting of up to three 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
57*4b512860SSteven Rostedt (Google)  'common_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
734420f5b1SSteven Rostedt (VMware)	=============  =================================================
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
8037036435SSteven Rostedt (VMware)	.buckets=size  display grouping of values rather than raw number
81ea272257SMauro Carvalho Chehab	.usecs         display a common_timestamp in microseconds
828c2b9979SMasami Hiramatsu (Google)        .percent       display a number of percentage value
838c2b9979SMasami Hiramatsu (Google)        .graph         display a bar-graph of a value
8488238513SSteven Rostedt (Google)	.stacktrace    display as a stacktrace (must by a long[] type)
854420f5b1SSteven Rostedt (VMware)	=============  =================================================
86ea272257SMauro Carvalho Chehab
87ea272257SMauro Carvalho Chehab  Note that in general the semantics of a given field aren't
88ea272257SMauro Carvalho Chehab  interpreted when applying a modifier to it, but there are some
89ea272257SMauro Carvalho Chehab  restrictions to be aware of in this regard:
90ea272257SMauro Carvalho Chehab
91ea272257SMauro Carvalho Chehab    - only the 'hex' modifier can be used for values (because values
92ea272257SMauro Carvalho Chehab      are essentially sums, and the other modifiers don't make sense
93ea272257SMauro Carvalho Chehab      in that context).
94ea272257SMauro Carvalho Chehab    - the 'execname' modifier can only be used on a 'common_pid'.  The
95ea272257SMauro Carvalho Chehab      reason for this is that the execname is simply the 'comm' value
96ea272257SMauro Carvalho Chehab      saved for the 'current' process when an event was triggered,
97ea272257SMauro Carvalho Chehab      which is the same as the common_pid value saved by the event
98ea272257SMauro Carvalho Chehab      tracing code.  Trying to apply that comm value to other pid
99ea272257SMauro Carvalho Chehab      values wouldn't be correct, and typically events that care save
100ea272257SMauro Carvalho Chehab      pid-specific comm fields in the event itself.
101ea272257SMauro Carvalho Chehab
102ea272257SMauro Carvalho Chehab  A typical usage scenario would be the following to enable a hist
103ea272257SMauro Carvalho Chehab  trigger, read its current contents, and then turn it off::
104ea272257SMauro Carvalho Chehab
105ea272257SMauro Carvalho Chehab    # echo 'hist:keys=skbaddr.hex:vals=len' > \
1062abfcd29SRoss Zwisler      /sys/kernel/tracing/events/net/netif_rx/trigger
107ea272257SMauro Carvalho Chehab
1082abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/net/netif_rx/hist
109ea272257SMauro Carvalho Chehab
110ea272257SMauro Carvalho Chehab    # echo '!hist:keys=skbaddr.hex:vals=len' > \
1112abfcd29SRoss Zwisler      /sys/kernel/tracing/events/net/netif_rx/trigger
112ea272257SMauro Carvalho Chehab
113ea272257SMauro Carvalho Chehab  The trigger file itself can be read to show the details of the
114ea272257SMauro Carvalho Chehab  currently attached hist trigger.  This information is also displayed
115ea272257SMauro Carvalho Chehab  at the top of the 'hist' file when read.
116ea272257SMauro Carvalho Chehab
117ea272257SMauro Carvalho Chehab  By default, the size of the hash table is 2048 entries.  The 'size'
118ea272257SMauro Carvalho Chehab  parameter can be used to specify more or fewer than that.  The units
119ea272257SMauro Carvalho Chehab  are in terms of hashtable entries - if a run uses more entries than
120ea272257SMauro Carvalho Chehab  specified, the results will show the number of 'drops', the number
121ea272257SMauro Carvalho Chehab  of hits that were ignored.  The size should be a power of 2 between
122ea272257SMauro Carvalho Chehab  128 and 131072 (any non- power-of-2 number specified will be rounded
123ea272257SMauro Carvalho Chehab  up).
124ea272257SMauro Carvalho Chehab
125ea272257SMauro Carvalho Chehab  The 'sort' parameter can be used to specify a value field to sort
126ea272257SMauro Carvalho Chehab  on.  The default if unspecified is 'hitcount' and the default sort
127ea272257SMauro Carvalho Chehab  order is 'ascending'.  To sort in the opposite direction, append
128ea272257SMauro Carvalho Chehab  .descending' to the sort key.
129ea272257SMauro Carvalho Chehab
130ea272257SMauro Carvalho Chehab  The 'pause' parameter can be used to pause an existing hist trigger
131ea272257SMauro Carvalho Chehab  or to start a hist trigger but not log any events until told to do
132ea272257SMauro Carvalho Chehab  so.  'continue' or 'cont' can be used to start or restart a paused
133ea272257SMauro Carvalho Chehab  hist trigger.
134ea272257SMauro Carvalho Chehab
135ea272257SMauro Carvalho Chehab  The 'clear' parameter will clear the contents of a running hist
136ea272257SMauro Carvalho Chehab  trigger and leave its current paused/active state.
137ea272257SMauro Carvalho Chehab
138ea272257SMauro Carvalho Chehab  Note that the 'pause', 'cont', and 'clear' parameters should be
139ea272257SMauro Carvalho Chehab  applied using 'append' shell operator ('>>') if applied to an
140ea272257SMauro Carvalho Chehab  existing trigger, rather than via the '>' operator, which will cause
141ea272257SMauro Carvalho Chehab  the trigger to be removed through truncation.
142ea272257SMauro Carvalho Chehab
1438c2b9979SMasami Hiramatsu (Google)  The 'nohitcount' (or NOHC) parameter will suppress display of
1448c2b9979SMasami Hiramatsu (Google)  raw hitcount in the histogram. This option requires at least one
1458c2b9979SMasami Hiramatsu (Google)  value field which is not a 'raw hitcount'. For example,
1468c2b9979SMasami Hiramatsu (Google)  'hist:...:vals=hitcount:nohitcount' is rejected, but
1478c2b9979SMasami Hiramatsu (Google)  'hist:...:vals=hitcount.percent:nohitcount' is OK.
1488c2b9979SMasami Hiramatsu (Google)
149ea272257SMauro Carvalho Chehab- enable_hist/disable_hist
150ea272257SMauro Carvalho Chehab
151ea272257SMauro Carvalho Chehab  The enable_hist and disable_hist triggers can be used to have one
152ea272257SMauro Carvalho Chehab  event conditionally start and stop another event's already-attached
153ea272257SMauro Carvalho Chehab  hist trigger.  Any number of enable_hist and disable_hist triggers
154ea272257SMauro Carvalho Chehab  can be attached to a given event, allowing that event to kick off
155ea272257SMauro Carvalho Chehab  and stop aggregations on a host of other events.
156ea272257SMauro Carvalho Chehab
157ea272257SMauro Carvalho Chehab  The format is very similar to the enable/disable_event triggers::
158ea272257SMauro Carvalho Chehab
159ea272257SMauro Carvalho Chehab      enable_hist:<system>:<event>[:count]
160ea272257SMauro Carvalho Chehab      disable_hist:<system>:<event>[:count]
161ea272257SMauro Carvalho Chehab
162ea272257SMauro Carvalho Chehab  Instead of enabling or disabling the tracing of the target event
163ea272257SMauro Carvalho Chehab  into the trace buffer as the enable/disable_event triggers do, the
164ea272257SMauro Carvalho Chehab  enable/disable_hist triggers enable or disable the aggregation of
165ea272257SMauro Carvalho Chehab  the target event into a hash table.
166ea272257SMauro Carvalho Chehab
167ea272257SMauro Carvalho Chehab  A typical usage scenario for the enable_hist/disable_hist triggers
168ea272257SMauro Carvalho Chehab  would be to first set up a paused hist trigger on some event,
169ea272257SMauro Carvalho Chehab  followed by an enable_hist/disable_hist pair that turns the hist
170ea272257SMauro Carvalho Chehab  aggregation on and off when conditions of interest are hit::
171ea272257SMauro Carvalho Chehab
172ea272257SMauro Carvalho Chehab   # echo 'hist:keys=skbaddr.hex:vals=len:pause' > \
1732abfcd29SRoss Zwisler      /sys/kernel/tracing/events/net/netif_receive_skb/trigger
174ea272257SMauro Carvalho Chehab
175ea272257SMauro Carvalho Chehab    # echo 'enable_hist:net:netif_receive_skb if filename==/usr/bin/wget' > \
1762abfcd29SRoss Zwisler      /sys/kernel/tracing/events/sched/sched_process_exec/trigger
177ea272257SMauro Carvalho Chehab
178ea272257SMauro Carvalho Chehab    # echo 'disable_hist:net:netif_receive_skb if comm==wget' > \
1792abfcd29SRoss Zwisler      /sys/kernel/tracing/events/sched/sched_process_exit/trigger
180ea272257SMauro Carvalho Chehab
181ea272257SMauro Carvalho Chehab  The above sets up an initially paused hist trigger which is unpaused
182ea272257SMauro Carvalho Chehab  and starts aggregating events when a given program is executed, and
183ea272257SMauro Carvalho Chehab  which stops aggregating when the process exits and the hist trigger
184ea272257SMauro Carvalho Chehab  is paused again.
185ea272257SMauro Carvalho Chehab
186ea272257SMauro Carvalho Chehab  The examples below provide a more concrete illustration of the
187ea272257SMauro Carvalho Chehab  concepts and typical usage patterns discussed above.
188ea272257SMauro Carvalho Chehab
189ea272257SMauro Carvalho Chehab'special' event fields
190ea272257SMauro Carvalho Chehab------------------------
191ea272257SMauro Carvalho Chehab
192ea272257SMauro Carvalho Chehab  There are a number of 'special event fields' available for use as
193ea272257SMauro Carvalho Chehab  keys or values in a hist trigger.  These look like and behave as if
194ea272257SMauro Carvalho Chehab  they were actual event fields, but aren't really part of the event's
195ea272257SMauro Carvalho Chehab  field definition or format file.  They are however available for any
196ea272257SMauro Carvalho Chehab  event, and can be used anywhere an actual event field could be.
197ea272257SMauro Carvalho Chehab  They are:
198ea272257SMauro Carvalho Chehab
199ea272257SMauro Carvalho Chehab    ====================== ==== =======================================
200ea272257SMauro Carvalho Chehab    common_timestamp       u64  timestamp (from ring buffer) associated
201ea272257SMauro Carvalho Chehab                                with the event, in nanoseconds.  May be
202ea272257SMauro Carvalho Chehab			        modified by .usecs to have timestamps
203ea272257SMauro Carvalho Chehab			        interpreted as microseconds.
2041e3bac71SSteven Rostedt (VMware)    common_cpu             int  the cpu on which the event occurred.
205ea272257SMauro Carvalho Chehab    ====================== ==== =======================================
206ea272257SMauro Carvalho Chehab
207ea272257SMauro Carvalho ChehabExtended error information
208ea272257SMauro Carvalho Chehab--------------------------
209ea272257SMauro Carvalho Chehab
210ea272257SMauro Carvalho Chehab  For some error conditions encountered when invoking a hist trigger
211ea272257SMauro Carvalho Chehab  command, extended error information is available via the
21226a94491STom Zanussi  tracing/error_log file.  See Error Conditions in
21326a94491STom Zanussi  :file:`Documentation/trace/ftrace.rst` for details.
214ea272257SMauro Carvalho Chehab
215ea272257SMauro Carvalho Chehab6.2 'hist' trigger examples
216ea272257SMauro Carvalho Chehab---------------------------
217ea272257SMauro Carvalho Chehab
218ea272257SMauro Carvalho Chehab  The first set of examples creates aggregations using the kmalloc
219ea272257SMauro Carvalho Chehab  event.  The fields that can be used for the hist trigger are listed
220ea272257SMauro Carvalho Chehab  in the kmalloc event's format file::
221ea272257SMauro Carvalho Chehab
2222abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/kmem/kmalloc/format
223ea272257SMauro Carvalho Chehab    name: kmalloc
224ea272257SMauro Carvalho Chehab    ID: 374
225ea272257SMauro Carvalho Chehab    format:
226ea272257SMauro Carvalho Chehab	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
227ea272257SMauro Carvalho Chehab	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
228ea272257SMauro Carvalho Chehab	field:unsigned char common_preempt_count;		offset:3;	size:1;	signed:0;
229ea272257SMauro Carvalho Chehab	field:int common_pid;					offset:4;	size:4;	signed:1;
230ea272257SMauro Carvalho Chehab
231ea272257SMauro Carvalho Chehab	field:unsigned long call_site;				offset:8;	size:8;	signed:0;
232ea272257SMauro Carvalho Chehab	field:const void * ptr;					offset:16;	size:8;	signed:0;
233ea272257SMauro Carvalho Chehab	field:size_t bytes_req;					offset:24;	size:8;	signed:0;
234ea272257SMauro Carvalho Chehab	field:size_t bytes_alloc;				offset:32;	size:8;	signed:0;
235ea272257SMauro Carvalho Chehab	field:gfp_t gfp_flags;					offset:40;	size:4;	signed:0;
236ea272257SMauro Carvalho Chehab
237ea272257SMauro Carvalho Chehab  We'll start by creating a hist trigger that generates a simple table
238ea272257SMauro Carvalho Chehab  that lists the total number of bytes requested for each function in
239ea272257SMauro Carvalho Chehab  the kernel that made one or more calls to kmalloc::
240ea272257SMauro Carvalho Chehab
24137036435SSteven Rostedt (VMware)    # echo 'hist:key=call_site:val=bytes_req.buckets=32' > \
2422abfcd29SRoss Zwisler            /sys/kernel/tracing/events/kmem/kmalloc/trigger
243ea272257SMauro Carvalho Chehab
244ea272257SMauro Carvalho Chehab  This tells the tracing system to create a 'hist' trigger using the
245ea272257SMauro Carvalho Chehab  call_site field of the kmalloc event as the key for the table, which
246ea272257SMauro Carvalho Chehab  just means that each unique call_site address will have an entry
247ea272257SMauro Carvalho Chehab  created for it in the table.  The 'val=bytes_req' parameter tells
248ea272257SMauro Carvalho Chehab  the hist trigger that for each unique entry (call_site) in the
249ea272257SMauro Carvalho Chehab  table, it should keep a running total of the number of bytes
250ea272257SMauro Carvalho Chehab  requested by that call_site.
251ea272257SMauro Carvalho Chehab
252ea272257SMauro Carvalho Chehab  We'll let it run for awhile and then dump the contents of the 'hist'
253ea272257SMauro Carvalho Chehab  file in the kmalloc event's subdirectory (for readability, a number
254ea272257SMauro Carvalho Chehab  of entries have been omitted)::
255ea272257SMauro Carvalho Chehab
2562abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/kmem/kmalloc/hist
257ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=call_site:vals=bytes_req:sort=hitcount:size=2048 [active]
258ea272257SMauro Carvalho Chehab
259ea272257SMauro Carvalho Chehab    { call_site: 18446744072106379007 } hitcount:          1  bytes_req:        176
260ea272257SMauro Carvalho Chehab    { call_site: 18446744071579557049 } hitcount:          1  bytes_req:       1024
261ea272257SMauro Carvalho Chehab    { call_site: 18446744071580608289 } hitcount:          1  bytes_req:      16384
262ea272257SMauro Carvalho Chehab    { call_site: 18446744071581827654 } hitcount:          1  bytes_req:         24
263ea272257SMauro Carvalho Chehab    { call_site: 18446744071580700980 } hitcount:          1  bytes_req:          8
264ea272257SMauro Carvalho Chehab    { call_site: 18446744071579359876 } hitcount:          1  bytes_req:        152
265ea272257SMauro Carvalho Chehab    { call_site: 18446744071580795365 } hitcount:          3  bytes_req:        144
266ea272257SMauro Carvalho Chehab    { call_site: 18446744071581303129 } hitcount:          3  bytes_req:        144
267ea272257SMauro Carvalho Chehab    { call_site: 18446744071580713234 } hitcount:          4  bytes_req:       2560
268ea272257SMauro Carvalho Chehab    { call_site: 18446744071580933750 } hitcount:          4  bytes_req:        736
269ea272257SMauro Carvalho Chehab    .
270ea272257SMauro Carvalho Chehab    .
271ea272257SMauro Carvalho Chehab    .
272ea272257SMauro Carvalho Chehab    { call_site: 18446744072106047046 } hitcount:         69  bytes_req:       5576
273ea272257SMauro Carvalho Chehab    { call_site: 18446744071582116407 } hitcount:         73  bytes_req:       2336
274ea272257SMauro Carvalho Chehab    { call_site: 18446744072106054684 } hitcount:        136  bytes_req:     140504
275ea272257SMauro Carvalho Chehab    { call_site: 18446744072106224230 } hitcount:        136  bytes_req:      19584
276ea272257SMauro Carvalho Chehab    { call_site: 18446744072106078074 } hitcount:        153  bytes_req:       2448
277ea272257SMauro Carvalho Chehab    { call_site: 18446744072106062406 } hitcount:        153  bytes_req:      36720
278ea272257SMauro Carvalho Chehab    { call_site: 18446744071582507929 } hitcount:        153  bytes_req:      37088
279ea272257SMauro Carvalho Chehab    { call_site: 18446744072102520590 } hitcount:        273  bytes_req:      10920
280ea272257SMauro Carvalho Chehab    { call_site: 18446744071582143559 } hitcount:        358  bytes_req:        716
281ea272257SMauro Carvalho Chehab    { call_site: 18446744072106465852 } hitcount:        417  bytes_req:      56712
282ea272257SMauro Carvalho Chehab    { call_site: 18446744072102523378 } hitcount:        485  bytes_req:      27160
283ea272257SMauro Carvalho Chehab    { call_site: 18446744072099568646 } hitcount:       1676  bytes_req:      33520
284ea272257SMauro Carvalho Chehab
285ea272257SMauro Carvalho Chehab    Totals:
286ea272257SMauro Carvalho Chehab        Hits: 4610
287ea272257SMauro Carvalho Chehab        Entries: 45
288ea272257SMauro Carvalho Chehab        Dropped: 0
289ea272257SMauro Carvalho Chehab
290ea272257SMauro Carvalho Chehab  The output displays a line for each entry, beginning with the key
291ea272257SMauro Carvalho Chehab  specified in the trigger, followed by the value(s) also specified in
292ea272257SMauro Carvalho Chehab  the trigger.  At the beginning of the output is a line that displays
293ea272257SMauro Carvalho Chehab  the trigger info, which can also be displayed by reading the
294ea272257SMauro Carvalho Chehab  'trigger' file::
295ea272257SMauro Carvalho Chehab
2962abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/kmem/kmalloc/trigger
297ea272257SMauro Carvalho Chehab    hist:keys=call_site:vals=bytes_req:sort=hitcount:size=2048 [active]
298ea272257SMauro Carvalho Chehab
299ea272257SMauro Carvalho Chehab  At the end of the output are a few lines that display the overall
300ea272257SMauro Carvalho Chehab  totals for the run.  The 'Hits' field shows the total number of
301ea272257SMauro Carvalho Chehab  times the event trigger was hit, the 'Entries' field shows the total
302ea272257SMauro Carvalho Chehab  number of used entries in the hash table, and the 'Dropped' field
303ea272257SMauro Carvalho Chehab  shows the number of hits that were dropped because the number of
304ea272257SMauro Carvalho Chehab  used entries for the run exceeded the maximum number of entries
305ea272257SMauro Carvalho Chehab  allowed for the table (normally 0, but if not a hint that you may
306ea272257SMauro Carvalho Chehab  want to increase the size of the table using the 'size' parameter).
307ea272257SMauro Carvalho Chehab
308ea272257SMauro Carvalho Chehab  Notice in the above output that there's an extra field, 'hitcount',
309ea272257SMauro Carvalho Chehab  which wasn't specified in the trigger.  Also notice that in the
310ea272257SMauro Carvalho Chehab  trigger info output, there's a parameter, 'sort=hitcount', which
311ea272257SMauro Carvalho Chehab  wasn't specified in the trigger either.  The reason for that is that
312ea272257SMauro Carvalho Chehab  every trigger implicitly keeps a count of the total number of hits
313ea272257SMauro Carvalho Chehab  attributed to a given entry, called the 'hitcount'.  That hitcount
314ea272257SMauro Carvalho Chehab  information is explicitly displayed in the output, and in the
315ea272257SMauro Carvalho Chehab  absence of a user-specified sort parameter, is used as the default
316ea272257SMauro Carvalho Chehab  sort field.
317ea272257SMauro Carvalho Chehab
318ea272257SMauro Carvalho Chehab  The value 'hitcount' can be used in place of an explicit value in
319ea272257SMauro Carvalho Chehab  the 'values' parameter if you don't really need to have any
320ea272257SMauro Carvalho Chehab  particular field summed and are mainly interested in hit
321ea272257SMauro Carvalho Chehab  frequencies.
322ea272257SMauro Carvalho Chehab
323ea272257SMauro Carvalho Chehab  To turn the hist trigger off, simply call up the trigger in the
324ea272257SMauro Carvalho Chehab  command history and re-execute it with a '!' prepended::
325ea272257SMauro Carvalho Chehab
326ea272257SMauro Carvalho Chehab    # echo '!hist:key=call_site:val=bytes_req' > \
3272abfcd29SRoss Zwisler           /sys/kernel/tracing/events/kmem/kmalloc/trigger
328ea272257SMauro Carvalho Chehab
329ea272257SMauro Carvalho Chehab  Finally, notice that the call_site as displayed in the output above
330ea272257SMauro Carvalho Chehab  isn't really very useful.  It's an address, but normally addresses
331ea272257SMauro Carvalho Chehab  are displayed in hex.  To have a numeric field displayed as a hex
332ea272257SMauro Carvalho Chehab  value, simply append '.hex' to the field name in the trigger::
333ea272257SMauro Carvalho Chehab
334ea272257SMauro Carvalho Chehab    # echo 'hist:key=call_site.hex:val=bytes_req' > \
3352abfcd29SRoss Zwisler           /sys/kernel/tracing/events/kmem/kmalloc/trigger
336ea272257SMauro Carvalho Chehab
3372abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/kmem/kmalloc/hist
338ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=call_site.hex:vals=bytes_req:sort=hitcount:size=2048 [active]
339ea272257SMauro Carvalho Chehab
340ea272257SMauro Carvalho Chehab    { call_site: ffffffffa026b291 } hitcount:          1  bytes_req:        433
341ea272257SMauro Carvalho Chehab    { call_site: ffffffffa07186ff } hitcount:          1  bytes_req:        176
342ea272257SMauro Carvalho Chehab    { call_site: ffffffff811ae721 } hitcount:          1  bytes_req:      16384
343ea272257SMauro Carvalho Chehab    { call_site: ffffffff811c5134 } hitcount:          1  bytes_req:          8
344ea272257SMauro Carvalho Chehab    { call_site: ffffffffa04a9ebb } hitcount:          1  bytes_req:        511
345ea272257SMauro Carvalho Chehab    { call_site: ffffffff8122e0a6 } hitcount:          1  bytes_req:         12
346ea272257SMauro Carvalho Chehab    { call_site: ffffffff8107da84 } hitcount:          1  bytes_req:        152
347ea272257SMauro Carvalho Chehab    { call_site: ffffffff812d8246 } hitcount:          1  bytes_req:         24
348ea272257SMauro Carvalho Chehab    { call_site: ffffffff811dc1e5 } hitcount:          3  bytes_req:        144
349ea272257SMauro Carvalho Chehab    { call_site: ffffffffa02515e8 } hitcount:          3  bytes_req:        648
350ea272257SMauro Carvalho Chehab    { call_site: ffffffff81258159 } hitcount:          3  bytes_req:        144
351ea272257SMauro Carvalho Chehab    { call_site: ffffffff811c80f4 } hitcount:          4  bytes_req:        544
352ea272257SMauro Carvalho Chehab    .
353ea272257SMauro Carvalho Chehab    .
354ea272257SMauro Carvalho Chehab    .
355ea272257SMauro Carvalho Chehab    { call_site: ffffffffa06c7646 } hitcount:        106  bytes_req:       8024
356ea272257SMauro Carvalho Chehab    { call_site: ffffffffa06cb246 } hitcount:        132  bytes_req:      31680
357ea272257SMauro Carvalho Chehab    { call_site: ffffffffa06cef7a } hitcount:        132  bytes_req:       2112
358ea272257SMauro Carvalho Chehab    { call_site: ffffffff8137e399 } hitcount:        132  bytes_req:      23232
359ea272257SMauro Carvalho Chehab    { call_site: ffffffffa06c941c } hitcount:        185  bytes_req:     171360
360ea272257SMauro Carvalho Chehab    { call_site: ffffffffa06f2a66 } hitcount:        185  bytes_req:      26640
361ea272257SMauro Carvalho Chehab    { call_site: ffffffffa036a70e } hitcount:        265  bytes_req:      10600
362ea272257SMauro Carvalho Chehab    { call_site: ffffffff81325447 } hitcount:        292  bytes_req:        584
363ea272257SMauro Carvalho Chehab    { call_site: ffffffffa072da3c } hitcount:        446  bytes_req:      60656
364ea272257SMauro Carvalho Chehab    { call_site: ffffffffa036b1f2 } hitcount:        526  bytes_req:      29456
365ea272257SMauro Carvalho Chehab    { call_site: ffffffffa0099c06 } hitcount:       1780  bytes_req:      35600
366ea272257SMauro Carvalho Chehab
367ea272257SMauro Carvalho Chehab    Totals:
368ea272257SMauro Carvalho Chehab        Hits: 4775
369ea272257SMauro Carvalho Chehab        Entries: 46
370ea272257SMauro Carvalho Chehab        Dropped: 0
371ea272257SMauro Carvalho Chehab
372ea272257SMauro Carvalho Chehab  Even that's only marginally more useful - while hex values do look
373ea272257SMauro Carvalho Chehab  more like addresses, what users are typically more interested in
374ea272257SMauro Carvalho Chehab  when looking at text addresses are the corresponding symbols
375ea272257SMauro Carvalho Chehab  instead.  To have an address displayed as symbolic value instead,
376ea272257SMauro Carvalho Chehab  simply append '.sym' or '.sym-offset' to the field name in the
377ea272257SMauro Carvalho Chehab  trigger::
378ea272257SMauro Carvalho Chehab
379ea272257SMauro Carvalho Chehab    # echo 'hist:key=call_site.sym:val=bytes_req' > \
3802abfcd29SRoss Zwisler           /sys/kernel/tracing/events/kmem/kmalloc/trigger
381ea272257SMauro Carvalho Chehab
3822abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/kmem/kmalloc/hist
383ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=call_site.sym:vals=bytes_req:sort=hitcount:size=2048 [active]
384ea272257SMauro Carvalho Chehab
385ea272257SMauro Carvalho Chehab    { call_site: [ffffffff810adcb9] syslog_print_all                              } hitcount:          1  bytes_req:       1024
386ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8154bc62] usb_control_msg                               } hitcount:          1  bytes_req:          8
387ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf6fe] hidraw_send_report [hid]                      } hitcount:          1  bytes_req:          7
388ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8154acbe] usb_alloc_urb                                 } hitcount:          1  bytes_req:        192
389ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf1ca] hidraw_report_event [hid]                     } hitcount:          1  bytes_req:          7
390ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811e3a25] __seq_open_private                            } hitcount:          1  bytes_req:         40
391ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8109524a] alloc_fair_sched_group                        } hitcount:          2  bytes_req:        128
392ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811febd5] fsnotify_alloc_group                          } hitcount:          2  bytes_req:        528
393ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81440f58] __tty_buffer_request_room                     } hitcount:          2  bytes_req:       2624
394ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81200ba6] inotify_new_group                             } hitcount:          2  bytes_req:         96
395ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa05e19af] ieee80211_start_tx_ba_session [mac80211]      } hitcount:          2  bytes_req:        464
396ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81672406] tcp_get_metrics                               } hitcount:          2  bytes_req:        304
397ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81097ec2] alloc_rt_sched_group                          } hitcount:          2  bytes_req:        128
398ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81089b05] sched_create_group                            } hitcount:          2  bytes_req:       1424
399ea272257SMauro Carvalho Chehab    .
400ea272257SMauro Carvalho Chehab    .
401ea272257SMauro Carvalho Chehab    .
402ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04a580c] intel_crtc_page_flip [i915]                   } hitcount:       1185  bytes_req:     123240
403ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0287592] drm_mode_page_flip_ioctl [drm]                } hitcount:       1185  bytes_req:     104280
404ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state [i915]            } hitcount:       1402  bytes_req:     190672
405ea272257SMauro Carvalho Chehab    { call_site: [ffffffff812891ca] ext4_find_extent                              } hitcount:       1518  bytes_req:     146208
406ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa029070e] drm_vma_node_allow [drm]                      } hitcount:       1746  bytes_req:      69840
407ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23 [i915]         } hitcount:       2021  bytes_req:     792312
408ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc [drm]                   } hitcount:       2592  bytes_req:     145152
409ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0489a66] intel_ring_begin [i915]                       } hitcount:       2629  bytes_req:     378576
410ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa046041c] i915_gem_execbuffer2 [i915]                   } hitcount:       2629  bytes_req:    3783248
411ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81325607] apparmor_file_alloc_security                  } hitcount:       5192  bytes_req:      10384
412ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00b7c06] hid_report_raw_event [hid]                    } hitcount:       5529  bytes_req:     110584
413ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8131ebf7] aa_alloc_task_context                         } hitcount:      21943  bytes_req:     702176
414ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8125847d] ext4_htree_store_dirent                       } hitcount:      55759  bytes_req:    5074265
415ea272257SMauro Carvalho Chehab
416ea272257SMauro Carvalho Chehab    Totals:
417ea272257SMauro Carvalho Chehab        Hits: 109928
418ea272257SMauro Carvalho Chehab        Entries: 71
419ea272257SMauro Carvalho Chehab        Dropped: 0
420ea272257SMauro Carvalho Chehab
421ea272257SMauro Carvalho Chehab  Because the default sort key above is 'hitcount', the above shows a
422ea272257SMauro Carvalho Chehab  the list of call_sites by increasing hitcount, so that at the bottom
423ea272257SMauro Carvalho Chehab  we see the functions that made the most kmalloc calls during the
4247f77ebbfSAkhil Raj  run.  If instead we wanted to see the top kmalloc callers in
425ea272257SMauro Carvalho Chehab  terms of the number of bytes requested rather than the number of
426ea272257SMauro Carvalho Chehab  calls, and we wanted the top caller to appear at the top, we can use
427ea272257SMauro Carvalho Chehab  the 'sort' parameter, along with the 'descending' modifier::
428ea272257SMauro Carvalho Chehab
429ea272257SMauro Carvalho Chehab    # echo 'hist:key=call_site.sym:val=bytes_req:sort=bytes_req.descending' > \
4302abfcd29SRoss Zwisler           /sys/kernel/tracing/events/kmem/kmalloc/trigger
431ea272257SMauro Carvalho Chehab
4322abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/kmem/kmalloc/hist
433ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=call_site.sym:vals=bytes_req:sort=bytes_req.descending:size=2048 [active]
434ea272257SMauro Carvalho Chehab
435ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa046041c] i915_gem_execbuffer2 [i915]                   } hitcount:       2186  bytes_req:    3397464
436ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23 [i915]         } hitcount:       1790  bytes_req:     712176
437ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8125847d] ext4_htree_store_dirent                       } hitcount:       8132  bytes_req:     513135
438ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811e2a1b] seq_buf_alloc                                 } hitcount:        106  bytes_req:     440128
439ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0489a66] intel_ring_begin [i915]                       } hitcount:       2186  bytes_req:     314784
440ea272257SMauro Carvalho Chehab    { call_site: [ffffffff812891ca] ext4_find_extent                              } hitcount:       2174  bytes_req:     208992
441ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811ae8e1] __kmalloc                                     } hitcount:          8  bytes_req:     131072
442ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state [i915]            } hitcount:        859  bytes_req:     116824
443ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc [drm]                   } hitcount:       1834  bytes_req:     102704
444ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04a580c] intel_crtc_page_flip [i915]                   } hitcount:        972  bytes_req:     101088
445ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0287592] drm_mode_page_flip_ioctl [drm]                } hitcount:        972  bytes_req:      85536
446ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00b7c06] hid_report_raw_event [hid]                    } hitcount:       3333  bytes_req:      66664
447ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8137e559] sg_kmalloc                                    } hitcount:        209  bytes_req:      61632
448ea272257SMauro Carvalho Chehab    .
449ea272257SMauro Carvalho Chehab    .
450ea272257SMauro Carvalho Chehab    .
451ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81095225] alloc_fair_sched_group                        } hitcount:          2  bytes_req:        128
452ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81097ec2] alloc_rt_sched_group                          } hitcount:          2  bytes_req:        128
453ea272257SMauro Carvalho Chehab    { call_site: [ffffffff812d8406] copy_semundo                                  } hitcount:          2  bytes_req:         48
454ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81200ba6] inotify_new_group                             } hitcount:          1  bytes_req:         48
455ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa027121a] drm_getmagic [drm]                            } hitcount:          1  bytes_req:         48
456ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811e3a25] __seq_open_private                            } hitcount:          1  bytes_req:         40
457ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811c52f4] bprm_change_interp                            } hitcount:          2  bytes_req:         16
458ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8154bc62] usb_control_msg                               } hitcount:          1  bytes_req:          8
459ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf1ca] hidraw_report_event [hid]                     } hitcount:          1  bytes_req:          7
460ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf6fe] hidraw_send_report [hid]                      } hitcount:          1  bytes_req:          7
461ea272257SMauro Carvalho Chehab
462ea272257SMauro Carvalho Chehab    Totals:
463ea272257SMauro Carvalho Chehab        Hits: 32133
464ea272257SMauro Carvalho Chehab        Entries: 81
465ea272257SMauro Carvalho Chehab        Dropped: 0
466ea272257SMauro Carvalho Chehab
467ea272257SMauro Carvalho Chehab  To display the offset and size information in addition to the symbol
468ea272257SMauro Carvalho Chehab  name, just use 'sym-offset' instead::
469ea272257SMauro Carvalho Chehab
470ea272257SMauro Carvalho Chehab    # echo 'hist:key=call_site.sym-offset:val=bytes_req:sort=bytes_req.descending' > \
4712abfcd29SRoss Zwisler           /sys/kernel/tracing/events/kmem/kmalloc/trigger
472ea272257SMauro Carvalho Chehab
4732abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/kmem/kmalloc/hist
474ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=call_site.sym-offset:vals=bytes_req:sort=bytes_req.descending:size=2048 [active]
475ea272257SMauro Carvalho Chehab
476ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa046041c] i915_gem_execbuffer2+0x6c/0x2c0 [i915]                  } hitcount:       4569  bytes_req:    3163720
477ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0489a66] intel_ring_begin+0xc6/0x1f0 [i915]                      } hitcount:       4569  bytes_req:     657936
478ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23+0x694/0x1020 [i915]      } hitcount:       1519  bytes_req:     472936
479ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa045e646] i915_gem_do_execbuffer.isra.23+0x516/0x1020 [i915]      } hitcount:       3050  bytes_req:     211832
480ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811e2a1b] seq_buf_alloc+0x1b/0x50                                 } hitcount:         34  bytes_req:     148384
481ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04a580c] intel_crtc_page_flip+0xbc/0x870 [i915]                  } hitcount:       1385  bytes_req:     144040
482ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811ae8e1] __kmalloc+0x191/0x1b0                                   } hitcount:          8  bytes_req:     131072
483ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0287592] drm_mode_page_flip_ioctl+0x282/0x360 [drm]              } hitcount:       1385  bytes_req:     121880
484ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc+0x32/0x100 [drm]                  } hitcount:       1848  bytes_req:     103488
485ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state+0x2c/0xa0 [i915]            } hitcount:        461  bytes_req:      62696
486ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa029070e] drm_vma_node_allow+0x2e/0xd0 [drm]                      } hitcount:       1541  bytes_req:      61640
487ea272257SMauro Carvalho Chehab    { call_site: [ffffffff815f8d7b] sk_prot_alloc+0xcb/0x1b0                                } hitcount:         57  bytes_req:      57456
488ea272257SMauro Carvalho Chehab    .
489ea272257SMauro Carvalho Chehab    .
490ea272257SMauro Carvalho Chehab    .
491ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8109524a] alloc_fair_sched_group+0x5a/0x1a0                       } hitcount:          2  bytes_req:        128
492ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa027b921] drm_vm_open_locked+0x31/0xa0 [drm]                      } hitcount:          3  bytes_req:         96
493ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8122e266] proc_self_follow_link+0x76/0xb0                         } hitcount:          8  bytes_req:         96
494ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81213e80] load_elf_binary+0x240/0x1650                            } hitcount:          3  bytes_req:         84
495ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8154bc62] usb_control_msg+0x42/0x110                              } hitcount:          1  bytes_req:          8
496ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf6fe] hidraw_send_report+0x7e/0x1a0 [hid]                     } hitcount:          1  bytes_req:          7
497ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf1ca] hidraw_report_event+0x8a/0x120 [hid]                    } hitcount:          1  bytes_req:          7
498ea272257SMauro Carvalho Chehab
499ea272257SMauro Carvalho Chehab    Totals:
500ea272257SMauro Carvalho Chehab        Hits: 26098
501ea272257SMauro Carvalho Chehab        Entries: 64
502ea272257SMauro Carvalho Chehab        Dropped: 0
503ea272257SMauro Carvalho Chehab
504ea272257SMauro Carvalho Chehab  We can also add multiple fields to the 'values' parameter.  For
505ea272257SMauro Carvalho Chehab  example, we might want to see the total number of bytes allocated
506ea272257SMauro Carvalho Chehab  alongside bytes requested, and display the result sorted by bytes
507ea272257SMauro Carvalho Chehab  allocated in a descending order::
508ea272257SMauro Carvalho Chehab
509ea272257SMauro Carvalho Chehab    # echo 'hist:keys=call_site.sym:values=bytes_req,bytes_alloc:sort=bytes_alloc.descending' > \
5102abfcd29SRoss Zwisler           /sys/kernel/tracing/events/kmem/kmalloc/trigger
511ea272257SMauro Carvalho Chehab
5122abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/kmem/kmalloc/hist
513ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=call_site.sym:vals=bytes_req,bytes_alloc:sort=bytes_alloc.descending:size=2048 [active]
514ea272257SMauro Carvalho Chehab
515ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa046041c] i915_gem_execbuffer2 [i915]                   } hitcount:       7403  bytes_req:    4084360  bytes_alloc:    5958016
516ea272257SMauro Carvalho Chehab    { call_site: [ffffffff811e2a1b] seq_buf_alloc                                 } hitcount:        541  bytes_req:    2213968  bytes_alloc:    2228224
517ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa0489a66] intel_ring_begin [i915]                       } hitcount:       7404  bytes_req:    1066176  bytes_alloc:    1421568
518ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23 [i915]         } hitcount:       1565  bytes_req:     557368  bytes_alloc:    1037760
519ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8125847d] ext4_htree_store_dirent                       } hitcount:       9557  bytes_req:     595778  bytes_alloc:     695744
520ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa045e646] i915_gem_do_execbuffer.isra.23 [i915]         } hitcount:       5839  bytes_req:     430680  bytes_alloc:     470400
521ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state [i915]            } hitcount:       2388  bytes_req:     324768  bytes_alloc:     458496
522ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc [drm]                   } hitcount:       3911  bytes_req:     219016  bytes_alloc:     250304
523ea272257SMauro Carvalho Chehab    { call_site: [ffffffff815f8d7b] sk_prot_alloc                                 } hitcount:        235  bytes_req:     236880  bytes_alloc:     240640
524ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8137e559] sg_kmalloc                                    } hitcount:        557  bytes_req:     169024  bytes_alloc:     221760
525ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00b7c06] hid_report_raw_event [hid]                    } hitcount:       9378  bytes_req:     187548  bytes_alloc:     206312
526ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa04a580c] intel_crtc_page_flip [i915]                   } hitcount:       1519  bytes_req:     157976  bytes_alloc:     194432
527ea272257SMauro Carvalho Chehab    .
528ea272257SMauro Carvalho Chehab    .
529ea272257SMauro Carvalho Chehab    .
530ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8109bd3b] sched_autogroup_create_attach                 } hitcount:          2  bytes_req:        144  bytes_alloc:        192
531ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81097ee8] alloc_rt_sched_group                          } hitcount:          2  bytes_req:        128  bytes_alloc:        128
532ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8109524a] alloc_fair_sched_group                        } hitcount:          2  bytes_req:        128  bytes_alloc:        128
533ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81095225] alloc_fair_sched_group                        } hitcount:          2  bytes_req:        128  bytes_alloc:        128
534ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81097ec2] alloc_rt_sched_group                          } hitcount:          2  bytes_req:        128  bytes_alloc:        128
535ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81213e80] load_elf_binary                               } hitcount:          3  bytes_req:         84  bytes_alloc:         96
536ea272257SMauro Carvalho Chehab    { call_site: [ffffffff81079a2e] kthread_create_on_node                        } hitcount:          1  bytes_req:         56  bytes_alloc:         64
537ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf6fe] hidraw_send_report [hid]                      } hitcount:          1  bytes_req:          7  bytes_alloc:          8
538ea272257SMauro Carvalho Chehab    { call_site: [ffffffff8154bc62] usb_control_msg                               } hitcount:          1  bytes_req:          8  bytes_alloc:          8
539ea272257SMauro Carvalho Chehab    { call_site: [ffffffffa00bf1ca] hidraw_report_event [hid]                     } hitcount:          1  bytes_req:          7  bytes_alloc:          8
540ea272257SMauro Carvalho Chehab
541ea272257SMauro Carvalho Chehab    Totals:
542ea272257SMauro Carvalho Chehab        Hits: 66598
543ea272257SMauro Carvalho Chehab        Entries: 65
544ea272257SMauro Carvalho Chehab        Dropped: 0
545ea272257SMauro Carvalho Chehab
546ea272257SMauro Carvalho Chehab  Finally, to finish off our kmalloc example, instead of simply having
547ea272257SMauro Carvalho Chehab  the hist trigger display symbolic call_sites, we can have the hist
548ea272257SMauro Carvalho Chehab  trigger additionally display the complete set of kernel stack traces
549ea272257SMauro Carvalho Chehab  that led to each call_site.  To do that, we simply use the special
550*4b512860SSteven Rostedt (Google)  value 'common_stacktrace' for the key parameter::
551ea272257SMauro Carvalho Chehab
552*4b512860SSteven Rostedt (Google)    # echo 'hist:keys=common_stacktrace:values=bytes_req,bytes_alloc:sort=bytes_alloc' > \
5532abfcd29SRoss Zwisler           /sys/kernel/tracing/events/kmem/kmalloc/trigger
554ea272257SMauro Carvalho Chehab
555ea272257SMauro Carvalho Chehab  The above trigger will use the kernel stack trace in effect when an
556ea272257SMauro Carvalho Chehab  event is triggered as the key for the hash table.  This allows the
557ea272257SMauro Carvalho Chehab  enumeration of every kernel callpath that led up to a particular
558ea272257SMauro Carvalho Chehab  event, along with a running total of any of the event fields for
559ea272257SMauro Carvalho Chehab  that event.  Here we tally bytes requested and bytes allocated for
560ea272257SMauro Carvalho Chehab  every callpath in the system that led up to a kmalloc (in this case
561ea272257SMauro Carvalho Chehab  every callpath to a kmalloc for a kernel compile)::
562ea272257SMauro Carvalho Chehab
5632abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/kmem/kmalloc/hist
564*4b512860SSteven Rostedt (Google)    # trigger info: hist:keys=common_stacktrace:vals=bytes_req,bytes_alloc:sort=bytes_alloc:size=2048 [active]
565ea272257SMauro Carvalho Chehab
566*4b512860SSteven Rostedt (Google)    { common_stacktrace:
567ea272257SMauro Carvalho Chehab         __kmalloc_track_caller+0x10b/0x1a0
568ea272257SMauro Carvalho Chehab         kmemdup+0x20/0x50
569ea272257SMauro Carvalho Chehab         hidraw_report_event+0x8a/0x120 [hid]
570ea272257SMauro Carvalho Chehab         hid_report_raw_event+0x3ea/0x440 [hid]
571ea272257SMauro Carvalho Chehab         hid_input_report+0x112/0x190 [hid]
572ea272257SMauro Carvalho Chehab         hid_irq_in+0xc2/0x260 [usbhid]
573ea272257SMauro Carvalho Chehab         __usb_hcd_giveback_urb+0x72/0x120
574ea272257SMauro Carvalho Chehab         usb_giveback_urb_bh+0x9e/0xe0
575ea272257SMauro Carvalho Chehab         tasklet_hi_action+0xf8/0x100
576ea272257SMauro Carvalho Chehab         __do_softirq+0x114/0x2c0
577ea272257SMauro Carvalho Chehab         irq_exit+0xa5/0xb0
578ea272257SMauro Carvalho Chehab         do_IRQ+0x5a/0xf0
579ea272257SMauro Carvalho Chehab         ret_from_intr+0x0/0x30
580ea272257SMauro Carvalho Chehab         cpuidle_enter+0x17/0x20
581ea272257SMauro Carvalho Chehab         cpu_startup_entry+0x315/0x3e0
582ea272257SMauro Carvalho Chehab         rest_init+0x7c/0x80
583ea272257SMauro Carvalho Chehab    } hitcount:          3  bytes_req:         21  bytes_alloc:         24
584*4b512860SSteven Rostedt (Google)    { common_stacktrace:
585ea272257SMauro Carvalho Chehab         __kmalloc_track_caller+0x10b/0x1a0
586ea272257SMauro Carvalho Chehab         kmemdup+0x20/0x50
587ea272257SMauro Carvalho Chehab         hidraw_report_event+0x8a/0x120 [hid]
588ea272257SMauro Carvalho Chehab         hid_report_raw_event+0x3ea/0x440 [hid]
589ea272257SMauro Carvalho Chehab         hid_input_report+0x112/0x190 [hid]
590ea272257SMauro Carvalho Chehab         hid_irq_in+0xc2/0x260 [usbhid]
591ea272257SMauro Carvalho Chehab         __usb_hcd_giveback_urb+0x72/0x120
592ea272257SMauro Carvalho Chehab         usb_giveback_urb_bh+0x9e/0xe0
593ea272257SMauro Carvalho Chehab         tasklet_hi_action+0xf8/0x100
594ea272257SMauro Carvalho Chehab         __do_softirq+0x114/0x2c0
595ea272257SMauro Carvalho Chehab         irq_exit+0xa5/0xb0
596ea272257SMauro Carvalho Chehab         do_IRQ+0x5a/0xf0
597ea272257SMauro Carvalho Chehab         ret_from_intr+0x0/0x30
598ea272257SMauro Carvalho Chehab    } hitcount:          3  bytes_req:         21  bytes_alloc:         24
599*4b512860SSteven Rostedt (Google)    { common_stacktrace:
600ea272257SMauro Carvalho Chehab         kmem_cache_alloc_trace+0xeb/0x150
601ea272257SMauro Carvalho Chehab         aa_alloc_task_context+0x27/0x40
602ea272257SMauro Carvalho Chehab         apparmor_cred_prepare+0x1f/0x50
603ea272257SMauro Carvalho Chehab         security_prepare_creds+0x16/0x20
604ea272257SMauro Carvalho Chehab         prepare_creds+0xdf/0x1a0
605ea272257SMauro Carvalho Chehab         SyS_capset+0xb5/0x200
606ea272257SMauro Carvalho Chehab         system_call_fastpath+0x12/0x6a
607ea272257SMauro Carvalho Chehab    } hitcount:          1  bytes_req:         32  bytes_alloc:         32
608ea272257SMauro Carvalho Chehab    .
609ea272257SMauro Carvalho Chehab    .
610ea272257SMauro Carvalho Chehab    .
611*4b512860SSteven Rostedt (Google)    { common_stacktrace:
612ea272257SMauro Carvalho Chehab         __kmalloc+0x11b/0x1b0
613ea272257SMauro Carvalho Chehab         i915_gem_execbuffer2+0x6c/0x2c0 [i915]
614ea272257SMauro Carvalho Chehab         drm_ioctl+0x349/0x670 [drm]
615ea272257SMauro Carvalho Chehab         do_vfs_ioctl+0x2f0/0x4f0
616ea272257SMauro Carvalho Chehab         SyS_ioctl+0x81/0xa0
617ea272257SMauro Carvalho Chehab         system_call_fastpath+0x12/0x6a
618ea272257SMauro Carvalho Chehab    } hitcount:      17726  bytes_req:   13944120  bytes_alloc:   19593808
619*4b512860SSteven Rostedt (Google)    { common_stacktrace:
620ea272257SMauro Carvalho Chehab         __kmalloc+0x11b/0x1b0
621ea272257SMauro Carvalho Chehab         load_elf_phdrs+0x76/0xa0
622ea272257SMauro Carvalho Chehab         load_elf_binary+0x102/0x1650
623ea272257SMauro Carvalho Chehab         search_binary_handler+0x97/0x1d0
624ea272257SMauro Carvalho Chehab         do_execveat_common.isra.34+0x551/0x6e0
625ea272257SMauro Carvalho Chehab         SyS_execve+0x3a/0x50
626ea272257SMauro Carvalho Chehab         return_from_execve+0x0/0x23
627ea272257SMauro Carvalho Chehab    } hitcount:      33348  bytes_req:   17152128  bytes_alloc:   20226048
628*4b512860SSteven Rostedt (Google)    { common_stacktrace:
629ea272257SMauro Carvalho Chehab         kmem_cache_alloc_trace+0xeb/0x150
630ea272257SMauro Carvalho Chehab         apparmor_file_alloc_security+0x27/0x40
631ea272257SMauro Carvalho Chehab         security_file_alloc+0x16/0x20
632ea272257SMauro Carvalho Chehab         get_empty_filp+0x93/0x1c0
633ea272257SMauro Carvalho Chehab         path_openat+0x31/0x5f0
634ea272257SMauro Carvalho Chehab         do_filp_open+0x3a/0x90
635ea272257SMauro Carvalho Chehab         do_sys_open+0x128/0x220
636ea272257SMauro Carvalho Chehab         SyS_open+0x1e/0x20
637ea272257SMauro Carvalho Chehab         system_call_fastpath+0x12/0x6a
638ea272257SMauro Carvalho Chehab    } hitcount:    4766422  bytes_req:    9532844  bytes_alloc:   38131376
639*4b512860SSteven Rostedt (Google)    { common_stacktrace:
640ea272257SMauro Carvalho Chehab         __kmalloc+0x11b/0x1b0
641ea272257SMauro Carvalho Chehab         seq_buf_alloc+0x1b/0x50
642ea272257SMauro Carvalho Chehab         seq_read+0x2cc/0x370
643ea272257SMauro Carvalho Chehab         proc_reg_read+0x3d/0x80
644ea272257SMauro Carvalho Chehab         __vfs_read+0x28/0xe0
645ea272257SMauro Carvalho Chehab         vfs_read+0x86/0x140
646ea272257SMauro Carvalho Chehab         SyS_read+0x46/0xb0
647ea272257SMauro Carvalho Chehab         system_call_fastpath+0x12/0x6a
648ea272257SMauro Carvalho Chehab    } hitcount:      19133  bytes_req:   78368768  bytes_alloc:   78368768
649ea272257SMauro Carvalho Chehab
650ea272257SMauro Carvalho Chehab    Totals:
651ea272257SMauro Carvalho Chehab        Hits: 6085872
652ea272257SMauro Carvalho Chehab        Entries: 253
653ea272257SMauro Carvalho Chehab        Dropped: 0
654ea272257SMauro Carvalho Chehab
655ea272257SMauro Carvalho Chehab  If you key a hist trigger on common_pid, in order for example to
656ea272257SMauro Carvalho Chehab  gather and display sorted totals for each process, you can use the
657ea272257SMauro Carvalho Chehab  special .execname modifier to display the executable names for the
658ea272257SMauro Carvalho Chehab  processes in the table rather than raw pids.  The example below
659ea272257SMauro Carvalho Chehab  keeps a per-process sum of total bytes read::
660ea272257SMauro Carvalho Chehab
661ea272257SMauro Carvalho Chehab    # echo 'hist:key=common_pid.execname:val=count:sort=count.descending' > \
6622abfcd29SRoss Zwisler           /sys/kernel/tracing/events/syscalls/sys_enter_read/trigger
663ea272257SMauro Carvalho Chehab
6642abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/syscalls/sys_enter_read/hist
665ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=common_pid.execname:vals=count:sort=count.descending:size=2048 [active]
666ea272257SMauro Carvalho Chehab
667ea272257SMauro Carvalho Chehab    { common_pid: gnome-terminal  [      3196] } hitcount:        280  count:    1093512
668ea272257SMauro Carvalho Chehab    { common_pid: Xorg            [      1309] } hitcount:        525  count:     256640
669ea272257SMauro Carvalho Chehab    { common_pid: compiz          [      2889] } hitcount:         59  count:     254400
670ea272257SMauro Carvalho Chehab    { common_pid: bash            [      8710] } hitcount:          3  count:      66369
671ea272257SMauro Carvalho Chehab    { common_pid: dbus-daemon-lau [      8703] } hitcount:         49  count:      47739
672ea272257SMauro Carvalho Chehab    { common_pid: irqbalance      [      1252] } hitcount:         27  count:      27648
673ea272257SMauro Carvalho Chehab    { common_pid: 01ifupdown      [      8705] } hitcount:          3  count:      17216
674ea272257SMauro Carvalho Chehab    { common_pid: dbus-daemon     [       772] } hitcount:         10  count:      12396
675ea272257SMauro Carvalho Chehab    { common_pid: Socket Thread   [      8342] } hitcount:         11  count:      11264
676ea272257SMauro Carvalho Chehab    { common_pid: nm-dhcp-client. [      8701] } hitcount:          6  count:       7424
677ea272257SMauro Carvalho Chehab    { common_pid: gmain           [      1315] } hitcount:         18  count:       6336
678ea272257SMauro Carvalho Chehab    .
679ea272257SMauro Carvalho Chehab    .
680ea272257SMauro Carvalho Chehab    .
681ea272257SMauro Carvalho Chehab    { common_pid: postgres        [      1892] } hitcount:          2  count:         32
682ea272257SMauro Carvalho Chehab    { common_pid: postgres        [      1891] } hitcount:          2  count:         32
683ea272257SMauro Carvalho Chehab    { common_pid: gmain           [      8704] } hitcount:          2  count:         32
684ea272257SMauro Carvalho Chehab    { common_pid: upstart-dbus-br [      2740] } hitcount:         21  count:         21
685ea272257SMauro Carvalho Chehab    { common_pid: nm-dispatcher.a [      8696] } hitcount:          1  count:         16
686ea272257SMauro Carvalho Chehab    { common_pid: indicator-datet [      2904] } hitcount:          1  count:         16
687ea272257SMauro Carvalho Chehab    { common_pid: gdbus           [      2998] } hitcount:          1  count:         16
688ea272257SMauro Carvalho Chehab    { common_pid: rtkit-daemon    [      2052] } hitcount:          1  count:          8
689ea272257SMauro Carvalho Chehab    { common_pid: init            [         1] } hitcount:          2  count:          2
690ea272257SMauro Carvalho Chehab
691ea272257SMauro Carvalho Chehab    Totals:
692ea272257SMauro Carvalho Chehab        Hits: 2116
693ea272257SMauro Carvalho Chehab        Entries: 51
694ea272257SMauro Carvalho Chehab        Dropped: 0
695ea272257SMauro Carvalho Chehab
696ea272257SMauro Carvalho Chehab  Similarly, if you key a hist trigger on syscall id, for example to
697ea272257SMauro Carvalho Chehab  gather and display a list of systemwide syscall hits, you can use
698ea272257SMauro Carvalho Chehab  the special .syscall modifier to display the syscall names rather
699ea272257SMauro Carvalho Chehab  than raw ids.  The example below keeps a running total of syscall
700ea272257SMauro Carvalho Chehab  counts for the system during the run::
701ea272257SMauro Carvalho Chehab
702ea272257SMauro Carvalho Chehab    # echo 'hist:key=id.syscall:val=hitcount' > \
7032abfcd29SRoss Zwisler           /sys/kernel/tracing/events/raw_syscalls/sys_enter/trigger
704ea272257SMauro Carvalho Chehab
7052abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/raw_syscalls/sys_enter/hist
706ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=id.syscall:vals=hitcount:sort=hitcount:size=2048 [active]
707ea272257SMauro Carvalho Chehab
708ea272257SMauro Carvalho Chehab    { id: sys_fsync                     [ 74] } hitcount:          1
709ea272257SMauro Carvalho Chehab    { id: sys_newuname                  [ 63] } hitcount:          1
710ea272257SMauro Carvalho Chehab    { id: sys_prctl                     [157] } hitcount:          1
711ea272257SMauro Carvalho Chehab    { id: sys_statfs                    [137] } hitcount:          1
712ea272257SMauro Carvalho Chehab    { id: sys_symlink                   [ 88] } hitcount:          1
713ea272257SMauro Carvalho Chehab    { id: sys_sendmmsg                  [307] } hitcount:          1
714ea272257SMauro Carvalho Chehab    { id: sys_semctl                    [ 66] } hitcount:          1
715ea272257SMauro Carvalho Chehab    { id: sys_readlink                  [ 89] } hitcount:          3
716ea272257SMauro Carvalho Chehab    { id: sys_bind                      [ 49] } hitcount:          3
717ea272257SMauro Carvalho Chehab    { id: sys_getsockname               [ 51] } hitcount:          3
718ea272257SMauro Carvalho Chehab    { id: sys_unlink                    [ 87] } hitcount:          3
719ea272257SMauro Carvalho Chehab    { id: sys_rename                    [ 82] } hitcount:          4
720ea272257SMauro Carvalho Chehab    { id: unknown_syscall               [ 58] } hitcount:          4
721ea272257SMauro Carvalho Chehab    { id: sys_connect                   [ 42] } hitcount:          4
722ea272257SMauro Carvalho Chehab    { id: sys_getpid                    [ 39] } hitcount:          4
723ea272257SMauro Carvalho Chehab    .
724ea272257SMauro Carvalho Chehab    .
725ea272257SMauro Carvalho Chehab    .
726ea272257SMauro Carvalho Chehab    { id: sys_rt_sigprocmask            [ 14] } hitcount:        952
727ea272257SMauro Carvalho Chehab    { id: sys_futex                     [202] } hitcount:       1534
728ea272257SMauro Carvalho Chehab    { id: sys_write                     [  1] } hitcount:       2689
729ea272257SMauro Carvalho Chehab    { id: sys_setitimer                 [ 38] } hitcount:       2797
730ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0] } hitcount:       3202
731ea272257SMauro Carvalho Chehab    { id: sys_select                    [ 23] } hitcount:       3773
732ea272257SMauro Carvalho Chehab    { id: sys_writev                    [ 20] } hitcount:       4531
733ea272257SMauro Carvalho Chehab    { id: sys_poll                      [  7] } hitcount:       8314
734ea272257SMauro Carvalho Chehab    { id: sys_recvmsg                   [ 47] } hitcount:      13738
735ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16] } hitcount:      21843
736ea272257SMauro Carvalho Chehab
737ea272257SMauro Carvalho Chehab    Totals:
738ea272257SMauro Carvalho Chehab        Hits: 67612
739ea272257SMauro Carvalho Chehab        Entries: 72
740ea272257SMauro Carvalho Chehab        Dropped: 0
741ea272257SMauro Carvalho Chehab
742ea272257SMauro Carvalho Chehab  The syscall counts above provide a rough overall picture of system
743ea272257SMauro Carvalho Chehab  call activity on the system; we can see for example that the most
744ea272257SMauro Carvalho Chehab  popular system call on this system was the 'sys_ioctl' system call.
745ea272257SMauro Carvalho Chehab
746ea272257SMauro Carvalho Chehab  We can use 'compound' keys to refine that number and provide some
747ea272257SMauro Carvalho Chehab  further insight as to which processes exactly contribute to the
748ea272257SMauro Carvalho Chehab  overall ioctl count.
749ea272257SMauro Carvalho Chehab
750ea272257SMauro Carvalho Chehab  The command below keeps a hitcount for every unique combination of
751ea272257SMauro Carvalho Chehab  system call id and pid - the end result is essentially a table
752ea272257SMauro Carvalho Chehab  that keeps a per-pid sum of system call hits.  The results are
753ea272257SMauro Carvalho Chehab  sorted using the system call id as the primary key, and the
754ea272257SMauro Carvalho Chehab  hitcount sum as the secondary key::
755ea272257SMauro Carvalho Chehab
756ea272257SMauro Carvalho Chehab    # echo 'hist:key=id.syscall,common_pid.execname:val=hitcount:sort=id,hitcount' > \
7572abfcd29SRoss Zwisler           /sys/kernel/tracing/events/raw_syscalls/sys_enter/trigger
758ea272257SMauro Carvalho Chehab
7592abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/raw_syscalls/sys_enter/hist
760ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=id.syscall,common_pid.execname:vals=hitcount:sort=id.syscall,hitcount:size=2048 [active]
761ea272257SMauro Carvalho Chehab
762ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: rtkit-daemon    [      1877] } hitcount:          1
763ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: gdbus           [      2976] } hitcount:          1
764ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: console-kit-dae [      3400] } hitcount:          1
765ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: postgres        [      1865] } hitcount:          1
766ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: deja-dup-monito [      3543] } hitcount:          2
767ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: NetworkManager  [       890] } hitcount:          2
768ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: evolution-calen [      3048] } hitcount:          2
769ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: postgres        [      1864] } hitcount:          2
770ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: nm-applet       [      3022] } hitcount:          2
771ea272257SMauro Carvalho Chehab    { id: sys_read                      [  0], common_pid: whoopsie        [      1212] } hitcount:          2
772ea272257SMauro Carvalho Chehab    .
773ea272257SMauro Carvalho Chehab    .
774ea272257SMauro Carvalho Chehab    .
775ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: bash            [      8479] } hitcount:          1
776ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: bash            [      3472] } hitcount:         12
777ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gnome-terminal  [      3199] } hitcount:         16
778ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: Xorg            [      1267] } hitcount:       1808
779ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: compiz          [      2994] } hitcount:       5580
780ea272257SMauro Carvalho Chehab    .
781ea272257SMauro Carvalho Chehab    .
782ea272257SMauro Carvalho Chehab    .
783ea272257SMauro Carvalho Chehab    { id: sys_waitid                    [247], common_pid: upstart-dbus-br [      2690] } hitcount:          3
784ea272257SMauro Carvalho Chehab    { id: sys_waitid                    [247], common_pid: upstart-dbus-br [      2688] } hitcount:         16
785ea272257SMauro Carvalho Chehab    { id: sys_inotify_add_watch         [254], common_pid: gmain           [       975] } hitcount:          2
786ea272257SMauro Carvalho Chehab    { id: sys_inotify_add_watch         [254], common_pid: gmain           [      3204] } hitcount:          4
787ea272257SMauro Carvalho Chehab    { id: sys_inotify_add_watch         [254], common_pid: gmain           [      2888] } hitcount:          4
788ea272257SMauro Carvalho Chehab    { id: sys_inotify_add_watch         [254], common_pid: gmain           [      3003] } hitcount:          4
789ea272257SMauro Carvalho Chehab    { id: sys_inotify_add_watch         [254], common_pid: gmain           [      2873] } hitcount:          4
790ea272257SMauro Carvalho Chehab    { id: sys_inotify_add_watch         [254], common_pid: gmain           [      3196] } hitcount:          6
791ea272257SMauro Carvalho Chehab    { id: sys_openat                    [257], common_pid: java            [      2623] } hitcount:          2
792ea272257SMauro Carvalho Chehab    { id: sys_eventfd2                  [290], common_pid: ibus-ui-gtk3    [      2760] } hitcount:          4
793ea272257SMauro Carvalho Chehab    { id: sys_eventfd2                  [290], common_pid: compiz          [      2994] } hitcount:          6
794ea272257SMauro Carvalho Chehab
795ea272257SMauro Carvalho Chehab    Totals:
796ea272257SMauro Carvalho Chehab        Hits: 31536
797ea272257SMauro Carvalho Chehab        Entries: 323
798ea272257SMauro Carvalho Chehab        Dropped: 0
799ea272257SMauro Carvalho Chehab
800ea272257SMauro Carvalho Chehab  The above list does give us a breakdown of the ioctl syscall by
801ea272257SMauro Carvalho Chehab  pid, but it also gives us quite a bit more than that, which we
802ea272257SMauro Carvalho Chehab  don't really care about at the moment.  Since we know the syscall
803ea272257SMauro Carvalho Chehab  id for sys_ioctl (16, displayed next to the sys_ioctl name), we
804ea272257SMauro Carvalho Chehab  can use that to filter out all the other syscalls::
805ea272257SMauro Carvalho Chehab
806ea272257SMauro Carvalho Chehab    # echo 'hist:key=id.syscall,common_pid.execname:val=hitcount:sort=id,hitcount if id == 16' > \
8072abfcd29SRoss Zwisler           /sys/kernel/tracing/events/raw_syscalls/sys_enter/trigger
808ea272257SMauro Carvalho Chehab
8092abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/raw_syscalls/sys_enter/hist
810ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=id.syscall,common_pid.execname:vals=hitcount:sort=id.syscall,hitcount:size=2048 if id == 16 [active]
811ea272257SMauro Carvalho Chehab
812ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gmain           [      2769] } hitcount:          1
813ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: evolution-addre [      8571] } hitcount:          1
814ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gmain           [      3003] } hitcount:          1
815ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gmain           [      2781] } hitcount:          1
816ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gmain           [      2829] } hitcount:          1
817ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: bash            [      8726] } hitcount:          1
818ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: bash            [      8508] } hitcount:          1
819ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gmain           [      2970] } hitcount:          1
820ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: gmain           [      2768] } hitcount:          1
821ea272257SMauro Carvalho Chehab    .
822ea272257SMauro Carvalho Chehab    .
823ea272257SMauro Carvalho Chehab    .
824ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: pool            [      8559] } hitcount:         45
825ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: pool            [      8555] } hitcount:         48
826ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: pool            [      8551] } hitcount:         48
827ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: avahi-daemon    [       896] } hitcount:         66
828ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: Xorg            [      1267] } hitcount:      26674
829ea272257SMauro Carvalho Chehab    { id: sys_ioctl                     [ 16], common_pid: compiz          [      2994] } hitcount:      73443
830ea272257SMauro Carvalho Chehab
831ea272257SMauro Carvalho Chehab    Totals:
832ea272257SMauro Carvalho Chehab        Hits: 101162
833ea272257SMauro Carvalho Chehab        Entries: 103
834ea272257SMauro Carvalho Chehab        Dropped: 0
835ea272257SMauro Carvalho Chehab
836ea272257SMauro Carvalho Chehab  The above output shows that 'compiz' and 'Xorg' are far and away
837ea272257SMauro Carvalho Chehab  the heaviest ioctl callers (which might lead to questions about
838ea272257SMauro Carvalho Chehab  whether they really need to be making all those calls and to
839ea272257SMauro Carvalho Chehab  possible avenues for further investigation.)
840ea272257SMauro Carvalho Chehab
841ea272257SMauro Carvalho Chehab  The compound key examples used a key and a sum value (hitcount) to
842ea272257SMauro Carvalho Chehab  sort the output, but we can just as easily use two keys instead.
843ea272257SMauro Carvalho Chehab  Here's an example where we use a compound key composed of the the
844ea272257SMauro Carvalho Chehab  common_pid and size event fields.  Sorting with pid as the primary
845ea272257SMauro Carvalho Chehab  key and 'size' as the secondary key allows us to display an
846ea272257SMauro Carvalho Chehab  ordered summary of the recvfrom sizes, with counts, received by
847ea272257SMauro Carvalho Chehab  each process::
848ea272257SMauro Carvalho Chehab
849ea272257SMauro Carvalho Chehab    # echo 'hist:key=common_pid.execname,size:val=hitcount:sort=common_pid,size' > \
8502abfcd29SRoss Zwisler           /sys/kernel/tracing/events/syscalls/sys_enter_recvfrom/trigger
851ea272257SMauro Carvalho Chehab
8522abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/syscalls/sys_enter_recvfrom/hist
853ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=common_pid.execname,size:vals=hitcount:sort=common_pid.execname,size:size=2048 [active]
854ea272257SMauro Carvalho Chehab
855ea272257SMauro Carvalho Chehab    { common_pid: smbd            [       784], size:          4 } hitcount:          1
856ea272257SMauro Carvalho Chehab    { common_pid: dnsmasq         [      1412], size:       4096 } hitcount:        672
857ea272257SMauro Carvalho Chehab    { common_pid: postgres        [      1796], size:       1000 } hitcount:          6
858ea272257SMauro Carvalho Chehab    { common_pid: postgres        [      1867], size:       1000 } hitcount:         10
859ea272257SMauro Carvalho Chehab    { common_pid: bamfdaemon      [      2787], size:         28 } hitcount:          2
860ea272257SMauro Carvalho Chehab    { common_pid: bamfdaemon      [      2787], size:      14360 } hitcount:          1
861ea272257SMauro Carvalho Chehab    { common_pid: compiz          [      2994], size:          8 } hitcount:          1
862ea272257SMauro Carvalho Chehab    { common_pid: compiz          [      2994], size:         20 } hitcount:         11
863ea272257SMauro Carvalho Chehab    { common_pid: gnome-terminal  [      3199], size:          4 } hitcount:          2
864ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8817], size:          4 } hitcount:          1
865ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8817], size:          8 } hitcount:          5
866ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8817], size:        588 } hitcount:          2
867ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8817], size:        628 } hitcount:          1
868ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8817], size:       6944 } hitcount:          1
869ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8817], size:     408880 } hitcount:          2
870ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8822], size:          8 } hitcount:          2
871ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8822], size:        160 } hitcount:          2
872ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8822], size:        320 } hitcount:          2
873ea272257SMauro Carvalho Chehab    { common_pid: firefox         [      8822], size:        352 } hitcount:          1
874ea272257SMauro Carvalho Chehab    .
875ea272257SMauro Carvalho Chehab    .
876ea272257SMauro Carvalho Chehab    .
877ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8923], size:       1960 } hitcount:         10
878ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8923], size:       2048 } hitcount:         10
879ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8924], size:       1960 } hitcount:         10
880ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8924], size:       2048 } hitcount:         10
881ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8928], size:       1964 } hitcount:          4
882ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8928], size:       1965 } hitcount:          2
883ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8928], size:       2048 } hitcount:          6
884ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8929], size:       1982 } hitcount:          1
885ea272257SMauro Carvalho Chehab    { common_pid: pool            [      8929], size:       2048 } hitcount:          1
886ea272257SMauro Carvalho Chehab
887ea272257SMauro Carvalho Chehab    Totals:
888ea272257SMauro Carvalho Chehab        Hits: 2016
889ea272257SMauro Carvalho Chehab        Entries: 224
890ea272257SMauro Carvalho Chehab        Dropped: 0
891ea272257SMauro Carvalho Chehab
892ea272257SMauro Carvalho Chehab  The above example also illustrates the fact that although a compound
893ea272257SMauro Carvalho Chehab  key is treated as a single entity for hashing purposes, the sub-keys
894ea272257SMauro Carvalho Chehab  it's composed of can be accessed independently.
895ea272257SMauro Carvalho Chehab
896ea272257SMauro Carvalho Chehab  The next example uses a string field as the hash key and
897ea272257SMauro Carvalho Chehab  demonstrates how you can manually pause and continue a hist trigger.
898ea272257SMauro Carvalho Chehab  In this example, we'll aggregate fork counts and don't expect a
899ea272257SMauro Carvalho Chehab  large number of entries in the hash table, so we'll drop it to a
900ea272257SMauro Carvalho Chehab  much smaller number, say 256::
901ea272257SMauro Carvalho Chehab
902ea272257SMauro Carvalho Chehab    # echo 'hist:key=child_comm:val=hitcount:size=256' > \
9032abfcd29SRoss Zwisler           /sys/kernel/tracing/events/sched/sched_process_fork/trigger
904ea272257SMauro Carvalho Chehab
9052abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/sched/sched_process_fork/hist
906ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=child_comm:vals=hitcount:sort=hitcount:size=256 [active]
907ea272257SMauro Carvalho Chehab
908ea272257SMauro Carvalho Chehab    { child_comm: dconf worker                        } hitcount:          1
909ea272257SMauro Carvalho Chehab    { child_comm: ibus-daemon                         } hitcount:          1
910ea272257SMauro Carvalho Chehab    { child_comm: whoopsie                            } hitcount:          1
911ea272257SMauro Carvalho Chehab    { child_comm: smbd                                } hitcount:          1
912ea272257SMauro Carvalho Chehab    { child_comm: gdbus                               } hitcount:          1
913ea272257SMauro Carvalho Chehab    { child_comm: kthreadd                            } hitcount:          1
914ea272257SMauro Carvalho Chehab    { child_comm: dconf worker                        } hitcount:          1
915ea272257SMauro Carvalho Chehab    { child_comm: evolution-alarm                     } hitcount:          2
916ea272257SMauro Carvalho Chehab    { child_comm: Socket Thread                       } hitcount:          2
917ea272257SMauro Carvalho Chehab    { child_comm: postgres                            } hitcount:          2
918ea272257SMauro Carvalho Chehab    { child_comm: bash                                } hitcount:          3
919ea272257SMauro Carvalho Chehab    { child_comm: compiz                              } hitcount:          3
920ea272257SMauro Carvalho Chehab    { child_comm: evolution-sourc                     } hitcount:          4
921ea272257SMauro Carvalho Chehab    { child_comm: dhclient                            } hitcount:          4
922ea272257SMauro Carvalho Chehab    { child_comm: pool                                } hitcount:          5
923ea272257SMauro Carvalho Chehab    { child_comm: nm-dispatcher.a                     } hitcount:          8
924ea272257SMauro Carvalho Chehab    { child_comm: firefox                             } hitcount:          8
925ea272257SMauro Carvalho Chehab    { child_comm: dbus-daemon                         } hitcount:          8
926ea272257SMauro Carvalho Chehab    { child_comm: glib-pacrunner                      } hitcount:         10
927ea272257SMauro Carvalho Chehab    { child_comm: evolution                           } hitcount:         23
928ea272257SMauro Carvalho Chehab
929ea272257SMauro Carvalho Chehab    Totals:
930ea272257SMauro Carvalho Chehab        Hits: 89
931ea272257SMauro Carvalho Chehab        Entries: 20
932ea272257SMauro Carvalho Chehab        Dropped: 0
933ea272257SMauro Carvalho Chehab
934ea272257SMauro Carvalho Chehab  If we want to pause the hist trigger, we can simply append :pause to
935ea272257SMauro Carvalho Chehab  the command that started the trigger.  Notice that the trigger info
936ea272257SMauro Carvalho Chehab  displays as [paused]::
937ea272257SMauro Carvalho Chehab
938ea272257SMauro Carvalho Chehab    # echo 'hist:key=child_comm:val=hitcount:size=256:pause' >> \
9392abfcd29SRoss Zwisler           /sys/kernel/tracing/events/sched/sched_process_fork/trigger
940ea272257SMauro Carvalho Chehab
9412abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/sched/sched_process_fork/hist
942ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=child_comm:vals=hitcount:sort=hitcount:size=256 [paused]
943ea272257SMauro Carvalho Chehab
944ea272257SMauro Carvalho Chehab    { child_comm: dconf worker                        } hitcount:          1
945ea272257SMauro Carvalho Chehab    { child_comm: kthreadd                            } hitcount:          1
946ea272257SMauro Carvalho Chehab    { child_comm: dconf worker                        } hitcount:          1
947ea272257SMauro Carvalho Chehab    { child_comm: gdbus                               } hitcount:          1
948ea272257SMauro Carvalho Chehab    { child_comm: ibus-daemon                         } hitcount:          1
949ea272257SMauro Carvalho Chehab    { child_comm: Socket Thread                       } hitcount:          2
950ea272257SMauro Carvalho Chehab    { child_comm: evolution-alarm                     } hitcount:          2
951ea272257SMauro Carvalho Chehab    { child_comm: smbd                                } hitcount:          2
952ea272257SMauro Carvalho Chehab    { child_comm: bash                                } hitcount:          3
953ea272257SMauro Carvalho Chehab    { child_comm: whoopsie                            } hitcount:          3
954ea272257SMauro Carvalho Chehab    { child_comm: compiz                              } hitcount:          3
955ea272257SMauro Carvalho Chehab    { child_comm: evolution-sourc                     } hitcount:          4
956ea272257SMauro Carvalho Chehab    { child_comm: pool                                } hitcount:          5
957ea272257SMauro Carvalho Chehab    { child_comm: postgres                            } hitcount:          6
958ea272257SMauro Carvalho Chehab    { child_comm: firefox                             } hitcount:          8
959ea272257SMauro Carvalho Chehab    { child_comm: dhclient                            } hitcount:         10
960ea272257SMauro Carvalho Chehab    { child_comm: emacs                               } hitcount:         12
961ea272257SMauro Carvalho Chehab    { child_comm: dbus-daemon                         } hitcount:         20
962ea272257SMauro Carvalho Chehab    { child_comm: nm-dispatcher.a                     } hitcount:         20
963ea272257SMauro Carvalho Chehab    { child_comm: evolution                           } hitcount:         35
964ea272257SMauro Carvalho Chehab    { child_comm: glib-pacrunner                      } hitcount:         59
965ea272257SMauro Carvalho Chehab
966ea272257SMauro Carvalho Chehab    Totals:
967ea272257SMauro Carvalho Chehab        Hits: 199
968ea272257SMauro Carvalho Chehab        Entries: 21
969ea272257SMauro Carvalho Chehab        Dropped: 0
970ea272257SMauro Carvalho Chehab
971ea272257SMauro Carvalho Chehab  To manually continue having the trigger aggregate events, append
972ea272257SMauro Carvalho Chehab  :cont instead.  Notice that the trigger info displays as [active]
973ea272257SMauro Carvalho Chehab  again, and the data has changed::
974ea272257SMauro Carvalho Chehab
975ea272257SMauro Carvalho Chehab    # echo 'hist:key=child_comm:val=hitcount:size=256:cont' >> \
9762abfcd29SRoss Zwisler           /sys/kernel/tracing/events/sched/sched_process_fork/trigger
977ea272257SMauro Carvalho Chehab
9782abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/sched/sched_process_fork/hist
979ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=child_comm:vals=hitcount:sort=hitcount:size=256 [active]
980ea272257SMauro Carvalho Chehab
981ea272257SMauro Carvalho Chehab    { child_comm: dconf worker                        } hitcount:          1
982ea272257SMauro Carvalho Chehab    { child_comm: dconf worker                        } hitcount:          1
983ea272257SMauro Carvalho Chehab    { child_comm: kthreadd                            } hitcount:          1
984ea272257SMauro Carvalho Chehab    { child_comm: gdbus                               } hitcount:          1
985ea272257SMauro Carvalho Chehab    { child_comm: ibus-daemon                         } hitcount:          1
986ea272257SMauro Carvalho Chehab    { child_comm: Socket Thread                       } hitcount:          2
987ea272257SMauro Carvalho Chehab    { child_comm: evolution-alarm                     } hitcount:          2
988ea272257SMauro Carvalho Chehab    { child_comm: smbd                                } hitcount:          2
989ea272257SMauro Carvalho Chehab    { child_comm: whoopsie                            } hitcount:          3
990ea272257SMauro Carvalho Chehab    { child_comm: compiz                              } hitcount:          3
991ea272257SMauro Carvalho Chehab    { child_comm: evolution-sourc                     } hitcount:          4
992ea272257SMauro Carvalho Chehab    { child_comm: bash                                } hitcount:          5
993ea272257SMauro Carvalho Chehab    { child_comm: pool                                } hitcount:          5
994ea272257SMauro Carvalho Chehab    { child_comm: postgres                            } hitcount:          6
995ea272257SMauro Carvalho Chehab    { child_comm: firefox                             } hitcount:          8
996ea272257SMauro Carvalho Chehab    { child_comm: dhclient                            } hitcount:         11
997ea272257SMauro Carvalho Chehab    { child_comm: emacs                               } hitcount:         12
998ea272257SMauro Carvalho Chehab    { child_comm: dbus-daemon                         } hitcount:         22
999ea272257SMauro Carvalho Chehab    { child_comm: nm-dispatcher.a                     } hitcount:         22
1000ea272257SMauro Carvalho Chehab    { child_comm: evolution                           } hitcount:         35
1001ea272257SMauro Carvalho Chehab    { child_comm: glib-pacrunner                      } hitcount:         59
1002ea272257SMauro Carvalho Chehab
1003ea272257SMauro Carvalho Chehab    Totals:
1004ea272257SMauro Carvalho Chehab        Hits: 206
1005ea272257SMauro Carvalho Chehab        Entries: 21
1006ea272257SMauro Carvalho Chehab        Dropped: 0
1007ea272257SMauro Carvalho Chehab
1008ea272257SMauro Carvalho Chehab  The previous example showed how to start and stop a hist trigger by
1009ea272257SMauro Carvalho Chehab  appending 'pause' and 'continue' to the hist trigger command.  A
1010ea272257SMauro Carvalho Chehab  hist trigger can also be started in a paused state by initially
1011ea272257SMauro Carvalho Chehab  starting the trigger with ':pause' appended.  This allows you to
1012ea272257SMauro Carvalho Chehab  start the trigger only when you're ready to start collecting data
1013ea272257SMauro Carvalho Chehab  and not before.  For example, you could start the trigger in a
1014ea272257SMauro Carvalho Chehab  paused state, then unpause it and do something you want to measure,
1015ea272257SMauro Carvalho Chehab  then pause the trigger again when done.
1016ea272257SMauro Carvalho Chehab
1017ea272257SMauro Carvalho Chehab  Of course, doing this manually can be difficult and error-prone, but
1018ea272257SMauro Carvalho Chehab  it is possible to automatically start and stop a hist trigger based
1019ea272257SMauro Carvalho Chehab  on some condition, via the enable_hist and disable_hist triggers.
1020ea272257SMauro Carvalho Chehab
1021ea272257SMauro Carvalho Chehab  For example, suppose we wanted to take a look at the relative
1022ea272257SMauro Carvalho Chehab  weights in terms of skb length for each callpath that leads to a
1023fe4ec72cSMasanari Iida  netif_receive_skb event when downloading a decent-sized file using
1024ea272257SMauro Carvalho Chehab  wget.
1025ea272257SMauro Carvalho Chehab
1026ea272257SMauro Carvalho Chehab  First we set up an initially paused stacktrace trigger on the
1027ea272257SMauro Carvalho Chehab  netif_receive_skb event::
1028ea272257SMauro Carvalho Chehab
1029*4b512860SSteven Rostedt (Google)    # echo 'hist:key=common_stacktrace:vals=len:pause' > \
10302abfcd29SRoss Zwisler           /sys/kernel/tracing/events/net/netif_receive_skb/trigger
1031ea272257SMauro Carvalho Chehab
1032ea272257SMauro Carvalho Chehab  Next, we set up an 'enable_hist' trigger on the sched_process_exec
1033ea272257SMauro Carvalho Chehab  event, with an 'if filename==/usr/bin/wget' filter.  The effect of
1034ea272257SMauro Carvalho Chehab  this new trigger is that it will 'unpause' the hist trigger we just
1035ea272257SMauro Carvalho Chehab  set up on netif_receive_skb if and only if it sees a
1036ea272257SMauro Carvalho Chehab  sched_process_exec event with a filename of '/usr/bin/wget'.  When
1037ea272257SMauro Carvalho Chehab  that happens, all netif_receive_skb events are aggregated into a
1038ea272257SMauro Carvalho Chehab  hash table keyed on stacktrace::
1039ea272257SMauro Carvalho Chehab
1040ea272257SMauro Carvalho Chehab    # echo 'enable_hist:net:netif_receive_skb if filename==/usr/bin/wget' > \
10412abfcd29SRoss Zwisler           /sys/kernel/tracing/events/sched/sched_process_exec/trigger
1042ea272257SMauro Carvalho Chehab
1043ea272257SMauro Carvalho Chehab  The aggregation continues until the netif_receive_skb is paused
1044ea272257SMauro Carvalho Chehab  again, which is what the following disable_hist event does by
1045ea272257SMauro Carvalho Chehab  creating a similar setup on the sched_process_exit event, using the
1046ea272257SMauro Carvalho Chehab  filter 'comm==wget'::
1047ea272257SMauro Carvalho Chehab
1048ea272257SMauro Carvalho Chehab    # echo 'disable_hist:net:netif_receive_skb if comm==wget' > \
10492abfcd29SRoss Zwisler           /sys/kernel/tracing/events/sched/sched_process_exit/trigger
1050ea272257SMauro Carvalho Chehab
1051ea272257SMauro Carvalho Chehab  Whenever a process exits and the comm field of the disable_hist
1052ea272257SMauro Carvalho Chehab  trigger filter matches 'comm==wget', the netif_receive_skb hist
1053ea272257SMauro Carvalho Chehab  trigger is disabled.
1054ea272257SMauro Carvalho Chehab
1055ea272257SMauro Carvalho Chehab  The overall effect is that netif_receive_skb events are aggregated
1056ea272257SMauro Carvalho Chehab  into the hash table for only the duration of the wget.  Executing a
1057ea272257SMauro Carvalho Chehab  wget command and then listing the 'hist' file will display the
1058ea272257SMauro Carvalho Chehab  output generated by the wget command::
1059ea272257SMauro Carvalho Chehab
1060ea272257SMauro Carvalho Chehab    $ wget https://www.kernel.org/pub/linux/kernel/v3.x/patch-3.19.xz
1061ea272257SMauro Carvalho Chehab
10622abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/net/netif_receive_skb/hist
1063*4b512860SSteven Rostedt (Google)    # trigger info: hist:keys=common_stacktrace:vals=len:sort=hitcount:size=2048 [paused]
1064ea272257SMauro Carvalho Chehab
1065*4b512860SSteven Rostedt (Google)    { common_stacktrace:
1066ea272257SMauro Carvalho Chehab         __netif_receive_skb_core+0x46d/0x990
1067ea272257SMauro Carvalho Chehab         __netif_receive_skb+0x18/0x60
1068ea272257SMauro Carvalho Chehab         netif_receive_skb_internal+0x23/0x90
1069ea272257SMauro Carvalho Chehab         napi_gro_receive+0xc8/0x100
1070ea272257SMauro Carvalho Chehab         ieee80211_deliver_skb+0xd6/0x270 [mac80211]
1071ea272257SMauro Carvalho Chehab         ieee80211_rx_handlers+0xccf/0x22f0 [mac80211]
1072ea272257SMauro Carvalho Chehab         ieee80211_prepare_and_rx_handle+0x4e7/0xc40 [mac80211]
1073ea272257SMauro Carvalho Chehab         ieee80211_rx+0x31d/0x900 [mac80211]
1074ea272257SMauro Carvalho Chehab         iwlagn_rx_reply_rx+0x3db/0x6f0 [iwldvm]
1075ea272257SMauro Carvalho Chehab         iwl_rx_dispatch+0x8e/0xf0 [iwldvm]
1076ea272257SMauro Carvalho Chehab         iwl_pcie_irq_handler+0xe3c/0x12f0 [iwlwifi]
1077ea272257SMauro Carvalho Chehab         irq_thread_fn+0x20/0x50
1078ea272257SMauro Carvalho Chehab         irq_thread+0x11f/0x150
1079ea272257SMauro Carvalho Chehab         kthread+0xd2/0xf0
1080ea272257SMauro Carvalho Chehab         ret_from_fork+0x42/0x70
1081ea272257SMauro Carvalho Chehab    } hitcount:         85  len:      28884
1082*4b512860SSteven Rostedt (Google)    { common_stacktrace:
1083ea272257SMauro Carvalho Chehab         __netif_receive_skb_core+0x46d/0x990
1084ea272257SMauro Carvalho Chehab         __netif_receive_skb+0x18/0x60
1085ea272257SMauro Carvalho Chehab         netif_receive_skb_internal+0x23/0x90
1086ea272257SMauro Carvalho Chehab         napi_gro_complete+0xa4/0xe0
1087ea272257SMauro Carvalho Chehab         dev_gro_receive+0x23a/0x360
1088ea272257SMauro Carvalho Chehab         napi_gro_receive+0x30/0x100
1089ea272257SMauro Carvalho Chehab         ieee80211_deliver_skb+0xd6/0x270 [mac80211]
1090ea272257SMauro Carvalho Chehab         ieee80211_rx_handlers+0xccf/0x22f0 [mac80211]
1091ea272257SMauro Carvalho Chehab         ieee80211_prepare_and_rx_handle+0x4e7/0xc40 [mac80211]
1092ea272257SMauro Carvalho Chehab         ieee80211_rx+0x31d/0x900 [mac80211]
1093ea272257SMauro Carvalho Chehab         iwlagn_rx_reply_rx+0x3db/0x6f0 [iwldvm]
1094ea272257SMauro Carvalho Chehab         iwl_rx_dispatch+0x8e/0xf0 [iwldvm]
1095ea272257SMauro Carvalho Chehab         iwl_pcie_irq_handler+0xe3c/0x12f0 [iwlwifi]
1096ea272257SMauro Carvalho Chehab         irq_thread_fn+0x20/0x50
1097ea272257SMauro Carvalho Chehab         irq_thread+0x11f/0x150
1098ea272257SMauro Carvalho Chehab         kthread+0xd2/0xf0
1099ea272257SMauro Carvalho Chehab    } hitcount:         98  len:     664329
1100*4b512860SSteven Rostedt (Google)    { common_stacktrace:
1101ea272257SMauro Carvalho Chehab         __netif_receive_skb_core+0x46d/0x990
1102ea272257SMauro Carvalho Chehab         __netif_receive_skb+0x18/0x60
1103ea272257SMauro Carvalho Chehab         process_backlog+0xa8/0x150
1104ea272257SMauro Carvalho Chehab         net_rx_action+0x15d/0x340
1105ea272257SMauro Carvalho Chehab         __do_softirq+0x114/0x2c0
1106ea272257SMauro Carvalho Chehab         do_softirq_own_stack+0x1c/0x30
1107ea272257SMauro Carvalho Chehab         do_softirq+0x65/0x70
1108ea272257SMauro Carvalho Chehab         __local_bh_enable_ip+0xb5/0xc0
1109ea272257SMauro Carvalho Chehab         ip_finish_output+0x1f4/0x840
1110ea272257SMauro Carvalho Chehab         ip_output+0x6b/0xc0
1111ea272257SMauro Carvalho Chehab         ip_local_out_sk+0x31/0x40
1112ea272257SMauro Carvalho Chehab         ip_send_skb+0x1a/0x50
1113ea272257SMauro Carvalho Chehab         udp_send_skb+0x173/0x2a0
1114ea272257SMauro Carvalho Chehab         udp_sendmsg+0x2bf/0x9f0
1115ea272257SMauro Carvalho Chehab         inet_sendmsg+0x64/0xa0
1116ea272257SMauro Carvalho Chehab         sock_sendmsg+0x3d/0x50
1117ea272257SMauro Carvalho Chehab    } hitcount:        115  len:      13030
1118*4b512860SSteven Rostedt (Google)    { common_stacktrace:
1119ea272257SMauro Carvalho Chehab         __netif_receive_skb_core+0x46d/0x990
1120ea272257SMauro Carvalho Chehab         __netif_receive_skb+0x18/0x60
1121ea272257SMauro Carvalho Chehab         netif_receive_skb_internal+0x23/0x90
1122ea272257SMauro Carvalho Chehab         napi_gro_complete+0xa4/0xe0
1123ea272257SMauro Carvalho Chehab         napi_gro_flush+0x6d/0x90
1124ea272257SMauro Carvalho Chehab         iwl_pcie_irq_handler+0x92a/0x12f0 [iwlwifi]
1125ea272257SMauro Carvalho Chehab         irq_thread_fn+0x20/0x50
1126ea272257SMauro Carvalho Chehab         irq_thread+0x11f/0x150
1127ea272257SMauro Carvalho Chehab         kthread+0xd2/0xf0
1128ea272257SMauro Carvalho Chehab         ret_from_fork+0x42/0x70
1129ea272257SMauro Carvalho Chehab    } hitcount:        934  len:    5512212
1130ea272257SMauro Carvalho Chehab
1131ea272257SMauro Carvalho Chehab    Totals:
1132ea272257SMauro Carvalho Chehab        Hits: 1232
1133ea272257SMauro Carvalho Chehab        Entries: 4
1134ea272257SMauro Carvalho Chehab        Dropped: 0
1135ea272257SMauro Carvalho Chehab
1136ea272257SMauro Carvalho Chehab  The above shows all the netif_receive_skb callpaths and their total
1137ea272257SMauro Carvalho Chehab  lengths for the duration of the wget command.
1138ea272257SMauro Carvalho Chehab
1139ea272257SMauro Carvalho Chehab  The 'clear' hist trigger param can be used to clear the hash table.
1140ea272257SMauro Carvalho Chehab  Suppose we wanted to try another run of the previous example but
1141ea272257SMauro Carvalho Chehab  this time also wanted to see the complete list of events that went
1142ea272257SMauro Carvalho Chehab  into the histogram.  In order to avoid having to set everything up
1143ea272257SMauro Carvalho Chehab  again, we can just clear the histogram first::
1144ea272257SMauro Carvalho Chehab
1145*4b512860SSteven Rostedt (Google)    # echo 'hist:key=common_stacktrace:vals=len:clear' >> \
11462abfcd29SRoss Zwisler           /sys/kernel/tracing/events/net/netif_receive_skb/trigger
1147ea272257SMauro Carvalho Chehab
1148ea272257SMauro Carvalho Chehab  Just to verify that it is in fact cleared, here's what we now see in
1149ea272257SMauro Carvalho Chehab  the hist file::
1150ea272257SMauro Carvalho Chehab
11512abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/net/netif_receive_skb/hist
1152*4b512860SSteven Rostedt (Google)    # trigger info: hist:keys=common_stacktrace:vals=len:sort=hitcount:size=2048 [paused]
1153ea272257SMauro Carvalho Chehab
1154ea272257SMauro Carvalho Chehab    Totals:
1155ea272257SMauro Carvalho Chehab        Hits: 0
1156ea272257SMauro Carvalho Chehab        Entries: 0
1157ea272257SMauro Carvalho Chehab        Dropped: 0
1158ea272257SMauro Carvalho Chehab
1159ea272257SMauro Carvalho Chehab  Since we want to see the detailed list of every netif_receive_skb
1160ea272257SMauro Carvalho Chehab  event occurring during the new run, which are in fact the same
1161ea272257SMauro Carvalho Chehab  events being aggregated into the hash table, we add some additional
1162ea272257SMauro Carvalho Chehab  'enable_event' events to the triggering sched_process_exec and
1163ea272257SMauro Carvalho Chehab  sched_process_exit events as such::
1164ea272257SMauro Carvalho Chehab
1165ea272257SMauro Carvalho Chehab    # echo 'enable_event:net:netif_receive_skb if filename==/usr/bin/wget' > \
11662abfcd29SRoss Zwisler           /sys/kernel/tracing/events/sched/sched_process_exec/trigger
1167ea272257SMauro Carvalho Chehab
1168ea272257SMauro Carvalho Chehab    # echo 'disable_event:net:netif_receive_skb if comm==wget' > \
11692abfcd29SRoss Zwisler           /sys/kernel/tracing/events/sched/sched_process_exit/trigger
1170ea272257SMauro Carvalho Chehab
1171ea272257SMauro Carvalho Chehab  If you read the trigger files for the sched_process_exec and
1172ea272257SMauro Carvalho Chehab  sched_process_exit triggers, you should see two triggers for each:
1173ea272257SMauro Carvalho Chehab  one enabling/disabling the hist aggregation and the other
1174ea272257SMauro Carvalho Chehab  enabling/disabling the logging of events::
1175ea272257SMauro Carvalho Chehab
11762abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/sched/sched_process_exec/trigger
1177ea272257SMauro Carvalho Chehab    enable_event:net:netif_receive_skb:unlimited if filename==/usr/bin/wget
1178ea272257SMauro Carvalho Chehab    enable_hist:net:netif_receive_skb:unlimited if filename==/usr/bin/wget
1179ea272257SMauro Carvalho Chehab
11802abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/sched/sched_process_exit/trigger
1181ea272257SMauro Carvalho Chehab    enable_event:net:netif_receive_skb:unlimited if comm==wget
1182ea272257SMauro Carvalho Chehab    disable_hist:net:netif_receive_skb:unlimited if comm==wget
1183ea272257SMauro Carvalho Chehab
1184ea272257SMauro Carvalho Chehab  In other words, whenever either of the sched_process_exec or
1185ea272257SMauro Carvalho Chehab  sched_process_exit events is hit and matches 'wget', it enables or
1186ea272257SMauro Carvalho Chehab  disables both the histogram and the event log, and what you end up
1187ea272257SMauro Carvalho Chehab  with is a hash table and set of events just covering the specified
1188ea272257SMauro Carvalho Chehab  duration.  Run the wget command again::
1189ea272257SMauro Carvalho Chehab
1190ea272257SMauro Carvalho Chehab    $ wget https://www.kernel.org/pub/linux/kernel/v3.x/patch-3.19.xz
1191ea272257SMauro Carvalho Chehab
1192ea272257SMauro Carvalho Chehab  Displaying the 'hist' file should show something similar to what you
1193ea272257SMauro Carvalho Chehab  saw in the last run, but this time you should also see the
1194ea272257SMauro Carvalho Chehab  individual events in the trace file::
1195ea272257SMauro Carvalho Chehab
11962abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/trace
1197ea272257SMauro Carvalho Chehab
1198ea272257SMauro Carvalho Chehab    # tracer: nop
1199ea272257SMauro Carvalho Chehab    #
1200ea272257SMauro Carvalho Chehab    # entries-in-buffer/entries-written: 183/1426   #P:4
1201ea272257SMauro Carvalho Chehab    #
1202ea272257SMauro Carvalho Chehab    #                              _-----=> irqs-off
1203ea272257SMauro Carvalho Chehab    #                             / _----=> need-resched
1204ea272257SMauro Carvalho Chehab    #                            | / _---=> hardirq/softirq
1205ea272257SMauro Carvalho Chehab    #                            || / _--=> preempt-depth
1206ea272257SMauro Carvalho Chehab    #                            ||| /     delay
1207ea272257SMauro Carvalho Chehab    #           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
1208ea272257SMauro Carvalho Chehab    #              | |       |   ||||       |         |
1209ea272257SMauro Carvalho Chehab                wget-15108 [000] ..s1 31769.606929: netif_receive_skb: dev=lo skbaddr=ffff88009c353100 len=60
1210ea272257SMauro Carvalho Chehab                wget-15108 [000] ..s1 31769.606999: netif_receive_skb: dev=lo skbaddr=ffff88009c353200 len=60
1211ea272257SMauro Carvalho Chehab             dnsmasq-1382  [000] ..s1 31769.677652: netif_receive_skb: dev=lo skbaddr=ffff88009c352b00 len=130
1212ea272257SMauro Carvalho Chehab             dnsmasq-1382  [000] ..s1 31769.685917: netif_receive_skb: dev=lo skbaddr=ffff88009c352200 len=138
1213ea272257SMauro Carvalho Chehab    ##### CPU 2 buffer started ####
1214ea272257SMauro Carvalho Chehab      irq/29-iwlwifi-559   [002] ..s. 31772.031529: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d433d00 len=2948
1215ea272257SMauro Carvalho Chehab      irq/29-iwlwifi-559   [002] ..s. 31772.031572: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d432200 len=1500
1216ea272257SMauro Carvalho Chehab      irq/29-iwlwifi-559   [002] ..s. 31772.032196: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d433100 len=2948
1217ea272257SMauro Carvalho Chehab      irq/29-iwlwifi-559   [002] ..s. 31772.032761: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d433000 len=2948
1218ea272257SMauro Carvalho Chehab      irq/29-iwlwifi-559   [002] ..s. 31772.033220: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d432e00 len=1500
1219ea272257SMauro Carvalho Chehab    .
1220ea272257SMauro Carvalho Chehab    .
1221ea272257SMauro Carvalho Chehab    .
1222ea272257SMauro Carvalho Chehab
1223ea272257SMauro Carvalho Chehab  The following example demonstrates how multiple hist triggers can be
1224ea272257SMauro Carvalho Chehab  attached to a given event.  This capability can be useful for
1225ea272257SMauro Carvalho Chehab  creating a set of different summaries derived from the same set of
1226ea272257SMauro Carvalho Chehab  events, or for comparing the effects of different filters, among
1227ea272257SMauro Carvalho Chehab  other things::
1228ea272257SMauro Carvalho Chehab
1229ea272257SMauro Carvalho Chehab    # echo 'hist:keys=skbaddr.hex:vals=len if len < 0' >> \
12302abfcd29SRoss Zwisler           /sys/kernel/tracing/events/net/netif_receive_skb/trigger
1231ea272257SMauro Carvalho Chehab    # echo 'hist:keys=skbaddr.hex:vals=len if len > 4096' >> \
12322abfcd29SRoss Zwisler           /sys/kernel/tracing/events/net/netif_receive_skb/trigger
1233ea272257SMauro Carvalho Chehab    # echo 'hist:keys=skbaddr.hex:vals=len if len == 256' >> \
12342abfcd29SRoss Zwisler           /sys/kernel/tracing/events/net/netif_receive_skb/trigger
1235ea272257SMauro Carvalho Chehab    # echo 'hist:keys=skbaddr.hex:vals=len' >> \
12362abfcd29SRoss Zwisler           /sys/kernel/tracing/events/net/netif_receive_skb/trigger
1237ea272257SMauro Carvalho Chehab    # echo 'hist:keys=len:vals=common_preempt_count' >> \
12382abfcd29SRoss Zwisler           /sys/kernel/tracing/events/net/netif_receive_skb/trigger
1239ea272257SMauro Carvalho Chehab
1240ea272257SMauro Carvalho Chehab  The above set of commands create four triggers differing only in
1241ea272257SMauro Carvalho Chehab  their filters, along with a completely different though fairly
1242ea272257SMauro Carvalho Chehab  nonsensical trigger.  Note that in order to append multiple hist
1243ea272257SMauro Carvalho Chehab  triggers to the same file, you should use the '>>' operator to
1244ea272257SMauro Carvalho Chehab  append them ('>' will also add the new hist trigger, but will remove
1245ea272257SMauro Carvalho Chehab  any existing hist triggers beforehand).
1246ea272257SMauro Carvalho Chehab
1247ea272257SMauro Carvalho Chehab  Displaying the contents of the 'hist' file for the event shows the
1248ea272257SMauro Carvalho Chehab  contents of all five histograms::
1249ea272257SMauro Carvalho Chehab
12502abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/net/netif_receive_skb/hist
1251ea272257SMauro Carvalho Chehab
1252ea272257SMauro Carvalho Chehab    # event histogram
1253ea272257SMauro Carvalho Chehab    #
1254ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=len:vals=hitcount,common_preempt_count:sort=hitcount:size=2048 [active]
1255ea272257SMauro Carvalho Chehab    #
1256ea272257SMauro Carvalho Chehab
1257ea272257SMauro Carvalho Chehab    { len:        176 } hitcount:          1  common_preempt_count:          0
1258ea272257SMauro Carvalho Chehab    { len:        223 } hitcount:          1  common_preempt_count:          0
1259ea272257SMauro Carvalho Chehab    { len:       4854 } hitcount:          1  common_preempt_count:          0
1260ea272257SMauro Carvalho Chehab    { len:        395 } hitcount:          1  common_preempt_count:          0
1261ea272257SMauro Carvalho Chehab    { len:        177 } hitcount:          1  common_preempt_count:          0
1262ea272257SMauro Carvalho Chehab    { len:        446 } hitcount:          1  common_preempt_count:          0
1263ea272257SMauro Carvalho Chehab    { len:       1601 } hitcount:          1  common_preempt_count:          0
1264ea272257SMauro Carvalho Chehab    .
1265ea272257SMauro Carvalho Chehab    .
1266ea272257SMauro Carvalho Chehab    .
1267ea272257SMauro Carvalho Chehab    { len:       1280 } hitcount:         66  common_preempt_count:          0
1268ea272257SMauro Carvalho Chehab    { len:        116 } hitcount:         81  common_preempt_count:         40
1269ea272257SMauro Carvalho Chehab    { len:        708 } hitcount:        112  common_preempt_count:          0
1270ea272257SMauro Carvalho Chehab    { len:         46 } hitcount:        221  common_preempt_count:          0
1271ea272257SMauro Carvalho Chehab    { len:       1264 } hitcount:        458  common_preempt_count:          0
1272ea272257SMauro Carvalho Chehab
1273ea272257SMauro Carvalho Chehab    Totals:
1274ea272257SMauro Carvalho Chehab        Hits: 1428
1275ea272257SMauro Carvalho Chehab        Entries: 147
1276ea272257SMauro Carvalho Chehab        Dropped: 0
1277ea272257SMauro Carvalho Chehab
1278ea272257SMauro Carvalho Chehab
1279ea272257SMauro Carvalho Chehab    # event histogram
1280ea272257SMauro Carvalho Chehab    #
1281ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active]
1282ea272257SMauro Carvalho Chehab    #
1283ea272257SMauro Carvalho Chehab
1284ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800baee5e00 } hitcount:          1  len:        130
1285ea272257SMauro Carvalho Chehab    { skbaddr: ffff88005f3d5600 } hitcount:          1  len:       1280
1286ea272257SMauro Carvalho Chehab    { skbaddr: ffff88005f3d4900 } hitcount:          1  len:       1280
1287ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fed6300 } hitcount:          1  len:        115
1288ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0ad00 } hitcount:          1  len:        115
1289ea272257SMauro Carvalho Chehab    { skbaddr: ffff88008cdb1900 } hitcount:          1  len:         46
1290ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064b5ef00 } hitcount:          1  len:        118
1291ea272257SMauro Carvalho Chehab    { skbaddr: ffff880044e3c700 } hitcount:          1  len:         60
1292ea272257SMauro Carvalho Chehab    { skbaddr: ffff880100065900 } hitcount:          1  len:         46
1293ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d46bd500 } hitcount:          1  len:        116
1294ea272257SMauro Carvalho Chehab    { skbaddr: ffff88005f3d5f00 } hitcount:          1  len:       1280
1295ea272257SMauro Carvalho Chehab    { skbaddr: ffff880100064700 } hitcount:          1  len:        365
1296ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800badb6f00 } hitcount:          1  len:         60
1297ea272257SMauro Carvalho Chehab    .
1298ea272257SMauro Carvalho Chehab    .
1299ea272257SMauro Carvalho Chehab    .
1300ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0be00 } hitcount:         27  len:      24677
1301ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0a400 } hitcount:         27  len:      23052
1302ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0b700 } hitcount:         31  len:      25589
1303ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0b600 } hitcount:         32  len:      27326
1304ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a462800 } hitcount:         68  len:      71678
1305ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a463700 } hitcount:         70  len:      72678
1306ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a462b00 } hitcount:         71  len:      77589
1307ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a463600 } hitcount:         73  len:      71307
1308ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a462200 } hitcount:         81  len:      81032
1309ea272257SMauro Carvalho Chehab
1310ea272257SMauro Carvalho Chehab    Totals:
1311ea272257SMauro Carvalho Chehab        Hits: 1451
1312ea272257SMauro Carvalho Chehab        Entries: 318
1313ea272257SMauro Carvalho Chehab        Dropped: 0
1314ea272257SMauro Carvalho Chehab
1315ea272257SMauro Carvalho Chehab
1316ea272257SMauro Carvalho Chehab    # event histogram
1317ea272257SMauro Carvalho Chehab    #
1318ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len == 256 [active]
1319ea272257SMauro Carvalho Chehab    #
1320ea272257SMauro Carvalho Chehab
1321ea272257SMauro Carvalho Chehab
1322ea272257SMauro Carvalho Chehab    Totals:
1323ea272257SMauro Carvalho Chehab        Hits: 0
1324ea272257SMauro Carvalho Chehab        Entries: 0
1325ea272257SMauro Carvalho Chehab        Dropped: 0
1326ea272257SMauro Carvalho Chehab
1327ea272257SMauro Carvalho Chehab
1328ea272257SMauro Carvalho Chehab    # event histogram
1329ea272257SMauro Carvalho Chehab    #
1330ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len > 4096 [active]
1331ea272257SMauro Carvalho Chehab    #
1332ea272257SMauro Carvalho Chehab
1333ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fd2c300 } hitcount:          1  len:       7212
1334ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcce00 } hitcount:          1  len:       7212
1335ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcd700 } hitcount:          1  len:       7212
1336ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcda00 } hitcount:          1  len:      21492
1337ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800ae2e2d00 } hitcount:          1  len:       7212
1338ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcdb00 } hitcount:          1  len:       7212
1339ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a4df500 } hitcount:          1  len:       4854
1340ea272257SMauro Carvalho Chehab    { skbaddr: ffff88008ce47b00 } hitcount:          1  len:      18636
1341ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800ae2e2200 } hitcount:          1  len:      12924
1342ea272257SMauro Carvalho Chehab    { skbaddr: ffff88005f3e1000 } hitcount:          1  len:       4356
1343ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcdc00 } hitcount:          2  len:      24420
1344ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcc200 } hitcount:          2  len:      12996
1345ea272257SMauro Carvalho Chehab
1346ea272257SMauro Carvalho Chehab    Totals:
1347ea272257SMauro Carvalho Chehab        Hits: 14
1348ea272257SMauro Carvalho Chehab        Entries: 12
1349ea272257SMauro Carvalho Chehab        Dropped: 0
1350ea272257SMauro Carvalho Chehab
1351ea272257SMauro Carvalho Chehab
1352ea272257SMauro Carvalho Chehab    # event histogram
1353ea272257SMauro Carvalho Chehab    #
1354ea272257SMauro Carvalho Chehab    # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len < 0 [active]
1355ea272257SMauro Carvalho Chehab    #
1356ea272257SMauro Carvalho Chehab
1357ea272257SMauro Carvalho Chehab
1358ea272257SMauro Carvalho Chehab    Totals:
1359ea272257SMauro Carvalho Chehab        Hits: 0
1360ea272257SMauro Carvalho Chehab        Entries: 0
1361ea272257SMauro Carvalho Chehab        Dropped: 0
1362ea272257SMauro Carvalho Chehab
1363ea272257SMauro Carvalho Chehab  Named triggers can be used to have triggers share a common set of
1364ea272257SMauro Carvalho Chehab  histogram data.  This capability is mostly useful for combining the
1365ea272257SMauro Carvalho Chehab  output of events generated by tracepoints contained inside inline
1366ea272257SMauro Carvalho Chehab  functions, but names can be used in a hist trigger on any event.
1367ea272257SMauro Carvalho Chehab  For example, these two triggers when hit will update the same 'len'
1368ea272257SMauro Carvalho Chehab  field in the shared 'foo' histogram data::
1369ea272257SMauro Carvalho Chehab
1370ea272257SMauro Carvalho Chehab    # echo 'hist:name=foo:keys=skbaddr.hex:vals=len' > \
13712abfcd29SRoss Zwisler           /sys/kernel/tracing/events/net/netif_receive_skb/trigger
1372ea272257SMauro Carvalho Chehab    # echo 'hist:name=foo:keys=skbaddr.hex:vals=len' > \
13732abfcd29SRoss Zwisler           /sys/kernel/tracing/events/net/netif_rx/trigger
1374ea272257SMauro Carvalho Chehab
1375ea272257SMauro Carvalho Chehab  You can see that they're updating common histogram data by reading
1376ea272257SMauro Carvalho Chehab  each event's hist files at the same time::
1377ea272257SMauro Carvalho Chehab
13782abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/net/netif_receive_skb/hist;
13792abfcd29SRoss Zwisler      cat /sys/kernel/tracing/events/net/netif_rx/hist
1380ea272257SMauro Carvalho Chehab
1381ea272257SMauro Carvalho Chehab    # event histogram
1382ea272257SMauro Carvalho Chehab    #
1383ea272257SMauro Carvalho Chehab    # trigger info: hist:name=foo:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active]
1384ea272257SMauro Carvalho Chehab    #
1385ea272257SMauro Carvalho Chehab
1386ea272257SMauro Carvalho Chehab    { skbaddr: ffff88000ad53500 } hitcount:          1  len:         46
1387ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800af5a1500 } hitcount:          1  len:         76
1388ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d62a1900 } hitcount:          1  len:         46
1389ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bccb00 } hitcount:          1  len:        468
1390ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d3c69900 } hitcount:          1  len:         46
1391ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009ff09100 } hitcount:          1  len:         52
1392ea272257SMauro Carvalho Chehab    { skbaddr: ffff88010f13ab00 } hitcount:          1  len:        168
1393ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a54f400 } hitcount:          1  len:         46
1394ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcc500 } hitcount:          1  len:        260
1395ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064505000 } hitcount:          1  len:         46
1396ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800baf24e00 } hitcount:          1  len:         32
1397ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0ad00 } hitcount:          1  len:         46
1398ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d3edff00 } hitcount:          1  len:         44
1399ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0b400 } hitcount:          1  len:        168
1400ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1c55a00 } hitcount:          1  len:         40
1401ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcd100 } hitcount:          1  len:         40
1402ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064505f00 } hitcount:          1  len:        174
1403ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bff200 } hitcount:          1  len:        160
1404ea272257SMauro Carvalho Chehab    { skbaddr: ffff880044e3cc00 } hitcount:          1  len:         76
1405ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bfe700 } hitcount:          1  len:         46
1406ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcdc00 } hitcount:          1  len:         32
1407ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f64800 } hitcount:          1  len:         46
1408ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcde00 } hitcount:          1  len:        988
1409ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a5dea00 } hitcount:          1  len:         46
1410ea272257SMauro Carvalho Chehab    { skbaddr: ffff88002e37a200 } hitcount:          1  len:         44
1411ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f32c00 } hitcount:          2  len:        676
1412ea272257SMauro Carvalho Chehab    { skbaddr: ffff88000ad52600 } hitcount:          2  len:        107
1413ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f91e00 } hitcount:          2  len:         92
1414ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800af5a0200 } hitcount:          2  len:        142
1415ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcc600 } hitcount:          2  len:        220
1416ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800ba36f500 } hitcount:          2  len:         92
1417ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d021f800 } hitcount:          2  len:         92
1418ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f33600 } hitcount:          2  len:        675
1419ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bfff00 } hitcount:          3  len:        138
1420ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d62a1300 } hitcount:          3  len:        138
1421ea272257SMauro Carvalho Chehab    { skbaddr: ffff88002e37a100 } hitcount:          4  len:        184
1422ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064504400 } hitcount:          4  len:        184
1423ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bfec00 } hitcount:          4  len:        184
1424ea272257SMauro Carvalho Chehab    { skbaddr: ffff88000ad53700 } hitcount:          5  len:        230
1425ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcdb00 } hitcount:          5  len:        196
1426ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f90000 } hitcount:          6  len:        276
1427ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a54f900 } hitcount:          6  len:        276
1428ea272257SMauro Carvalho Chehab
1429ea272257SMauro Carvalho Chehab    Totals:
1430ea272257SMauro Carvalho Chehab        Hits: 81
1431ea272257SMauro Carvalho Chehab        Entries: 42
1432ea272257SMauro Carvalho Chehab        Dropped: 0
1433ea272257SMauro Carvalho Chehab    # event histogram
1434ea272257SMauro Carvalho Chehab    #
1435ea272257SMauro Carvalho Chehab    # trigger info: hist:name=foo:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active]
1436ea272257SMauro Carvalho Chehab    #
1437ea272257SMauro Carvalho Chehab
1438ea272257SMauro Carvalho Chehab    { skbaddr: ffff88000ad53500 } hitcount:          1  len:         46
1439ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800af5a1500 } hitcount:          1  len:         76
1440ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d62a1900 } hitcount:          1  len:         46
1441ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bccb00 } hitcount:          1  len:        468
1442ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d3c69900 } hitcount:          1  len:         46
1443ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009ff09100 } hitcount:          1  len:         52
1444ea272257SMauro Carvalho Chehab    { skbaddr: ffff88010f13ab00 } hitcount:          1  len:        168
1445ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a54f400 } hitcount:          1  len:         46
1446ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcc500 } hitcount:          1  len:        260
1447ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064505000 } hitcount:          1  len:         46
1448ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800baf24e00 } hitcount:          1  len:         32
1449ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0ad00 } hitcount:          1  len:         46
1450ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d3edff00 } hitcount:          1  len:         44
1451ea272257SMauro Carvalho Chehab    { skbaddr: ffff88009fe0b400 } hitcount:          1  len:        168
1452ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1c55a00 } hitcount:          1  len:         40
1453ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcd100 } hitcount:          1  len:         40
1454ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064505f00 } hitcount:          1  len:        174
1455ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bff200 } hitcount:          1  len:        160
1456ea272257SMauro Carvalho Chehab    { skbaddr: ffff880044e3cc00 } hitcount:          1  len:         76
1457ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bfe700 } hitcount:          1  len:         46
1458ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcdc00 } hitcount:          1  len:         32
1459ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f64800 } hitcount:          1  len:         46
1460ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcde00 } hitcount:          1  len:        988
1461ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a5dea00 } hitcount:          1  len:         46
1462ea272257SMauro Carvalho Chehab    { skbaddr: ffff88002e37a200 } hitcount:          1  len:         44
1463ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f32c00 } hitcount:          2  len:        676
1464ea272257SMauro Carvalho Chehab    { skbaddr: ffff88000ad52600 } hitcount:          2  len:        107
1465ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f91e00 } hitcount:          2  len:         92
1466ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800af5a0200 } hitcount:          2  len:        142
1467ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcc600 } hitcount:          2  len:        220
1468ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800ba36f500 } hitcount:          2  len:         92
1469ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d021f800 } hitcount:          2  len:         92
1470ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f33600 } hitcount:          2  len:        675
1471ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bfff00 } hitcount:          3  len:        138
1472ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d62a1300 } hitcount:          3  len:        138
1473ea272257SMauro Carvalho Chehab    { skbaddr: ffff88002e37a100 } hitcount:          4  len:        184
1474ea272257SMauro Carvalho Chehab    { skbaddr: ffff880064504400 } hitcount:          4  len:        184
1475ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a8bfec00 } hitcount:          4  len:        184
1476ea272257SMauro Carvalho Chehab    { skbaddr: ffff88000ad53700 } hitcount:          5  len:        230
1477ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800d2bcdb00 } hitcount:          5  len:        196
1478ea272257SMauro Carvalho Chehab    { skbaddr: ffff8800a1f90000 } hitcount:          6  len:        276
1479ea272257SMauro Carvalho Chehab    { skbaddr: ffff88006a54f900 } hitcount:          6  len:        276
1480ea272257SMauro Carvalho Chehab
1481ea272257SMauro Carvalho Chehab    Totals:
1482ea272257SMauro Carvalho Chehab        Hits: 81
1483ea272257SMauro Carvalho Chehab        Entries: 42
1484ea272257SMauro Carvalho Chehab        Dropped: 0
1485ea272257SMauro Carvalho Chehab
1486ea272257SMauro Carvalho Chehab  And here's an example that shows how to combine histogram data from
1487ea272257SMauro Carvalho Chehab  any two events even if they don't share any 'compatible' fields
1488*4b512860SSteven Rostedt (Google)  other than 'hitcount' and 'common_stacktrace'.  These commands create a
1489ea272257SMauro Carvalho Chehab  couple of triggers named 'bar' using those fields::
1490ea272257SMauro Carvalho Chehab
1491*4b512860SSteven Rostedt (Google)    # echo 'hist:name=bar:key=common_stacktrace:val=hitcount' > \
14922abfcd29SRoss Zwisler           /sys/kernel/tracing/events/sched/sched_process_fork/trigger
1493*4b512860SSteven Rostedt (Google)    # echo 'hist:name=bar:key=common_stacktrace:val=hitcount' > \
14942abfcd29SRoss Zwisler          /sys/kernel/tracing/events/net/netif_rx/trigger
1495ea272257SMauro Carvalho Chehab
1496ea272257SMauro Carvalho Chehab  And displaying the output of either shows some interesting if
1497ea272257SMauro Carvalho Chehab  somewhat confusing output::
1498ea272257SMauro Carvalho Chehab
14992abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/sched/sched_process_fork/hist
15002abfcd29SRoss Zwisler    # cat /sys/kernel/tracing/events/net/netif_rx/hist
1501ea272257SMauro Carvalho Chehab
1502ea272257SMauro Carvalho Chehab    # event histogram
1503ea272257SMauro Carvalho Chehab    #
1504*4b512860SSteven Rostedt (Google)    # trigger info: hist:name=bar:keys=common_stacktrace:vals=hitcount:sort=hitcount:size=2048 [active]
1505ea272257SMauro Carvalho Chehab    #
1506ea272257SMauro Carvalho Chehab
1507*4b512860SSteven Rostedt (Google)    { common_stacktrace:
1508eea11285SChristian Brauner             kernel_clone+0x18e/0x330
1509ea272257SMauro Carvalho Chehab             kernel_thread+0x29/0x30
1510ea272257SMauro Carvalho Chehab             kthreadd+0x154/0x1b0
1511ea272257SMauro Carvalho Chehab             ret_from_fork+0x3f/0x70
1512ea272257SMauro Carvalho Chehab    } hitcount:          1
1513*4b512860SSteven Rostedt (Google)    { common_stacktrace:
1514ea272257SMauro Carvalho Chehab             netif_rx_internal+0xb2/0xd0
1515ea272257SMauro Carvalho Chehab             netif_rx_ni+0x20/0x70
1516ea272257SMauro Carvalho Chehab             dev_loopback_xmit+0xaa/0xd0
1517ea272257SMauro Carvalho Chehab             ip_mc_output+0x126/0x240
1518ea272257SMauro Carvalho Chehab             ip_local_out_sk+0x31/0x40
1519ea272257SMauro Carvalho Chehab             igmp_send_report+0x1e9/0x230
1520ea272257SMauro Carvalho Chehab             igmp_timer_expire+0xe9/0x120
1521ea272257SMauro Carvalho Chehab             call_timer_fn+0x39/0xf0
1522ea272257SMauro Carvalho Chehab             run_timer_softirq+0x1e1/0x290
1523ea272257SMauro Carvalho Chehab             __do_softirq+0xfd/0x290
1524ea272257SMauro Carvalho Chehab             irq_exit+0x98/0xb0
1525ea272257SMauro Carvalho Chehab             smp_apic_timer_interrupt+0x4a/0x60
1526ea272257SMauro Carvalho Chehab             apic_timer_interrupt+0x6d/0x80
1527ea272257SMauro Carvalho Chehab             cpuidle_enter+0x17/0x20
1528ea272257SMauro Carvalho Chehab             call_cpuidle+0x3b/0x60
1529ea272257SMauro Carvalho Chehab             cpu_startup_entry+0x22d/0x310
1530ea272257SMauro Carvalho Chehab    } hitcount:          1
1531*4b512860SSteven Rostedt (Google)    { common_stacktrace:
1532ea272257SMauro Carvalho Chehab             netif_rx_internal+0xb2/0xd0
1533ea272257SMauro Carvalho Chehab             netif_rx_ni+0x20/0x70
1534ea272257SMauro Carvalho Chehab             dev_loopback_xmit+0xaa/0xd0
1535ea272257SMauro Carvalho Chehab             ip_mc_output+0x17f/0x240
1536ea272257SMauro Carvalho Chehab             ip_local_out_sk+0x31/0x40
1537ea272257SMauro Carvalho Chehab             ip_send_skb+0x1a/0x50
1538ea272257SMauro Carvalho Chehab             udp_send_skb+0x13e/0x270
1539ea272257SMauro Carvalho Chehab             udp_sendmsg+0x2bf/0x980
1540ea272257SMauro Carvalho Chehab             inet_sendmsg+0x67/0xa0
1541ea272257SMauro Carvalho Chehab             sock_sendmsg+0x38/0x50
1542ea272257SMauro Carvalho Chehab             SYSC_sendto+0xef/0x170
1543ea272257SMauro Carvalho Chehab             SyS_sendto+0xe/0x10
1544ea272257SMauro Carvalho Chehab             entry_SYSCALL_64_fastpath+0x12/0x6a
1545ea272257SMauro Carvalho Chehab    } hitcount:          2
1546*4b512860SSteven Rostedt (Google)    { common_stacktrace:
1547ea272257SMauro Carvalho Chehab             netif_rx_internal+0xb2/0xd0
1548ea272257SMauro Carvalho Chehab             netif_rx+0x1c/0x60
1549ea272257SMauro Carvalho Chehab             loopback_xmit+0x6c/0xb0
1550ea272257SMauro Carvalho Chehab             dev_hard_start_xmit+0x219/0x3a0
1551ea272257SMauro Carvalho Chehab             __dev_queue_xmit+0x415/0x4f0
1552ea272257SMauro Carvalho Chehab             dev_queue_xmit_sk+0x13/0x20
1553ea272257SMauro Carvalho Chehab             ip_finish_output2+0x237/0x340
1554ea272257SMauro Carvalho Chehab             ip_finish_output+0x113/0x1d0
1555ea272257SMauro Carvalho Chehab             ip_output+0x66/0xc0
1556ea272257SMauro Carvalho Chehab             ip_local_out_sk+0x31/0x40
1557ea272257SMauro Carvalho Chehab             ip_send_skb+0x1a/0x50
1558ea272257SMauro Carvalho Chehab             udp_send_skb+0x16d/0x270
1559ea272257SMauro Carvalho Chehab             udp_sendmsg+0x2bf/0x980
1560ea272257SMauro Carvalho Chehab             inet_sendmsg+0x67/0xa0
1561ea272257SMauro Carvalho Chehab             sock_sendmsg+0x38/0x50
1562ea272257SMauro Carvalho Chehab             ___sys_sendmsg+0x14e/0x270
1563ea272257SMauro Carvalho Chehab    } hitcount:         76
1564*4b512860SSteven Rostedt (Google)    { common_stacktrace:
1565ea272257SMauro Carvalho Chehab             netif_rx_internal+0xb2/0xd0
1566ea272257SMauro Carvalho Chehab             netif_rx+0x1c/0x60
1567ea272257SMauro Carvalho Chehab             loopback_xmit+0x6c/0xb0
1568ea272257SMauro Carvalho Chehab             dev_hard_start_xmit+0x219/0x3a0
1569ea272257SMauro Carvalho Chehab             __dev_queue_xmit+0x415/0x4f0
1570ea272257SMauro Carvalho Chehab             dev_queue_xmit_sk+0x13/0x20
1571ea272257SMauro Carvalho Chehab             ip_finish_output2+0x237/0x340
1572ea272257SMauro Carvalho Chehab             ip_finish_output+0x113/0x1d0
1573ea272257SMauro Carvalho Chehab             ip_output+0x66/0xc0
1574ea272257SMauro Carvalho Chehab             ip_local_out_sk+0x31/0x40
1575ea272257SMauro Carvalho Chehab             ip_send_skb+0x1a/0x50
1576ea272257SMauro Carvalho Chehab             udp_send_skb+0x16d/0x270
1577ea272257SMauro Carvalho Chehab             udp_sendmsg+0x2bf/0x980
1578ea272257SMauro Carvalho Chehab             inet_sendmsg+0x67/0xa0
1579ea272257SMauro Carvalho Chehab             sock_sendmsg+0x38/0x50
1580ea272257SMauro Carvalho Chehab             ___sys_sendmsg+0x269/0x270
1581ea272257SMauro Carvalho Chehab    } hitcount:         77
1582*4b512860SSteven Rostedt (Google)    { common_stacktrace:
1583ea272257SMauro Carvalho Chehab             netif_rx_internal+0xb2/0xd0
1584ea272257SMauro Carvalho Chehab             netif_rx+0x1c/0x60
1585ea272257SMauro Carvalho Chehab             loopback_xmit+0x6c/0xb0
1586ea272257SMauro Carvalho Chehab             dev_hard_start_xmit+0x219/0x3a0
1587ea272257SMauro Carvalho Chehab             __dev_queue_xmit+0x415/0x4f0
1588ea272257SMauro Carvalho Chehab             dev_queue_xmit_sk+0x13/0x20
1589ea272257SMauro Carvalho Chehab             ip_finish_output2+0x237/0x340
1590ea272257SMauro Carvalho Chehab             ip_finish_output+0x113/0x1d0
1591ea272257SMauro Carvalho Chehab             ip_output+0x66/0xc0
1592ea272257SMauro Carvalho Chehab             ip_local_out_sk+0x31/0x40
1593ea272257SMauro Carvalho Chehab             ip_send_skb+0x1a/0x50
1594ea272257SMauro Carvalho Chehab             udp_send_skb+0x16d/0x270
1595ea272257SMauro Carvalho Chehab             udp_sendmsg+0x2bf/0x980
1596ea272257SMauro Carvalho Chehab             inet_sendmsg+0x67/0xa0
1597ea272257SMauro Carvalho Chehab             sock_sendmsg+0x38/0x50
1598ea272257SMauro Carvalho Chehab             SYSC_sendto+0xef/0x170
1599ea272257SMauro Carvalho Chehab    } hitcount:         88
1600*4b512860SSteven Rostedt (Google)    { common_stacktrace:
1601eea11285SChristian Brauner             kernel_clone+0x18e/0x330
1602ea272257SMauro Carvalho Chehab             SyS_clone+0x19/0x20
1603ea272257SMauro Carvalho Chehab             entry_SYSCALL_64_fastpath+0x12/0x6a
1604ea272257SMauro Carvalho Chehab    } hitcount:        244
1605ea272257SMauro Carvalho Chehab
1606ea272257SMauro Carvalho Chehab    Totals:
1607ea272257SMauro Carvalho Chehab        Hits: 489
1608ea272257SMauro Carvalho Chehab        Entries: 7
1609ea272257SMauro Carvalho Chehab        Dropped: 0
1610ea272257SMauro Carvalho Chehab
1611ea272257SMauro Carvalho Chehab2.2 Inter-event hist triggers
1612ea272257SMauro Carvalho Chehab-----------------------------
1613ea272257SMauro Carvalho Chehab
1614ea272257SMauro Carvalho ChehabInter-event hist triggers are hist triggers that combine values from
1615ea272257SMauro Carvalho Chehabone or more other events and create a histogram using that data.  Data
1616ea272257SMauro Carvalho Chehabfrom an inter-event histogram can in turn become the source for
1617ea272257SMauro Carvalho Chehabfurther combined histograms, thus providing a chain of related
1618ea272257SMauro Carvalho Chehabhistograms, which is important for some applications.
1619ea272257SMauro Carvalho Chehab
1620ea272257SMauro Carvalho ChehabThe most important example of an inter-event quantity that can be used
1621ea272257SMauro Carvalho Chehabin this manner is latency, which is simply a difference in timestamps
1622ea272257SMauro Carvalho Chehabbetween two events.  Although latency is the most important
1623ea272257SMauro Carvalho Chehabinter-event quantity, note that because the support is completely
1624ea272257SMauro Carvalho Chehabgeneral across the trace event subsystem, any event field can be used
1625ea272257SMauro Carvalho Chehabin an inter-event quantity.
1626ea272257SMauro Carvalho Chehab
1627ea272257SMauro Carvalho ChehabAn example of a histogram that combines data from other histograms
1628ea272257SMauro Carvalho Chehabinto a useful chain would be a 'wakeupswitch latency' histogram that
1629ea272257SMauro Carvalho Chehabcombines a 'wakeup latency' histogram and a 'switch latency'
1630ea272257SMauro Carvalho Chehabhistogram.
1631ea272257SMauro Carvalho Chehab
1632ea272257SMauro Carvalho ChehabNormally, a hist trigger specification consists of a (possibly
1633ea272257SMauro Carvalho Chehabcompound) key along with one or more numeric values, which are
1634ea272257SMauro Carvalho Chehabcontinually updated sums associated with that key.  A histogram
1635ea272257SMauro Carvalho Chehabspecification in this case consists of individual key and value
1636ea272257SMauro Carvalho Chehabspecifications that refer to trace event fields associated with a
1637ea272257SMauro Carvalho Chehabsingle event type.
1638ea272257SMauro Carvalho Chehab
1639ea272257SMauro Carvalho ChehabThe inter-event hist trigger extension allows fields from multiple
1640ea272257SMauro Carvalho Chehabevents to be referenced and combined into a multi-event histogram
1641ea272257SMauro Carvalho Chehabspecification.  In support of this overall goal, a few enabling
1642ea272257SMauro Carvalho Chehabfeatures have been added to the hist trigger support:
1643ea272257SMauro Carvalho Chehab
1644ea272257SMauro Carvalho Chehab  - In order to compute an inter-event quantity, a value from one
1645ea272257SMauro Carvalho Chehab    event needs to saved and then referenced from another event.  This
1646ea272257SMauro Carvalho Chehab    requires the introduction of support for histogram 'variables'.
1647ea272257SMauro Carvalho Chehab
1648ea272257SMauro Carvalho Chehab  - The computation of inter-event quantities and their combination
1649ea272257SMauro Carvalho Chehab    require some minimal amount of support for applying simple
1650ea272257SMauro Carvalho Chehab    expressions to variables (+ and -).
1651ea272257SMauro Carvalho Chehab
1652ea272257SMauro Carvalho Chehab  - A histogram consisting of inter-event quantities isn't logically a
1653ea272257SMauro Carvalho Chehab    histogram on either event (so having the 'hist' file for either
1654ea272257SMauro Carvalho Chehab    event host the histogram output doesn't really make sense).  To
1655ea272257SMauro Carvalho Chehab    address the idea that the histogram is associated with a
1656ea272257SMauro Carvalho Chehab    combination of events, support is added allowing the creation of
1657ea272257SMauro Carvalho Chehab    'synthetic' events that are events derived from other events.
1658ea272257SMauro Carvalho Chehab    These synthetic events are full-fledged events just like any other
1659ea272257SMauro Carvalho Chehab    and can be used as such, as for instance to create the
1660ea272257SMauro Carvalho Chehab    'combination' histograms mentioned previously.
1661ea272257SMauro Carvalho Chehab
1662ea272257SMauro Carvalho Chehab  - A set of 'actions' can be associated with histogram entries -
1663ea272257SMauro Carvalho Chehab    these can be used to generate the previously mentioned synthetic
1664ea272257SMauro Carvalho Chehab    events, but can also be used for other purposes, such as for
1665ea272257SMauro Carvalho Chehab    example saving context when a 'max' latency has been hit.
1666ea272257SMauro Carvalho Chehab
1667ea272257SMauro Carvalho Chehab  - Trace events don't have a 'timestamp' associated with them, but
1668ea272257SMauro Carvalho Chehab    there is an implicit timestamp saved along with an event in the
1669ea272257SMauro Carvalho Chehab    underlying ftrace ring buffer.  This timestamp is now exposed as a
1670ea272257SMauro Carvalho Chehab    a synthetic field named 'common_timestamp' which can be used in
1671ea272257SMauro Carvalho Chehab    histograms as if it were any other event field; it isn't an actual
1672ea272257SMauro Carvalho Chehab    field in the trace format but rather is a synthesized value that
1673ea272257SMauro Carvalho Chehab    nonetheless can be used as if it were an actual field.  By default
1674ea272257SMauro Carvalho Chehab    it is in units of nanoseconds; appending '.usecs' to a
1675ea272257SMauro Carvalho Chehab    common_timestamp field changes the units to microseconds.
1676ea272257SMauro Carvalho Chehab
1677ea272257SMauro Carvalho ChehabA note on inter-event timestamps: If common_timestamp is used in a
1678ea272257SMauro Carvalho Chehabhistogram, the trace buffer is automatically switched over to using
1679ea272257SMauro Carvalho Chehababsolute timestamps and the "global" trace clock, in order to avoid
1680ea272257SMauro Carvalho Chehabbogus timestamp differences with other clocks that aren't coherent
1681ea272257SMauro Carvalho Chehabacross CPUs.  This can be overridden by specifying one of the other
1682ea272257SMauro Carvalho Chehabtrace clocks instead, using the "clock=XXX" hist trigger attribute,
1683ea272257SMauro Carvalho Chehabwhere XXX is any of the clocks listed in the tracing/trace_clock
1684ea272257SMauro Carvalho Chehabpseudo-file.
1685ea272257SMauro Carvalho Chehab
1686ea272257SMauro Carvalho ChehabThese features are described in more detail in the following sections.
1687ea272257SMauro Carvalho Chehab
1688ea272257SMauro Carvalho Chehab2.2.1 Histogram Variables
1689ea272257SMauro Carvalho Chehab-------------------------
1690ea272257SMauro Carvalho Chehab
1691ea272257SMauro Carvalho ChehabVariables are simply named locations used for saving and retrieving
1692ea272257SMauro Carvalho Chehabvalues between matching events.  A 'matching' event is defined as an
1693ea272257SMauro Carvalho Chehabevent that has a matching key - if a variable is saved for a histogram
1694ea272257SMauro Carvalho Chehabentry corresponding to that key, any subsequent event with a matching
1695ea272257SMauro Carvalho Chehabkey can access that variable.
1696ea272257SMauro Carvalho Chehab
1697ea272257SMauro Carvalho ChehabA variable's value is normally available to any subsequent event until
1698ea272257SMauro Carvalho Chehabit is set to something else by a subsequent event.  The one exception
1699ea272257SMauro Carvalho Chehabto that rule is that any variable used in an expression is essentially
1700ea272257SMauro Carvalho Chehab'read-once' - once it's used by an expression in a subsequent event,
1701ea272257SMauro Carvalho Chehabit's reset to its 'unset' state, which means it can't be used again
1702ea272257SMauro Carvalho Chehabunless it's set again.  This ensures not only that an event doesn't
1703ea272257SMauro Carvalho Chehabuse an uninitialized variable in a calculation, but that that variable
1704ea272257SMauro Carvalho Chehabis used only once and not for any unrelated subsequent match.
1705ea272257SMauro Carvalho Chehab
1706ea272257SMauro Carvalho ChehabThe basic syntax for saving a variable is to simply prefix a unique
1707ea272257SMauro Carvalho Chehabvariable name not corresponding to any keyword along with an '=' sign
1708ea272257SMauro Carvalho Chehabto any event field.
1709ea272257SMauro Carvalho Chehab
1710ea272257SMauro Carvalho ChehabEither keys or values can be saved and retrieved in this way.  This
1711ea272257SMauro Carvalho Chehabcreates a variable named 'ts0' for a histogram entry with the key
1712ea272257SMauro Carvalho Chehab'next_pid'::
1713ea272257SMauro Carvalho Chehab
1714ea272257SMauro Carvalho Chehab  # echo 'hist:keys=next_pid:vals=$ts0:ts0=common_timestamp ... >> \
1715ea272257SMauro Carvalho Chehab	event/trigger
1716ea272257SMauro Carvalho Chehab
1717ea272257SMauro Carvalho ChehabThe ts0 variable can be accessed by any subsequent event having the
1718ea272257SMauro Carvalho Chehabsame pid as 'next_pid'.
1719ea272257SMauro Carvalho Chehab
1720ea272257SMauro Carvalho ChehabVariable references are formed by prepending the variable name with
1721ea272257SMauro Carvalho Chehabthe '$' sign.  Thus for example, the ts0 variable above would be
1722ea272257SMauro Carvalho Chehabreferenced as '$ts0' in expressions.
1723ea272257SMauro Carvalho Chehab
1724ea272257SMauro Carvalho ChehabBecause 'vals=' is used, the common_timestamp variable value above
1725ea272257SMauro Carvalho Chehabwill also be summed as a normal histogram value would (though for a
1726ea272257SMauro Carvalho Chehabtimestamp it makes little sense).
1727ea272257SMauro Carvalho Chehab
1728ea272257SMauro Carvalho ChehabThe below shows that a key value can also be saved in the same way::
1729ea272257SMauro Carvalho Chehab
1730ea272257SMauro Carvalho Chehab  # echo 'hist:timer_pid=common_pid:key=timer_pid ...' >> event/trigger
1731ea272257SMauro Carvalho Chehab
1732ea272257SMauro Carvalho ChehabIf a variable isn't a key variable or prefixed with 'vals=', the
1733ea272257SMauro Carvalho Chehabassociated event field will be saved in a variable but won't be summed
1734ea272257SMauro Carvalho Chehabas a value::
1735ea272257SMauro Carvalho Chehab
1736ea272257SMauro Carvalho Chehab  # echo 'hist:keys=next_pid:ts1=common_timestamp ...' >> event/trigger
1737ea272257SMauro Carvalho Chehab
1738ea272257SMauro Carvalho ChehabMultiple variables can be assigned at the same time.  The below would
1739ea272257SMauro Carvalho Chehabresult in both ts0 and b being created as variables, with both
1740ea272257SMauro Carvalho Chehabcommon_timestamp and field1 additionally being summed as values::
1741ea272257SMauro Carvalho Chehab
1742ea272257SMauro Carvalho Chehab  # echo 'hist:keys=pid:vals=$ts0,$b:ts0=common_timestamp,b=field1 ...' >> \
1743ea272257SMauro Carvalho Chehab	event/trigger
1744ea272257SMauro Carvalho Chehab
1745ea272257SMauro Carvalho ChehabNote that variable assignments can appear either preceding or
1746ea272257SMauro Carvalho Chehabfollowing their use.  The command below behaves identically to the
1747ea272257SMauro Carvalho Chehabcommand above::
1748ea272257SMauro Carvalho Chehab
1749ea272257SMauro Carvalho Chehab  # echo 'hist:keys=pid:ts0=common_timestamp,b=field1:vals=$ts0,$b ...' >> \
1750ea272257SMauro Carvalho Chehab	event/trigger
1751ea272257SMauro Carvalho Chehab
1752ea272257SMauro Carvalho ChehabAny number of variables not bound to a 'vals=' prefix can also be
1753ea272257SMauro Carvalho Chehabassigned by simply separating them with colons.  Below is the same
1754ea272257SMauro Carvalho Chehabthing but without the values being summed in the histogram::
1755ea272257SMauro Carvalho Chehab
1756ea272257SMauro Carvalho Chehab  # echo 'hist:keys=pid:ts0=common_timestamp:b=field1 ...' >> event/trigger
1757ea272257SMauro Carvalho Chehab
1758ea272257SMauro Carvalho ChehabVariables set as above can be referenced and used in expressions on
1759ea272257SMauro Carvalho Chehabanother event.
1760ea272257SMauro Carvalho Chehab
1761ea272257SMauro Carvalho ChehabFor example, here's how a latency can be calculated::
1762ea272257SMauro Carvalho Chehab
1763ea272257SMauro Carvalho Chehab  # echo 'hist:keys=pid,prio:ts0=common_timestamp ...' >> event1/trigger
1764ea272257SMauro Carvalho Chehab  # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp-$ts0 ...' >> event2/trigger
1765ea272257SMauro Carvalho Chehab
1766aea74de4SMasanari IidaIn the first line above, the event's timestamp is saved into the
1767ea272257SMauro Carvalho Chehabvariable ts0.  In the next line, ts0 is subtracted from the second
1768ea272257SMauro Carvalho Chehabevent's timestamp to produce the latency, which is then assigned into
1769ea272257SMauro Carvalho Chehabyet another variable, 'wakeup_lat'.  The hist trigger below in turn
1770ea272257SMauro Carvalho Chehabmakes use of the wakeup_lat variable to compute a combined latency
1771ea272257SMauro Carvalho Chehabusing the same key and variable from yet another event::
1772ea272257SMauro Carvalho Chehab
1773ea272257SMauro Carvalho Chehab  # echo 'hist:key=pid:wakeupswitch_lat=$wakeup_lat+$switchtime_lat ...' >> event3/trigger
1774ea272257SMauro Carvalho Chehab
17752d2f6d4bSKalesh SinghExpressions support the use of addition, subtraction, multiplication and
177693d76e4aSKalesh Singhdivision operators (+-\*/).
17772d2f6d4bSKalesh Singh
17780ca6d12cSKalesh SinghNote if division by zero cannot be detected at parse time (i.e. the
17790ca6d12cSKalesh Singhdivisor is not a constant), the result will be -1.
17802d2f6d4bSKalesh Singh
17812d2f6d4bSKalesh SinghNumeric constants can also be used directly in an expression::
17822d2f6d4bSKalesh Singh
17832d2f6d4bSKalesh Singh  # echo 'hist:keys=next_pid:timestamp_secs=common_timestamp/1000000 ...' >> event/trigger
17842d2f6d4bSKalesh Singh
17852d2f6d4bSKalesh Singhor assigned to a variable and referenced in a subsequent expression::
17862d2f6d4bSKalesh Singh
17872d2f6d4bSKalesh Singh  # echo 'hist:keys=next_pid:us_per_sec=1000000 ...' >> event/trigger
17882d2f6d4bSKalesh Singh  # echo 'hist:keys=next_pid:timestamp_secs=common_timestamp/$us_per_sec ...' >> event/trigger
17892d2f6d4bSKalesh Singh
179088238513SSteven Rostedt (Google)Variables can even hold stacktraces, which are useful with synthetic events.
179188238513SSteven Rostedt (Google)
1792ea272257SMauro Carvalho Chehab2.2.2 Synthetic Events
1793ea272257SMauro Carvalho Chehab----------------------
1794ea272257SMauro Carvalho Chehab
1795ea272257SMauro Carvalho ChehabSynthetic events are user-defined events generated from hist trigger
1796ea272257SMauro Carvalho Chehabvariables or fields associated with one or more other events.  Their
1797ea272257SMauro Carvalho Chehabpurpose is to provide a mechanism for displaying data spanning
1798ea272257SMauro Carvalho Chehabmultiple events consistent with the existing and already familiar
1799ea272257SMauro Carvalho Chehabusage for normal events.
1800ea272257SMauro Carvalho Chehab
1801ea272257SMauro Carvalho ChehabTo define a synthetic event, the user writes a simple specification
1802ea272257SMauro Carvalho Chehabconsisting of the name of the new event along with one or more
1803ea272257SMauro Carvalho Chehabvariables and their types, which can be any valid field type,
1804ea272257SMauro Carvalho Chehabseparated by semicolons, to the tracing/synthetic_events file.
1805ea272257SMauro Carvalho Chehab
1806bd82631dSTom ZanussiSee synth_field_size() for available types.
1807bd82631dSTom Zanussi
1808bd82631dSTom ZanussiIf field_name contains [n], the field is considered to be a static array.
1809bd82631dSTom Zanussi
1810bd82631dSTom ZanussiIf field_names contains[] (no subscript), the field is considered to
1811bd82631dSTom Zanussibe a dynamic array, which will only take as much space in the event as
1812bd82631dSTom Zanussiis required to hold the array.
1813bd82631dSTom Zanussi
1814bd82631dSTom ZanussiA string field can be specified using either the static notation:
1815bd82631dSTom Zanussi
1816bd82631dSTom Zanussi  char name[32];
1817bd82631dSTom Zanussi
1818bd82631dSTom ZanussiOr the dynamic:
1819bd82631dSTom Zanussi
1820bd82631dSTom Zanussi  char name[];
1821bd82631dSTom Zanussi
1822bd82631dSTom ZanussiThe size limit for either is 256.
1823bd82631dSTom Zanussi
1824ea272257SMauro Carvalho ChehabFor instance, the following creates a new event named 'wakeup_latency'
1825ea272257SMauro Carvalho Chehabwith 3 fields: lat, pid, and prio.  Each of those fields is simply a
1826ea272257SMauro Carvalho Chehabvariable reference to a variable on another event::
1827ea272257SMauro Carvalho Chehab
1828ea272257SMauro Carvalho Chehab  # echo 'wakeup_latency \
1829ea272257SMauro Carvalho Chehab          u64 lat; \
1830ea272257SMauro Carvalho Chehab          pid_t pid; \
1831ea272257SMauro Carvalho Chehab	  int prio' >> \
18322abfcd29SRoss Zwisler	  /sys/kernel/tracing/synthetic_events
1833ea272257SMauro Carvalho Chehab
1834ea272257SMauro Carvalho ChehabReading the tracing/synthetic_events file lists all the currently
1835ea272257SMauro Carvalho Chehabdefined synthetic events, in this case the event defined above::
1836ea272257SMauro Carvalho Chehab
18372abfcd29SRoss Zwisler  # cat /sys/kernel/tracing/synthetic_events
1838ea272257SMauro Carvalho Chehab    wakeup_latency u64 lat; pid_t pid; int prio
1839ea272257SMauro Carvalho Chehab
1840ea272257SMauro Carvalho ChehabAn existing synthetic event definition can be removed by prepending
1841ea272257SMauro Carvalho Chehabthe command that defined it with a '!'::
1842ea272257SMauro Carvalho Chehab
1843ea272257SMauro Carvalho Chehab  # echo '!wakeup_latency u64 lat pid_t pid int prio' >> \
18442abfcd29SRoss Zwisler    /sys/kernel/tracing/synthetic_events
1845ea272257SMauro Carvalho Chehab
1846ea272257SMauro Carvalho ChehabAt this point, there isn't yet an actual 'wakeup_latency' event
1847aea74de4SMasanari Iidainstantiated in the event subsystem - for this to happen, a 'hist
1848ea272257SMauro Carvalho Chehabtrigger action' needs to be instantiated and bound to actual fields
1849ea272257SMauro Carvalho Chehaband variables defined on other events (see Section 2.2.3 below on
1850ea272257SMauro Carvalho Chehabhow that is done using hist trigger 'onmatch' action). Once that is
1851ea272257SMauro Carvalho Chehabdone, the 'wakeup_latency' synthetic event instance is created.
1852ea272257SMauro Carvalho Chehab
1853ea272257SMauro Carvalho ChehabThe new event is created under the tracing/events/synthetic/ directory
1854ea272257SMauro Carvalho Chehaband looks and behaves just like any other event::
1855ea272257SMauro Carvalho Chehab
18562abfcd29SRoss Zwisler  # ls /sys/kernel/tracing/events/synthetic/wakeup_latency
1857ea272257SMauro Carvalho Chehab        enable  filter  format  hist  id  trigger
1858ea272257SMauro Carvalho Chehab
185937036435SSteven Rostedt (VMware)A histogram can now be defined for the new synthetic event::
186037036435SSteven Rostedt (VMware)
186137036435SSteven Rostedt (VMware)  # echo 'hist:keys=pid,prio,lat.log2:sort=lat' >> \
18622abfcd29SRoss Zwisler        /sys/kernel/tracing/events/synthetic/wakeup_latency/trigger
186337036435SSteven Rostedt (VMware)
186437036435SSteven Rostedt (VMware)The above shows the latency "lat" in a power of 2 grouping.
186537036435SSteven Rostedt (VMware)
1866ea272257SMauro Carvalho ChehabLike any other event, once a histogram is enabled for the event, the
1867a2ff84a5SBagas Sanjayaoutput can be displayed by reading the event's 'hist' file::
1868ea272257SMauro Carvalho Chehab
18692abfcd29SRoss Zwisler  # cat /sys/kernel/tracing/events/synthetic/wakeup_latency/hist
187037036435SSteven Rostedt (VMware)
187137036435SSteven Rostedt (VMware)  # event histogram
187237036435SSteven Rostedt (VMware)  #
187337036435SSteven Rostedt (VMware)  # trigger info: hist:keys=pid,prio,lat.log2:vals=hitcount:sort=lat.log2:size=2048 [active]
187437036435SSteven Rostedt (VMware)  #
187537036435SSteven Rostedt (VMware)
187637036435SSteven Rostedt (VMware)  { pid:       2035, prio:          9, lat: ~ 2^2  } hitcount:         43
187737036435SSteven Rostedt (VMware)  { pid:       2034, prio:          9, lat: ~ 2^2  } hitcount:         60
187837036435SSteven Rostedt (VMware)  { pid:       2029, prio:          9, lat: ~ 2^2  } hitcount:        965
187937036435SSteven Rostedt (VMware)  { pid:       2034, prio:        120, lat: ~ 2^2  } hitcount:          9
188037036435SSteven Rostedt (VMware)  { pid:       2033, prio:        120, lat: ~ 2^2  } hitcount:          5
188137036435SSteven Rostedt (VMware)  { pid:       2030, prio:          9, lat: ~ 2^2  } hitcount:        335
188237036435SSteven Rostedt (VMware)  { pid:       2030, prio:        120, lat: ~ 2^2  } hitcount:         10
188337036435SSteven Rostedt (VMware)  { pid:       2032, prio:        120, lat: ~ 2^2  } hitcount:          1
188437036435SSteven Rostedt (VMware)  { pid:       2035, prio:        120, lat: ~ 2^2  } hitcount:          2
188537036435SSteven Rostedt (VMware)  { pid:       2031, prio:          9, lat: ~ 2^2  } hitcount:        176
188637036435SSteven Rostedt (VMware)  { pid:       2028, prio:        120, lat: ~ 2^2  } hitcount:         15
188737036435SSteven Rostedt (VMware)  { pid:       2033, prio:          9, lat: ~ 2^2  } hitcount:         91
188837036435SSteven Rostedt (VMware)  { pid:       2032, prio:          9, lat: ~ 2^2  } hitcount:        125
188937036435SSteven Rostedt (VMware)  { pid:       2029, prio:        120, lat: ~ 2^2  } hitcount:          4
189037036435SSteven Rostedt (VMware)  { pid:       2031, prio:        120, lat: ~ 2^2  } hitcount:          3
189137036435SSteven Rostedt (VMware)  { pid:       2029, prio:        120, lat: ~ 2^3  } hitcount:          2
189237036435SSteven Rostedt (VMware)  { pid:       2035, prio:          9, lat: ~ 2^3  } hitcount:         41
189337036435SSteven Rostedt (VMware)  { pid:       2030, prio:        120, lat: ~ 2^3  } hitcount:          1
189437036435SSteven Rostedt (VMware)  { pid:       2032, prio:          9, lat: ~ 2^3  } hitcount:         32
189537036435SSteven Rostedt (VMware)  { pid:       2031, prio:          9, lat: ~ 2^3  } hitcount:         44
189637036435SSteven Rostedt (VMware)  { pid:       2034, prio:          9, lat: ~ 2^3  } hitcount:         40
189737036435SSteven Rostedt (VMware)  { pid:       2030, prio:          9, lat: ~ 2^3  } hitcount:         29
189837036435SSteven Rostedt (VMware)  { pid:       2033, prio:          9, lat: ~ 2^3  } hitcount:         31
189937036435SSteven Rostedt (VMware)  { pid:       2029, prio:          9, lat: ~ 2^3  } hitcount:         31
190037036435SSteven Rostedt (VMware)  { pid:       2028, prio:        120, lat: ~ 2^3  } hitcount:         18
190137036435SSteven Rostedt (VMware)  { pid:       2031, prio:        120, lat: ~ 2^3  } hitcount:          2
190237036435SSteven Rostedt (VMware)  { pid:       2028, prio:        120, lat: ~ 2^4  } hitcount:          1
190337036435SSteven Rostedt (VMware)  { pid:       2029, prio:          9, lat: ~ 2^4  } hitcount:          4
190437036435SSteven Rostedt (VMware)  { pid:       2031, prio:        120, lat: ~ 2^7  } hitcount:          1
190537036435SSteven Rostedt (VMware)  { pid:       2032, prio:        120, lat: ~ 2^7  } hitcount:          1
190637036435SSteven Rostedt (VMware)
190737036435SSteven Rostedt (VMware)  Totals:
190837036435SSteven Rostedt (VMware)      Hits: 2122
190937036435SSteven Rostedt (VMware)      Entries: 30
191037036435SSteven Rostedt (VMware)      Dropped: 0
191137036435SSteven Rostedt (VMware)
191237036435SSteven Rostedt (VMware)
191337036435SSteven Rostedt (VMware)The latency values can also be grouped linearly by a given size with
1914a2ff84a5SBagas Sanjayathe ".buckets" modifier and specify a size (in this case groups of 10)::
191537036435SSteven Rostedt (VMware)
191637036435SSteven Rostedt (VMware)  # echo 'hist:keys=pid,prio,lat.buckets=10:sort=lat' >> \
19172abfcd29SRoss Zwisler        /sys/kernel/tracing/events/synthetic/wakeup_latency/trigger
191837036435SSteven Rostedt (VMware)
191937036435SSteven Rostedt (VMware)  # event histogram
192037036435SSteven Rostedt (VMware)  #
192137036435SSteven Rostedt (VMware)  # trigger info: hist:keys=pid,prio,lat.buckets=10:vals=hitcount:sort=lat.buckets=10:size=2048 [active]
192237036435SSteven Rostedt (VMware)  #
192337036435SSteven Rostedt (VMware)
192437036435SSteven Rostedt (VMware)  { pid:       2067, prio:          9, lat: ~ 0-9 } hitcount:        220
192537036435SSteven Rostedt (VMware)  { pid:       2068, prio:          9, lat: ~ 0-9 } hitcount:        157
192637036435SSteven Rostedt (VMware)  { pid:       2070, prio:          9, lat: ~ 0-9 } hitcount:        100
192737036435SSteven Rostedt (VMware)  { pid:       2067, prio:        120, lat: ~ 0-9 } hitcount:          6
192837036435SSteven Rostedt (VMware)  { pid:       2065, prio:        120, lat: ~ 0-9 } hitcount:          2
192937036435SSteven Rostedt (VMware)  { pid:       2066, prio:        120, lat: ~ 0-9 } hitcount:          2
193037036435SSteven Rostedt (VMware)  { pid:       2069, prio:          9, lat: ~ 0-9 } hitcount:        122
193137036435SSteven Rostedt (VMware)  { pid:       2069, prio:        120, lat: ~ 0-9 } hitcount:          8
193237036435SSteven Rostedt (VMware)  { pid:       2070, prio:        120, lat: ~ 0-9 } hitcount:          1
193337036435SSteven Rostedt (VMware)  { pid:       2068, prio:        120, lat: ~ 0-9 } hitcount:          7
193437036435SSteven Rostedt (VMware)  { pid:       2066, prio:          9, lat: ~ 0-9 } hitcount:        365
193537036435SSteven Rostedt (VMware)  { pid:       2064, prio:        120, lat: ~ 0-9 } hitcount:         35
193637036435SSteven Rostedt (VMware)  { pid:       2065, prio:          9, lat: ~ 0-9 } hitcount:        998
193737036435SSteven Rostedt (VMware)  { pid:       2071, prio:          9, lat: ~ 0-9 } hitcount:         85
193837036435SSteven Rostedt (VMware)  { pid:       2065, prio:          9, lat: ~ 10-19 } hitcount:          2
193937036435SSteven Rostedt (VMware)  { pid:       2064, prio:        120, lat: ~ 10-19 } hitcount:          2
194037036435SSteven Rostedt (VMware)
194137036435SSteven Rostedt (VMware)  Totals:
194237036435SSteven Rostedt (VMware)      Hits: 2112
194337036435SSteven Rostedt (VMware)      Entries: 16
194437036435SSteven Rostedt (VMware)      Dropped: 0
194537036435SSteven Rostedt (VMware)
194688238513SSteven Rostedt (Google)To save stacktraces, create a synthetic event with a field of type "unsigned long[]"
194788238513SSteven Rostedt (Google)or even just "long[]". For example, to see how long a task is blocked in an
1948a2ff84a5SBagas Sanjayauninterruptible state::
194988238513SSteven Rostedt (Google)
195088238513SSteven Rostedt (Google)  # cd /sys/kernel/tracing
195188238513SSteven Rostedt (Google)  # echo 's:block_lat pid_t pid; u64 delta; unsigned long[] stack;' > dynamic_events
1952*4b512860SSteven Rostedt (Google)  # echo 'hist:keys=next_pid:ts=common_timestamp.usecs,st=common_stacktrace  if prev_state == 2' >> events/sched/sched_switch/trigger
195388238513SSteven Rostedt (Google)  # echo 'hist:keys=prev_pid:delta=common_timestamp.usecs-$ts,s=$st:onmax($delta).trace(block_lat,prev_pid,$delta,$s)' >> events/sched/sched_switch/trigger
195488238513SSteven Rostedt (Google)  # echo 1 > events/synthetic/block_lat/enable
195588238513SSteven Rostedt (Google)  # cat trace
195688238513SSteven Rostedt (Google)
195788238513SSteven Rostedt (Google)  # tracer: nop
195888238513SSteven Rostedt (Google)  #
195988238513SSteven Rostedt (Google)  # entries-in-buffer/entries-written: 2/2   #P:8
196088238513SSteven Rostedt (Google)  #
196188238513SSteven Rostedt (Google)  #                                _-----=> irqs-off/BH-disabled
196288238513SSteven Rostedt (Google)  #                               / _----=> need-resched
196388238513SSteven Rostedt (Google)  #                              | / _---=> hardirq/softirq
196488238513SSteven Rostedt (Google)  #                              || / _--=> preempt-depth
196588238513SSteven Rostedt (Google)  #                              ||| / _-=> migrate-disable
196688238513SSteven Rostedt (Google)  #                              |||| /     delay
196788238513SSteven Rostedt (Google)  #           TASK-PID     CPU#  |||||  TIMESTAMP  FUNCTION
196888238513SSteven Rostedt (Google)  #              | |         |   |||||     |         |
196988238513SSteven Rostedt (Google)            <idle>-0       [005] d..4.   521.164922: block_lat: pid=0 delta=8322 stack=STACK:
197088238513SSteven Rostedt (Google)  => __schedule+0x448/0x7b0
197188238513SSteven Rostedt (Google)  => schedule+0x5a/0xb0
197288238513SSteven Rostedt (Google)  => io_schedule+0x42/0x70
197388238513SSteven Rostedt (Google)  => bit_wait_io+0xd/0x60
197488238513SSteven Rostedt (Google)  => __wait_on_bit+0x4b/0x140
197588238513SSteven Rostedt (Google)  => out_of_line_wait_on_bit+0x91/0xb0
197688238513SSteven Rostedt (Google)  => jbd2_journal_commit_transaction+0x1679/0x1a70
197788238513SSteven Rostedt (Google)  => kjournald2+0xa9/0x280
197888238513SSteven Rostedt (Google)  => kthread+0xe9/0x110
197988238513SSteven Rostedt (Google)  => ret_from_fork+0x2c/0x50
198088238513SSteven Rostedt (Google)
198188238513SSteven Rostedt (Google)             <...>-2       [004] d..4.   525.184257: block_lat: pid=2 delta=76 stack=STACK:
198288238513SSteven Rostedt (Google)  => __schedule+0x448/0x7b0
198388238513SSteven Rostedt (Google)  => schedule+0x5a/0xb0
198488238513SSteven Rostedt (Google)  => schedule_timeout+0x11a/0x150
198588238513SSteven Rostedt (Google)  => wait_for_completion_killable+0x144/0x1f0
198688238513SSteven Rostedt (Google)  => __kthread_create_on_node+0xe7/0x1e0
198788238513SSteven Rostedt (Google)  => kthread_create_on_node+0x51/0x70
198888238513SSteven Rostedt (Google)  => create_worker+0xcc/0x1a0
198988238513SSteven Rostedt (Google)  => worker_thread+0x2ad/0x380
199088238513SSteven Rostedt (Google)  => kthread+0xe9/0x110
199188238513SSteven Rostedt (Google)  => ret_from_fork+0x2c/0x50
199288238513SSteven Rostedt (Google)
1993a2ff84a5SBagas SanjayaA synthetic event that has a stacktrace field may use it as a key in
1994a2ff84a5SBagas Sanjayahistogram::
199588238513SSteven Rostedt (Google)
1996d8f0ae3eSTom Zanussi  # echo 'hist:keys=delta.buckets=100,stack.stacktrace:sort=delta' > events/synthetic/block_lat/trigger
199788238513SSteven Rostedt (Google)  # cat events/synthetic/block_lat/hist
199888238513SSteven Rostedt (Google)
199988238513SSteven Rostedt (Google)  # event histogram
200088238513SSteven Rostedt (Google)  #
2001d8f0ae3eSTom Zanussi  # trigger info: hist:keys=delta.buckets=100,stack.stacktrace:vals=hitcount:sort=delta.buckets=100:size=2048 [active]
200288238513SSteven Rostedt (Google)  #
2003d8f0ae3eSTom Zanussi  { delta: ~ 0-99, stack.stacktrace         __schedule+0xa19/0x1520
2004d8f0ae3eSTom Zanussi         schedule+0x6b/0x110
2005d8f0ae3eSTom Zanussi         io_schedule+0x46/0x80
2006d8f0ae3eSTom Zanussi         bit_wait_io+0x11/0x80
2007d8f0ae3eSTom Zanussi         __wait_on_bit+0x4e/0x120
2008d8f0ae3eSTom Zanussi         out_of_line_wait_on_bit+0x8d/0xb0
2009d8f0ae3eSTom Zanussi         __wait_on_buffer+0x33/0x40
2010d8f0ae3eSTom Zanussi         jbd2_journal_commit_transaction+0x155a/0x19b0
2011d8f0ae3eSTom Zanussi         kjournald2+0xab/0x270
2012d8f0ae3eSTom Zanussi         kthread+0xfa/0x130
2013d8f0ae3eSTom Zanussi         ret_from_fork+0x29/0x50
201488238513SSteven Rostedt (Google)  } hitcount:          1
2015d8f0ae3eSTom Zanussi  { delta: ~ 0-99, stack.stacktrace         __schedule+0xa19/0x1520
2016d8f0ae3eSTom Zanussi         schedule+0x6b/0x110
2017d8f0ae3eSTom Zanussi         io_schedule+0x46/0x80
2018d8f0ae3eSTom Zanussi         rq_qos_wait+0xd0/0x170
2019d8f0ae3eSTom Zanussi         wbt_wait+0x9e/0xf0
2020d8f0ae3eSTom Zanussi         __rq_qos_throttle+0x25/0x40
2021d8f0ae3eSTom Zanussi         blk_mq_submit_bio+0x2c3/0x5b0
2022d8f0ae3eSTom Zanussi         __submit_bio+0xff/0x190
2023d8f0ae3eSTom Zanussi         submit_bio_noacct_nocheck+0x25b/0x2b0
2024d8f0ae3eSTom Zanussi         submit_bio_noacct+0x20b/0x600
2025d8f0ae3eSTom Zanussi         submit_bio+0x28/0x90
2026d8f0ae3eSTom Zanussi         ext4_bio_write_page+0x1e0/0x8c0
2027d8f0ae3eSTom Zanussi         mpage_submit_page+0x60/0x80
2028d8f0ae3eSTom Zanussi         mpage_process_page_bufs+0x16c/0x180
2029d8f0ae3eSTom Zanussi         mpage_prepare_extent_to_map+0x23f/0x530
2030d8f0ae3eSTom Zanussi  } hitcount:          1
2031d8f0ae3eSTom Zanussi  { delta: ~ 0-99, stack.stacktrace         __schedule+0xa19/0x1520
2032d8f0ae3eSTom Zanussi         schedule+0x6b/0x110
2033d8f0ae3eSTom Zanussi         schedule_hrtimeout_range_clock+0x97/0x110
2034d8f0ae3eSTom Zanussi         schedule_hrtimeout_range+0x13/0x20
2035d8f0ae3eSTom Zanussi         usleep_range_state+0x65/0x90
2036d8f0ae3eSTom Zanussi         __intel_wait_for_register+0x1c1/0x230 [i915]
2037d8f0ae3eSTom Zanussi         intel_psr_wait_for_idle_locked+0x171/0x2a0 [i915]
2038d8f0ae3eSTom Zanussi         intel_pipe_update_start+0x169/0x360 [i915]
2039d8f0ae3eSTom Zanussi         intel_update_crtc+0x112/0x490 [i915]
2040d8f0ae3eSTom Zanussi         skl_commit_modeset_enables+0x199/0x600 [i915]
2041d8f0ae3eSTom Zanussi         intel_atomic_commit_tail+0x7c4/0x1080 [i915]
2042d8f0ae3eSTom Zanussi         intel_atomic_commit_work+0x12/0x20 [i915]
2043d8f0ae3eSTom Zanussi         process_one_work+0x21c/0x3f0
2044d8f0ae3eSTom Zanussi         worker_thread+0x50/0x3e0
2045d8f0ae3eSTom Zanussi         kthread+0xfa/0x130
2046d8f0ae3eSTom Zanussi  } hitcount:          3
2047d8f0ae3eSTom Zanussi  { delta: ~ 0-99, stack.stacktrace         __schedule+0xa19/0x1520
2048d8f0ae3eSTom Zanussi         schedule+0x6b/0x110
2049d8f0ae3eSTom Zanussi         schedule_timeout+0x11e/0x160
2050d8f0ae3eSTom Zanussi         __wait_for_common+0x8f/0x190
2051d8f0ae3eSTom Zanussi         wait_for_completion+0x24/0x30
2052d8f0ae3eSTom Zanussi         __flush_work.isra.0+0x1cc/0x360
2053d8f0ae3eSTom Zanussi         flush_work+0xe/0x20
2054d8f0ae3eSTom Zanussi         drm_mode_rmfb+0x18b/0x1d0 [drm]
2055d8f0ae3eSTom Zanussi         drm_mode_rmfb_ioctl+0x10/0x20 [drm]
2056d8f0ae3eSTom Zanussi         drm_ioctl_kernel+0xb8/0x150 [drm]
2057d8f0ae3eSTom Zanussi         drm_ioctl+0x243/0x560 [drm]
2058d8f0ae3eSTom Zanussi         __x64_sys_ioctl+0x92/0xd0
2059d8f0ae3eSTom Zanussi         do_syscall_64+0x59/0x90
2060d8f0ae3eSTom Zanussi         entry_SYSCALL_64_after_hwframe+0x72/0xdc
2061d8f0ae3eSTom Zanussi  } hitcount:          1
2062d8f0ae3eSTom Zanussi  { delta: ~ 0-99, stack.stacktrace         __schedule+0xa19/0x1520
2063d8f0ae3eSTom Zanussi         schedule+0x6b/0x110
2064d8f0ae3eSTom Zanussi         schedule_timeout+0x87/0x160
2065d8f0ae3eSTom Zanussi         __wait_for_common+0x8f/0x190
2066d8f0ae3eSTom Zanussi         wait_for_completion_timeout+0x1d/0x30
2067d8f0ae3eSTom Zanussi         drm_atomic_helper_wait_for_flip_done+0x57/0x90 [drm_kms_helper]
2068d8f0ae3eSTom Zanussi         intel_atomic_commit_tail+0x8ce/0x1080 [i915]
2069d8f0ae3eSTom Zanussi         intel_atomic_commit_work+0x12/0x20 [i915]
2070d8f0ae3eSTom Zanussi         process_one_work+0x21c/0x3f0
2071d8f0ae3eSTom Zanussi         worker_thread+0x50/0x3e0
2072d8f0ae3eSTom Zanussi         kthread+0xfa/0x130
2073d8f0ae3eSTom Zanussi         ret_from_fork+0x29/0x50
2074d8f0ae3eSTom Zanussi  } hitcount:          1
2075d8f0ae3eSTom Zanussi  { delta: ~ 100-199, stack.stacktrace         __schedule+0xa19/0x1520
2076d8f0ae3eSTom Zanussi         schedule+0x6b/0x110
2077d8f0ae3eSTom Zanussi         schedule_hrtimeout_range_clock+0x97/0x110
2078d8f0ae3eSTom Zanussi         schedule_hrtimeout_range+0x13/0x20
2079d8f0ae3eSTom Zanussi         usleep_range_state+0x65/0x90
2080d8f0ae3eSTom Zanussi         pci_set_low_power_state+0x17f/0x1f0
2081d8f0ae3eSTom Zanussi         pci_set_power_state+0x49/0x250
2082d8f0ae3eSTom Zanussi         pci_finish_runtime_suspend+0x4a/0x90
2083d8f0ae3eSTom Zanussi         pci_pm_runtime_suspend+0xcb/0x1b0
2084d8f0ae3eSTom Zanussi         __rpm_callback+0x48/0x120
2085d8f0ae3eSTom Zanussi         rpm_callback+0x67/0x70
2086d8f0ae3eSTom Zanussi         rpm_suspend+0x167/0x780
2087d8f0ae3eSTom Zanussi         rpm_idle+0x25a/0x380
2088d8f0ae3eSTom Zanussi         pm_runtime_work+0x93/0xc0
2089d8f0ae3eSTom Zanussi         process_one_work+0x21c/0x3f0
209088238513SSteven Rostedt (Google)  } hitcount:          1
209188238513SSteven Rostedt (Google)
209288238513SSteven Rostedt (Google)  Totals:
2093d8f0ae3eSTom Zanussi    Hits: 10
2094d8f0ae3eSTom Zanussi    Entries: 7
209588238513SSteven Rostedt (Google)    Dropped: 0
209688238513SSteven Rostedt (Google)
20975032b381STom Zanussi2.2.3 Hist trigger 'handlers' and 'actions'
20985032b381STom Zanussi-------------------------------------------
2099ea272257SMauro Carvalho Chehab
21005032b381STom ZanussiA hist trigger 'action' is a function that's executed (in most cases
21015032b381STom Zanussiconditionally) whenever a histogram entry is added or updated.
2102ea272257SMauro Carvalho Chehab
21035032b381STom ZanussiWhen a histogram entry is added or updated, a hist trigger 'handler'
21045032b381STom Zanussiis what decides whether the corresponding action is actually invoked
21055032b381STom Zanussior not.
2106ea272257SMauro Carvalho Chehab
21075032b381STom ZanussiHist trigger handlers and actions are paired together in the general
21085032b381STom Zanussiform:
21095032b381STom Zanussi
21105032b381STom Zanussi  <handler>.<action>
21115032b381STom Zanussi
21125032b381STom ZanussiTo specify a handler.action pair for a given event, simply specify
21135032b381STom Zanussithat handler.action pair between colons in the hist trigger
21145032b381STom Zanussispecification.
21155032b381STom Zanussi
21165032b381STom ZanussiIn theory, any handler can be combined with any action, but in
21175032b381STom Zanussipractice, not every handler.action combination is currently supported;
21185032b381STom Zanussiif a given handler.action combination isn't supported, the hist
21195032b381STom Zanussitrigger will fail with -EINVAL;
21205032b381STom Zanussi
2121fe4ec72cSMasanari IidaThe default 'handler.action' if none is explicitly specified is as it
21225032b381STom Zanussialways has been, to simply update the set of values associated with an
21235032b381STom Zanussientry.  Some applications, however, may want to perform additional
21245032b381STom Zanussiactions at that point, such as generate another event, or compare and
21255032b381STom Zanussisave a maximum.
21265032b381STom Zanussi
21275032b381STom ZanussiThe supported handlers and actions are listed below, and each is
21285032b381STom Zanussidescribed in more detail in the following paragraphs, in the context
21295032b381STom Zanussiof descriptions of some common and useful handler.action combinations.
21305032b381STom Zanussi
21315032b381STom ZanussiThe available handlers are:
21325032b381STom Zanussi
21335032b381STom Zanussi  - onmatch(matching.event)    - invoke action on any addition or update
21345032b381STom Zanussi  - onmax(var)                 - invoke action if var exceeds current max
2135ff0d35e2STom Zanussi  - onchange(var)              - invoke action if var changes
21365032b381STom Zanussi
21375032b381STom ZanussiThe available actions are:
21385032b381STom Zanussi
2139e91eefd7STom Zanussi  - trace(<synthetic_event_name>,param list)   - generate synthetic event
21405032b381STom Zanussi  - save(field,...)                            - save current event fields
2141fd451a3dSTom Zanussi  - snapshot()                                 - snapshot the trace buffer
21425032b381STom Zanussi
21435032b381STom ZanussiThe following commonly-used handler.action pairs are available:
2144ea272257SMauro Carvalho Chehab
2145e91eefd7STom Zanussi  - onmatch(matching.event).trace(<synthetic_event_name>,param list)
2146ea272257SMauro Carvalho Chehab
2147e91eefd7STom Zanussi    The 'onmatch(matching.event).trace(<synthetic_event_name>,param
2148e91eefd7STom Zanussi    list)' hist trigger action is invoked whenever an event matches
2149e91eefd7STom Zanussi    and the histogram entry would be added or updated.  It causes the
2150e91eefd7STom Zanussi    named synthetic event to be generated with the values given in the
2151ea272257SMauro Carvalho Chehab    'param list'.  The result is the generation of a synthetic event
2152ea272257SMauro Carvalho Chehab    that consists of the values contained in those variables at the
2153e91eefd7STom Zanussi    time the invoking event was hit.  For example, if the synthetic
2154e91eefd7STom Zanussi    event name is 'wakeup_latency', a wakeup_latency event is
2155e91eefd7STom Zanussi    generated using onmatch(event).trace(wakeup_latency,arg1,arg2).
2156ea272257SMauro Carvalho Chehab
2157e91eefd7STom Zanussi    There is also an equivalent alternative form available for
2158e91eefd7STom Zanussi    generating synthetic events.  In this form, the synthetic event
2159e91eefd7STom Zanussi    name is used as if it were a function name.  For example, using
2160e91eefd7STom Zanussi    the 'wakeup_latency' synthetic event name again, the
2161e91eefd7STom Zanussi    wakeup_latency event would be generated by invoking it as if it
2162e91eefd7STom Zanussi    were a function call, with the event field values passed in as
2163e91eefd7STom Zanussi    arguments: onmatch(event).wakeup_latency(arg1,arg2).  The syntax
2164e91eefd7STom Zanussi    for this form is:
2165e91eefd7STom Zanussi
2166e91eefd7STom Zanussi      onmatch(matching.event).<synthetic_event_name>(param list)
2167e91eefd7STom Zanussi
2168e91eefd7STom Zanussi    In either case, the 'param list' consists of one or more
2169e91eefd7STom Zanussi    parameters which may be either variables or fields defined on
2170e91eefd7STom Zanussi    either the 'matching.event' or the target event.  The variables or
2171e91eefd7STom Zanussi    fields specified in the param list may be either fully-qualified
2172e91eefd7STom Zanussi    or unqualified.  If a variable is specified as unqualified, it
2173e91eefd7STom Zanussi    must be unique between the two events.  A field name used as a
2174e91eefd7STom Zanussi    param can be unqualified if it refers to the target event, but
2175e91eefd7STom Zanussi    must be fully qualified if it refers to the matching event.  A
2176e91eefd7STom Zanussi    fully-qualified name is of the form 'system.event_name.$var_name'
2177e91eefd7STom Zanussi    or 'system.event_name.field'.
2178ea272257SMauro Carvalho Chehab
2179ea272257SMauro Carvalho Chehab    The 'matching.event' specification is simply the fully qualified
2180ea272257SMauro Carvalho Chehab    event name of the event that matches the target event for the
218139a39d5bSTzvetomir Stoyanov    onmatch() functionality, in the form 'system.event_name'. Histogram
218239a39d5bSTzvetomir Stoyanov    keys of both events are compared to find if events match. In case
218339a39d5bSTzvetomir Stoyanov    multiple histogram keys are used, they all must match in the specified
218439a39d5bSTzvetomir Stoyanov    order.
2185ea272257SMauro Carvalho Chehab
2186ea272257SMauro Carvalho Chehab    Finally, the number and type of variables/fields in the 'param
2187ea272257SMauro Carvalho Chehab    list' must match the number and types of the fields in the
2188ea272257SMauro Carvalho Chehab    synthetic event being generated.
2189ea272257SMauro Carvalho Chehab
2190ea272257SMauro Carvalho Chehab    As an example the below defines a simple synthetic event and uses
2191ea272257SMauro Carvalho Chehab    a variable defined on the sched_wakeup_new event as a parameter
2192ea272257SMauro Carvalho Chehab    when invoking the synthetic event.  Here we define the synthetic
2193ea272257SMauro Carvalho Chehab    event::
2194ea272257SMauro Carvalho Chehab
2195ea272257SMauro Carvalho Chehab      # echo 'wakeup_new_test pid_t pid' >> \
21962abfcd29SRoss Zwisler             /sys/kernel/tracing/synthetic_events
2197ea272257SMauro Carvalho Chehab
21982abfcd29SRoss Zwisler      # cat /sys/kernel/tracing/synthetic_events
2199ea272257SMauro Carvalho Chehab            wakeup_new_test pid_t pid
2200ea272257SMauro Carvalho Chehab
2201ea272257SMauro Carvalho Chehab    The following hist trigger both defines the missing testpid
2202ea272257SMauro Carvalho Chehab    variable and specifies an onmatch() action that generates a
2203ea272257SMauro Carvalho Chehab    wakeup_new_test synthetic event whenever a sched_wakeup_new event
2204ea272257SMauro Carvalho Chehab    occurs, which because of the 'if comm == "cyclictest"' filter only
2205ea272257SMauro Carvalho Chehab    happens when the executable is cyclictest::
2206ea272257SMauro Carvalho Chehab
2207ea272257SMauro Carvalho Chehab      # echo 'hist:keys=$testpid:testpid=pid:onmatch(sched.sched_wakeup_new).\
2208ea272257SMauro Carvalho Chehab              wakeup_new_test($testpid) if comm=="cyclictest"' >> \
22092abfcd29SRoss Zwisler              /sys/kernel/tracing/events/sched/sched_wakeup_new/trigger
2210ea272257SMauro Carvalho Chehab
2211a2ff84a5SBagas Sanjaya    Or, equivalently, using the 'trace' keyword syntax::
2212e91eefd7STom Zanussi
2213e91eefd7STom Zanussi      # echo 'hist:keys=$testpid:testpid=pid:onmatch(sched.sched_wakeup_new).\
2214e91eefd7STom Zanussi              trace(wakeup_new_test,$testpid) if comm=="cyclictest"' >> \
22152abfcd29SRoss Zwisler              /sys/kernel/tracing/events/sched/sched_wakeup_new/trigger
2216e91eefd7STom Zanussi
2217ea272257SMauro Carvalho Chehab    Creating and displaying a histogram based on those events is now
2218ea272257SMauro Carvalho Chehab    just a matter of using the fields and new synthetic event in the
2219ea272257SMauro Carvalho Chehab    tracing/events/synthetic directory, as usual::
2220ea272257SMauro Carvalho Chehab
2221ea272257SMauro Carvalho Chehab      # echo 'hist:keys=pid:sort=pid' >> \
22222abfcd29SRoss Zwisler             /sys/kernel/tracing/events/synthetic/wakeup_new_test/trigger
2223ea272257SMauro Carvalho Chehab
2224ea272257SMauro Carvalho Chehab    Running 'cyclictest' should cause wakeup_new events to generate
2225ea272257SMauro Carvalho Chehab    wakeup_new_test synthetic events which should result in histogram
2226ea272257SMauro Carvalho Chehab    output in the wakeup_new_test event's hist file::
2227ea272257SMauro Carvalho Chehab
22282abfcd29SRoss Zwisler      # cat /sys/kernel/tracing/events/synthetic/wakeup_new_test/hist
2229ea272257SMauro Carvalho Chehab
2230ea272257SMauro Carvalho Chehab    A more typical usage would be to use two events to calculate a
2231ea272257SMauro Carvalho Chehab    latency.  The following example uses a set of hist triggers to
2232ea272257SMauro Carvalho Chehab    produce a 'wakeup_latency' histogram.
2233ea272257SMauro Carvalho Chehab
2234ea272257SMauro Carvalho Chehab    First, we define a 'wakeup_latency' synthetic event::
2235ea272257SMauro Carvalho Chehab
2236ea272257SMauro Carvalho Chehab      # echo 'wakeup_latency u64 lat; pid_t pid; int prio' >> \
22372abfcd29SRoss Zwisler              /sys/kernel/tracing/synthetic_events
2238ea272257SMauro Carvalho Chehab
2239ea272257SMauro Carvalho Chehab    Next, we specify that whenever we see a sched_waking event for a
2240ea272257SMauro Carvalho Chehab    cyclictest thread, save the timestamp in a 'ts0' variable::
2241ea272257SMauro Carvalho Chehab
2242ea272257SMauro Carvalho Chehab      # echo 'hist:keys=$saved_pid:saved_pid=pid:ts0=common_timestamp.usecs \
2243ea272257SMauro Carvalho Chehab              if comm=="cyclictest"' >> \
22442abfcd29SRoss Zwisler	      /sys/kernel/tracing/events/sched/sched_waking/trigger
2245ea272257SMauro Carvalho Chehab
2246ea272257SMauro Carvalho Chehab    Then, when the corresponding thread is actually scheduled onto the
224739a39d5bSTzvetomir Stoyanov    CPU by a sched_switch event (saved_pid matches next_pid), calculate
224839a39d5bSTzvetomir Stoyanov    the latency and use that along with another variable and an event field
224939a39d5bSTzvetomir Stoyanov    to generate a wakeup_latency synthetic event::
2250ea272257SMauro Carvalho Chehab
2251ea272257SMauro Carvalho Chehab      # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:\
2252ea272257SMauro Carvalho Chehab              onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,\
2253ea272257SMauro Carvalho Chehab	              $saved_pid,next_prio) if next_comm=="cyclictest"' >> \
22542abfcd29SRoss Zwisler	      /sys/kernel/tracing/events/sched/sched_switch/trigger
2255ea272257SMauro Carvalho Chehab
2256ea272257SMauro Carvalho Chehab    We also need to create a histogram on the wakeup_latency synthetic
2257ea272257SMauro Carvalho Chehab    event in order to aggregate the generated synthetic event data::
2258ea272257SMauro Carvalho Chehab
2259ea272257SMauro Carvalho Chehab      # echo 'hist:keys=pid,prio,lat:sort=pid,lat' >> \
22602abfcd29SRoss Zwisler              /sys/kernel/tracing/events/synthetic/wakeup_latency/trigger
2261ea272257SMauro Carvalho Chehab
2262ea272257SMauro Carvalho Chehab    Finally, once we've run cyclictest to actually generate some
2263ea272257SMauro Carvalho Chehab    events, we can see the output by looking at the wakeup_latency
2264ea272257SMauro Carvalho Chehab    synthetic event's hist file::
2265ea272257SMauro Carvalho Chehab
22662abfcd29SRoss Zwisler      # cat /sys/kernel/tracing/events/synthetic/wakeup_latency/hist
2267ea272257SMauro Carvalho Chehab
2268ea272257SMauro Carvalho Chehab  - onmax(var).save(field,..	.)
2269ea272257SMauro Carvalho Chehab
2270ea272257SMauro Carvalho Chehab    The 'onmax(var).save(field,...)' hist trigger action is invoked
2271ea272257SMauro Carvalho Chehab    whenever the value of 'var' associated with a histogram entry
2272ea272257SMauro Carvalho Chehab    exceeds the current maximum contained in that variable.
2273ea272257SMauro Carvalho Chehab
2274ea272257SMauro Carvalho Chehab    The end result is that the trace event fields specified as the
2275ea272257SMauro Carvalho Chehab    onmax.save() params will be saved if 'var' exceeds the current
2276ea272257SMauro Carvalho Chehab    maximum for that hist trigger entry.  This allows context from the
2277ea272257SMauro Carvalho Chehab    event that exhibited the new maximum to be saved for later
2278ea272257SMauro Carvalho Chehab    reference.  When the histogram is displayed, additional fields
2279ea272257SMauro Carvalho Chehab    displaying the saved values will be printed.
2280ea272257SMauro Carvalho Chehab
2281ea272257SMauro Carvalho Chehab    As an example the below defines a couple of hist triggers, one for
2282ea272257SMauro Carvalho Chehab    sched_waking and another for sched_switch, keyed on pid.  Whenever
2283ea272257SMauro Carvalho Chehab    a sched_waking occurs, the timestamp is saved in the entry
2284ea272257SMauro Carvalho Chehab    corresponding to the current pid, and when the scheduler switches
2285ea272257SMauro Carvalho Chehab    back to that pid, the timestamp difference is calculated.  If the
2286ea272257SMauro Carvalho Chehab    resulting latency, stored in wakeup_lat, exceeds the current
2287ea272257SMauro Carvalho Chehab    maximum latency, the values specified in the save() fields are
2288ea272257SMauro Carvalho Chehab    recorded::
2289ea272257SMauro Carvalho Chehab
2290ea272257SMauro Carvalho Chehab      # echo 'hist:keys=pid:ts0=common_timestamp.usecs \
2291ea272257SMauro Carvalho Chehab              if comm=="cyclictest"' >> \
22922abfcd29SRoss Zwisler              /sys/kernel/tracing/events/sched/sched_waking/trigger
2293ea272257SMauro Carvalho Chehab
2294ea272257SMauro Carvalho Chehab      # echo 'hist:keys=next_pid:\
2295ea272257SMauro Carvalho Chehab              wakeup_lat=common_timestamp.usecs-$ts0:\
2296ea272257SMauro Carvalho Chehab              onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) \
2297ea272257SMauro Carvalho Chehab              if next_comm=="cyclictest"' >> \
22982abfcd29SRoss Zwisler              /sys/kernel/tracing/events/sched/sched_switch/trigger
2299ea272257SMauro Carvalho Chehab
2300ea272257SMauro Carvalho Chehab    When the histogram is displayed, the max value and the saved
2301ea272257SMauro Carvalho Chehab    values corresponding to the max are displayed following the rest
2302ea272257SMauro Carvalho Chehab    of the fields::
2303ea272257SMauro Carvalho Chehab
23042abfcd29SRoss Zwisler      # cat /sys/kernel/tracing/events/sched/sched_switch/hist
2305ea272257SMauro Carvalho Chehab        { next_pid:       2255 } hitcount:        239
2306ea272257SMauro Carvalho Chehab          common_timestamp-ts0:          0
2307ea272257SMauro Carvalho Chehab          max:         27
2308ea272257SMauro Carvalho Chehab	  next_comm: cyclictest
2309ea272257SMauro Carvalho Chehab          prev_pid:          0  prev_prio:        120  prev_comm: swapper/1
2310ea272257SMauro Carvalho Chehab
2311ea272257SMauro Carvalho Chehab        { next_pid:       2256 } hitcount:       2355
2312ea272257SMauro Carvalho Chehab          common_timestamp-ts0: 0
2313ea272257SMauro Carvalho Chehab          max:         49  next_comm: cyclictest
2314ea272257SMauro Carvalho Chehab          prev_pid:          0  prev_prio:        120  prev_comm: swapper/0
2315ea272257SMauro Carvalho Chehab
2316ea272257SMauro Carvalho Chehab        Totals:
2317ea272257SMauro Carvalho Chehab            Hits: 12970
2318ea272257SMauro Carvalho Chehab            Entries: 2
2319ea272257SMauro Carvalho Chehab            Dropped: 0
2320ea272257SMauro Carvalho Chehab
2321fd451a3dSTom Zanussi  - onmax(var).snapshot()
2322fd451a3dSTom Zanussi
2323fd451a3dSTom Zanussi    The 'onmax(var).snapshot()' hist trigger action is invoked
2324fd451a3dSTom Zanussi    whenever the value of 'var' associated with a histogram entry
2325fd451a3dSTom Zanussi    exceeds the current maximum contained in that variable.
2326fd451a3dSTom Zanussi
2327fd451a3dSTom Zanussi    The end result is that a global snapshot of the trace buffer will
2328fd451a3dSTom Zanussi    be saved in the tracing/snapshot file if 'var' exceeds the current
2329fd451a3dSTom Zanussi    maximum for any hist trigger entry.
2330fd451a3dSTom Zanussi
2331fd451a3dSTom Zanussi    Note that in this case the maximum is a global maximum for the
2332fd451a3dSTom Zanussi    current trace instance, which is the maximum across all buckets of
2333fd451a3dSTom Zanussi    the histogram.  The key of the specific trace event that caused
2334fd451a3dSTom Zanussi    the global maximum and the global maximum itself are displayed,
2335fd451a3dSTom Zanussi    along with a message stating that a snapshot has been taken and
2336fd451a3dSTom Zanussi    where to find it.  The user can use the key information displayed
2337fd451a3dSTom Zanussi    to locate the corresponding bucket in the histogram for even more
2338fd451a3dSTom Zanussi    detail.
2339fd451a3dSTom Zanussi
2340fd451a3dSTom Zanussi    As an example the below defines a couple of hist triggers, one for
2341fd451a3dSTom Zanussi    sched_waking and another for sched_switch, keyed on pid.  Whenever
2342fd451a3dSTom Zanussi    a sched_waking event occurs, the timestamp is saved in the entry
2343fd451a3dSTom Zanussi    corresponding to the current pid, and when the scheduler switches
2344fd451a3dSTom Zanussi    back to that pid, the timestamp difference is calculated.  If the
2345fd451a3dSTom Zanussi    resulting latency, stored in wakeup_lat, exceeds the current
2346fd451a3dSTom Zanussi    maximum latency, a snapshot is taken.  As part of the setup, all
2347fd451a3dSTom Zanussi    the scheduler events are also enabled, which are the events that
2348a2ff84a5SBagas Sanjaya    will show up in the snapshot when it is taken at some point::
2349fd451a3dSTom Zanussi
23502abfcd29SRoss Zwisler      # echo 1 > /sys/kernel/tracing/events/sched/enable
2351fd451a3dSTom Zanussi
2352fd451a3dSTom Zanussi      # echo 'hist:keys=pid:ts0=common_timestamp.usecs \
2353fd451a3dSTom Zanussi              if comm=="cyclictest"' >> \
23542abfcd29SRoss Zwisler              /sys/kernel/tracing/events/sched/sched_waking/trigger
2355fd451a3dSTom Zanussi
2356fd451a3dSTom Zanussi      # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0: \
2357fd451a3dSTom Zanussi              onmax($wakeup_lat).save(next_prio,next_comm,prev_pid,prev_prio, \
2358fd451a3dSTom Zanussi	      prev_comm):onmax($wakeup_lat).snapshot() \
2359fd451a3dSTom Zanussi	      if next_comm=="cyclictest"' >> \
23602abfcd29SRoss Zwisler	      /sys/kernel/tracing/events/sched/sched_switch/trigger
2361fd451a3dSTom Zanussi
2362fd451a3dSTom Zanussi    When the histogram is displayed, for each bucket the max value
2363fd451a3dSTom Zanussi    and the saved values corresponding to the max are displayed
2364fd451a3dSTom Zanussi    following the rest of the fields.
2365fd451a3dSTom Zanussi
2366fe4ec72cSMasanari Iida    If a snapshot was taken, there is also a message indicating that,
2367a2ff84a5SBagas Sanjaya    along with the value and event that triggered the global maximum::
2368fd451a3dSTom Zanussi
23692abfcd29SRoss Zwisler      # cat /sys/kernel/tracing/events/sched/sched_switch/hist
2370fd451a3dSTom Zanussi        { next_pid:       2101 } hitcount:        200
2371fd451a3dSTom Zanussi	  max:         52  next_prio:        120  next_comm: cyclictest \
2372fd451a3dSTom Zanussi          prev_pid:          0  prev_prio:        120  prev_comm: swapper/6
2373fd451a3dSTom Zanussi
2374fd451a3dSTom Zanussi        { next_pid:       2103 } hitcount:       1326
2375fd451a3dSTom Zanussi	  max:        572  next_prio:         19  next_comm: cyclictest \
2376fd451a3dSTom Zanussi          prev_pid:          0  prev_prio:        120  prev_comm: swapper/1
2377fd451a3dSTom Zanussi
2378fd451a3dSTom Zanussi        { next_pid:       2102 } hitcount:       1982 \
2379fd451a3dSTom Zanussi	  max:         74  next_prio:         19  next_comm: cyclictest \
2380fd451a3dSTom Zanussi          prev_pid:          0  prev_prio:        120  prev_comm: swapper/5
2381fd451a3dSTom Zanussi
2382fd451a3dSTom Zanussi      Snapshot taken (see tracing/snapshot).  Details:
2383fd451a3dSTom Zanussi	  triggering value { onmax($wakeup_lat) }:        572	\
2384fd451a3dSTom Zanussi	  triggered by event with key: { next_pid:       2103 }
2385fd451a3dSTom Zanussi
2386fd451a3dSTom Zanussi      Totals:
2387fd451a3dSTom Zanussi          Hits: 3508
2388fd451a3dSTom Zanussi          Entries: 3
2389fd451a3dSTom Zanussi          Dropped: 0
2390fd451a3dSTom Zanussi
2391fd451a3dSTom Zanussi    In the above case, the event that triggered the global maximum has
2392fd451a3dSTom Zanussi    the key with next_pid == 2103.  If you look at the bucket that has
2393fd451a3dSTom Zanussi    2103 as the key, you'll find the additional values save()'d along
2394fd451a3dSTom Zanussi    with the local maximum for that bucket, which should be the same
2395fd451a3dSTom Zanussi    as the global maximum (since that was the same value that
2396fd451a3dSTom Zanussi    triggered the global snapshot).
2397fd451a3dSTom Zanussi
2398fd451a3dSTom Zanussi    And finally, looking at the snapshot data should show at or near
2399fd451a3dSTom Zanussi    the end the event that triggered the snapshot (in this case you
2400fd451a3dSTom Zanussi    can verify the timestamps between the sched_waking and
2401fd451a3dSTom Zanussi    sched_switch events, which should match the time displayed in the
24023df5ffd2SMauro Carvalho Chehab    global maximum)::
2403fd451a3dSTom Zanussi
24042abfcd29SRoss Zwisler     # cat /sys/kernel/tracing/snapshot
2405fd451a3dSTom Zanussi
2406fd451a3dSTom 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
2407fd451a3dSTom Zanussi         <idle>-0     [005] d.h3   309.873611: sched_waking: comm=cyclictest pid=2102 prio=19 target_cpu=005
2408fd451a3dSTom Zanussi         <idle>-0     [005] dNh4   309.873613: sched_wakeup: comm=cyclictest pid=2102 prio=19 target_cpu=005
2409fd451a3dSTom 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
2410fd451a3dSTom 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
2411fd451a3dSTom Zanussi         <idle>-0     [005] d.h3   309.874624: sched_waking: comm=cyclictest pid=2102 prio=19 target_cpu=005
2412fd451a3dSTom Zanussi         <idle>-0     [005] dNh4   309.874626: sched_wakeup: comm=cyclictest pid=2102 prio=19 target_cpu=005
2413fd451a3dSTom Zanussi         <idle>-0     [005] dNh3   309.874628: sched_waking: comm=cyclictest pid=2103 prio=19 target_cpu=005
2414fd451a3dSTom Zanussi         <idle>-0     [005] dNh4   309.874630: sched_wakeup: comm=cyclictest pid=2103 prio=19 target_cpu=005
2415fd451a3dSTom 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
2416fd451a3dSTom Zanussi         <idle>-0     [004] d.h3   309.874757: sched_waking: comm=gnome-terminal- pid=1699 prio=120 target_cpu=004
2417fd451a3dSTom Zanussi         <idle>-0     [004] dNh4   309.874762: sched_wakeup: comm=gnome-terminal- pid=1699 prio=120 target_cpu=004
2418fd451a3dSTom 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
2419fd451a3dSTom Zanussi     gnome-terminal--1699  [004] d.h2   309.874941: sched_stat_runtime: comm=gnome-terminal- pid=1699 runtime=180706 [ns] vruntime=1126870572 [ns]
2420fd451a3dSTom Zanussi         <idle>-0     [003] d.s4   309.874956: sched_waking: comm=rcu_sched pid=9 prio=120 target_cpu=007
2421fd451a3dSTom Zanussi         <idle>-0     [003] d.s5   309.874960: sched_wake_idle_without_ipi: cpu=7
2422fd451a3dSTom Zanussi         <idle>-0     [003] d.s5   309.874961: sched_wakeup: comm=rcu_sched pid=9 prio=120 target_cpu=007
2423fd451a3dSTom 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
2424fd451a3dSTom Zanussi      rcu_sched-9     [007] d..3   309.874973: sched_stat_runtime: comm=rcu_sched pid=9 runtime=13646 [ns] vruntime=22531430286 [ns]
2425fd451a3dSTom 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
2426fd451a3dSTom Zanussi          <...>-2102  [005] d..4   309.874994: sched_migrate_task: comm=cyclictest pid=2103 prio=19 orig_cpu=5 dest_cpu=1
2427fd451a3dSTom Zanussi          <...>-2102  [005] d..4   309.875185: sched_wake_idle_without_ipi: cpu=1
2428fd451a3dSTom 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
2429fd451a3dSTom Zanussi
2430ff0d35e2STom Zanussi  - onchange(var).save(field,..	.)
2431ff0d35e2STom Zanussi
2432ff0d35e2STom Zanussi    The 'onchange(var).save(field,...)' hist trigger action is invoked
2433ff0d35e2STom Zanussi    whenever the value of 'var' associated with a histogram entry
2434ff0d35e2STom Zanussi    changes.
2435ff0d35e2STom Zanussi
2436ff0d35e2STom Zanussi    The end result is that the trace event fields specified as the
2437ff0d35e2STom Zanussi    onchange.save() params will be saved if 'var' changes for that
2438ff0d35e2STom Zanussi    hist trigger entry.  This allows context from the event that
2439ff0d35e2STom Zanussi    changed the value to be saved for later reference.  When the
2440ff0d35e2STom Zanussi    histogram is displayed, additional fields displaying the saved
2441ff0d35e2STom Zanussi    values will be printed.
2442ff0d35e2STom Zanussi
2443ff0d35e2STom Zanussi  - onchange(var).snapshot()
2444ff0d35e2STom Zanussi
2445ff0d35e2STom Zanussi    The 'onchange(var).snapshot()' hist trigger action is invoked
2446ff0d35e2STom Zanussi    whenever the value of 'var' associated with a histogram entry
2447ff0d35e2STom Zanussi    changes.
2448ff0d35e2STom Zanussi
2449ff0d35e2STom Zanussi    The end result is that a global snapshot of the trace buffer will
2450ff0d35e2STom Zanussi    be saved in the tracing/snapshot file if 'var' changes for any
2451ff0d35e2STom Zanussi    hist trigger entry.
2452ff0d35e2STom Zanussi
2453ff0d35e2STom Zanussi    Note that in this case the changed value is a global variable
2454fe4ec72cSMasanari Iida    associated with current trace instance.  The key of the specific
2455ff0d35e2STom Zanussi    trace event that caused the value to change and the global value
2456ff0d35e2STom Zanussi    itself are displayed, along with a message stating that a snapshot
2457ff0d35e2STom Zanussi    has been taken and where to find it.  The user can use the key
2458ff0d35e2STom Zanussi    information displayed to locate the corresponding bucket in the
2459ff0d35e2STom Zanussi    histogram for even more detail.
2460ff0d35e2STom Zanussi
2461ff0d35e2STom Zanussi    As an example the below defines a hist trigger on the tcp_probe
2462ff0d35e2STom Zanussi    event, keyed on dport.  Whenever a tcp_probe event occurs, the
2463ff0d35e2STom Zanussi    cwnd field is checked against the current value stored in the
2464ff0d35e2STom Zanussi    $cwnd variable.  If the value has changed, a snapshot is taken.
2465ff0d35e2STom Zanussi    As part of the setup, all the scheduler and tcp events are also
2466ff0d35e2STom Zanussi    enabled, which are the events that will show up in the snapshot
2467a2ff84a5SBagas Sanjaya    when it is taken at some point::
2468ff0d35e2STom Zanussi
24692abfcd29SRoss Zwisler      # echo 1 > /sys/kernel/tracing/events/sched/enable
24702abfcd29SRoss Zwisler      # echo 1 > /sys/kernel/tracing/events/tcp/enable
2471ff0d35e2STom Zanussi
2472ff0d35e2STom Zanussi      # echo 'hist:keys=dport:cwnd=snd_cwnd: \
2473ff0d35e2STom Zanussi              onchange($cwnd).save(snd_wnd,srtt,rcv_wnd): \
2474ff0d35e2STom Zanussi	      onchange($cwnd).snapshot()' >> \
24752abfcd29SRoss Zwisler	      /sys/kernel/tracing/events/tcp/tcp_probe/trigger
2476ff0d35e2STom Zanussi
2477ff0d35e2STom Zanussi    When the histogram is displayed, for each bucket the tracked value
2478ff0d35e2STom Zanussi    and the saved values corresponding to that value are displayed
2479ff0d35e2STom Zanussi    following the rest of the fields.
2480ff0d35e2STom Zanussi
2481fe4ec72cSMasanari Iida    If a snapshot was taken, there is also a message indicating that,
24823df5ffd2SMauro Carvalho Chehab    along with the value and event that triggered the snapshot::
2483ff0d35e2STom Zanussi
24842abfcd29SRoss Zwisler      # cat /sys/kernel/tracing/events/tcp/tcp_probe/hist
24853df5ffd2SMauro Carvalho Chehab
2486ff0d35e2STom Zanussi      { dport:       1521 } hitcount:          8
2487ff0d35e2STom Zanussi	changed:         10  snd_wnd:      35456  srtt:     154262  rcv_wnd:      42112
2488ff0d35e2STom Zanussi
2489ff0d35e2STom Zanussi      { dport:         80 } hitcount:         23
2490ff0d35e2STom Zanussi	changed:         10  snd_wnd:      28960  srtt:      19604  rcv_wnd:      29312
2491ff0d35e2STom Zanussi
2492ff0d35e2STom Zanussi      { dport:       9001 } hitcount:        172
2493ff0d35e2STom Zanussi	changed:         10  snd_wnd:      48384  srtt:     260444  rcv_wnd:      55168
2494ff0d35e2STom Zanussi
2495ff0d35e2STom Zanussi      { dport:        443 } hitcount:        211
2496ff0d35e2STom Zanussi	changed:         10  snd_wnd:      26960  srtt:      17379  rcv_wnd:      28800
2497ff0d35e2STom Zanussi
2498a2ff84a5SBagas Sanjaya      Snapshot taken (see tracing/snapshot).  Details:
24993df5ffd2SMauro Carvalho Chehab
2500ff0d35e2STom Zanussi          triggering value { onchange($cwnd) }:         10
2501ff0d35e2STom Zanussi          triggered by event with key: { dport:         80 }
2502ff0d35e2STom Zanussi
2503ff0d35e2STom Zanussi      Totals:
2504ff0d35e2STom Zanussi          Hits: 414
2505ff0d35e2STom Zanussi          Entries: 4
2506ff0d35e2STom Zanussi          Dropped: 0
2507ff0d35e2STom Zanussi
2508ff0d35e2STom Zanussi    In the above case, the event that triggered the snapshot has the
2509ff0d35e2STom Zanussi    key with dport == 80.  If you look at the bucket that has 80 as
2510ff0d35e2STom Zanussi    the key, you'll find the additional values save()'d along with the
2511ff0d35e2STom Zanussi    changed value for that bucket, which should be the same as the
2512ff0d35e2STom Zanussi    global changed value (since that was the same value that triggered
2513ff0d35e2STom Zanussi    the global snapshot).
2514ff0d35e2STom Zanussi
2515ff0d35e2STom Zanussi    And finally, looking at the snapshot data should show at or near
25163df5ffd2SMauro Carvalho Chehab    the end the event that triggered the snapshot::
2517ff0d35e2STom Zanussi
25182abfcd29SRoss Zwisler      # cat /sys/kernel/tracing/snapshot
2519ff0d35e2STom Zanussi
2520ff0d35e2STom Zanussi         gnome-shell-1261  [006] dN.3    49.823113: sched_stat_runtime: comm=gnome-shell pid=1261 runtime=49347 [ns] vruntime=1835730389 [ns]
2521ff0d35e2STom 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
2522ff0d35e2STom 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
2523ff0d35e2STom 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]
2524ff0d35e2STom 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]
2525ff0d35e2STom 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
2526ff0d35e2STom 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
2527ff0d35e2STom 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
2528ff0d35e2STom Zanussi
2529ea272257SMauro Carvalho Chehab3. User space creating a trigger
2530ea272257SMauro Carvalho Chehab--------------------------------
2531ea272257SMauro Carvalho Chehab
2532ea272257SMauro Carvalho ChehabWriting into /sys/kernel/tracing/trace_marker writes into the ftrace
2533ea272257SMauro Carvalho Chehabring buffer. This can also act like an event, by writing into the trigger
2534ea272257SMauro Carvalho Chehabfile located in /sys/kernel/tracing/events/ftrace/print/
2535ea272257SMauro Carvalho Chehab
2536ea272257SMauro Carvalho ChehabModifying cyclictest to write into the trace_marker file before it sleeps
2537ea272257SMauro Carvalho Chehaband after it wakes up, something like this::
2538ea272257SMauro Carvalho Chehab
2539ea272257SMauro Carvalho Chehab  static void traceputs(char *str)
2540ea272257SMauro Carvalho Chehab  {
2541ea272257SMauro Carvalho Chehab	/* tracemark_fd is the trace_marker file descriptor */
2542ea272257SMauro Carvalho Chehab	if (tracemark_fd < 0)
2543ea272257SMauro Carvalho Chehab		return;
2544ea272257SMauro Carvalho Chehab	/* write the tracemark message */
2545ea272257SMauro Carvalho Chehab	write(tracemark_fd, str, strlen(str));
2546ea272257SMauro Carvalho Chehab  }
2547ea272257SMauro Carvalho Chehab
2548ea272257SMauro Carvalho ChehabAnd later add something like::
2549ea272257SMauro Carvalho Chehab
2550ea272257SMauro Carvalho Chehab	traceputs("start");
2551ea272257SMauro Carvalho Chehab	clock_nanosleep(...);
2552ea272257SMauro Carvalho Chehab	traceputs("end");
2553ea272257SMauro Carvalho Chehab
2554ea272257SMauro Carvalho ChehabWe can make a histogram from this::
2555ea272257SMauro Carvalho Chehab
2556ea272257SMauro Carvalho Chehab # cd /sys/kernel/tracing
2557ea272257SMauro Carvalho Chehab # echo 'latency u64 lat' > synthetic_events
2558ea272257SMauro Carvalho Chehab # echo 'hist:keys=common_pid:ts0=common_timestamp.usecs if buf == "start"' > events/ftrace/print/trigger
2559ea272257SMauro Carvalho Chehab # echo 'hist:keys=common_pid:lat=common_timestamp.usecs-$ts0:onmatch(ftrace.print).latency($lat) if buf == "end"' >> events/ftrace/print/trigger
2560ea272257SMauro Carvalho Chehab # echo 'hist:keys=lat,common_pid:sort=lat' > events/synthetic/latency/trigger
2561ea272257SMauro Carvalho Chehab
2562ea272257SMauro Carvalho ChehabThe above created a synthetic event called "latency" and two histograms
2563ea272257SMauro Carvalho Chehabagainst the trace_marker, one gets triggered when "start" is written into the
2564ea272257SMauro Carvalho Chehabtrace_marker file and the other when "end" is written. If the pids match, then
2565ea272257SMauro Carvalho Chehabit will call the "latency" synthetic event with the calculated latency as its
2566ea272257SMauro Carvalho Chehabparameter. Finally, a histogram is added to the latency synthetic event to
2567ea272257SMauro Carvalho Chehabrecord the calculated latency along with the pid.
2568ea272257SMauro Carvalho Chehab
2569ea272257SMauro Carvalho ChehabNow running cyclictest with::
2570ea272257SMauro Carvalho Chehab
2571ea272257SMauro Carvalho Chehab # ./cyclictest -p80 -d0 -i250 -n -a -t --tracemark -b 1000
2572ea272257SMauro Carvalho Chehab
2573ea272257SMauro Carvalho Chehab -p80  : run threads at priority 80
2574ea272257SMauro Carvalho Chehab -d0   : have all threads run at the same interval
2575ea272257SMauro Carvalho Chehab -i250 : start the interval at 250 microseconds (all threads will do this)
2576ea272257SMauro Carvalho Chehab -n    : sleep with nanosleep
2577ea272257SMauro Carvalho Chehab -a    : affine all threads to a separate CPU
2578ea272257SMauro Carvalho Chehab -t    : one thread per available CPU
2579ea272257SMauro Carvalho Chehab --tracemark : enable trace mark writing
2580ea272257SMauro Carvalho Chehab -b 1000 : stop if any latency is greater than 1000 microseconds
2581ea272257SMauro Carvalho Chehab
2582ea272257SMauro Carvalho ChehabNote, the -b 1000 is used just to make --tracemark available.
2583ea272257SMauro Carvalho Chehab
2584ea272257SMauro Carvalho ChehabThen we can see the histogram created by this with::
2585ea272257SMauro Carvalho Chehab
2586ea272257SMauro Carvalho Chehab # cat events/synthetic/latency/hist
2587ea272257SMauro Carvalho Chehab # event histogram
2588ea272257SMauro Carvalho Chehab #
2589ea272257SMauro Carvalho Chehab # trigger info: hist:keys=lat,common_pid:vals=hitcount:sort=lat:size=2048 [active]
2590ea272257SMauro Carvalho Chehab #
2591ea272257SMauro Carvalho Chehab
2592ea272257SMauro Carvalho Chehab { lat:        107, common_pid:       2039 } hitcount:          1
2593ea272257SMauro Carvalho Chehab { lat:        122, common_pid:       2041 } hitcount:          1
2594ea272257SMauro Carvalho Chehab { lat:        166, common_pid:       2039 } hitcount:          1
2595ea272257SMauro Carvalho Chehab { lat:        174, common_pid:       2039 } hitcount:          1
2596ea272257SMauro Carvalho Chehab { lat:        194, common_pid:       2041 } hitcount:          1
2597ea272257SMauro Carvalho Chehab { lat:        196, common_pid:       2036 } hitcount:          1
2598ea272257SMauro Carvalho Chehab { lat:        197, common_pid:       2038 } hitcount:          1
2599ea272257SMauro Carvalho Chehab { lat:        198, common_pid:       2039 } hitcount:          1
2600ea272257SMauro Carvalho Chehab { lat:        199, common_pid:       2039 } hitcount:          1
2601ea272257SMauro Carvalho Chehab { lat:        200, common_pid:       2041 } hitcount:          1
2602ea272257SMauro Carvalho Chehab { lat:        201, common_pid:       2039 } hitcount:          2
2603ea272257SMauro Carvalho Chehab { lat:        202, common_pid:       2038 } hitcount:          1
2604ea272257SMauro Carvalho Chehab { lat:        202, common_pid:       2043 } hitcount:          1
2605ea272257SMauro Carvalho Chehab { lat:        203, common_pid:       2039 } hitcount:          1
2606ea272257SMauro Carvalho Chehab { lat:        203, common_pid:       2036 } hitcount:          1
2607ea272257SMauro Carvalho Chehab { lat:        203, common_pid:       2041 } hitcount:          1
2608ea272257SMauro Carvalho Chehab { lat:        206, common_pid:       2038 } hitcount:          2
2609ea272257SMauro Carvalho Chehab { lat:        207, common_pid:       2039 } hitcount:          1
2610ea272257SMauro Carvalho Chehab { lat:        207, common_pid:       2036 } hitcount:          1
2611ea272257SMauro Carvalho Chehab { lat:        208, common_pid:       2040 } hitcount:          1
2612ea272257SMauro Carvalho Chehab { lat:        209, common_pid:       2043 } hitcount:          1
2613ea272257SMauro Carvalho Chehab { lat:        210, common_pid:       2039 } hitcount:          1
2614ea272257SMauro Carvalho Chehab { lat:        211, common_pid:       2039 } hitcount:          4
2615ea272257SMauro Carvalho Chehab { lat:        212, common_pid:       2043 } hitcount:          1
2616ea272257SMauro Carvalho Chehab { lat:        212, common_pid:       2039 } hitcount:          2
2617ea272257SMauro Carvalho Chehab { lat:        213, common_pid:       2039 } hitcount:          1
2618ea272257SMauro Carvalho Chehab { lat:        214, common_pid:       2038 } hitcount:          1
2619ea272257SMauro Carvalho Chehab { lat:        214, common_pid:       2039 } hitcount:          2
2620ea272257SMauro Carvalho Chehab { lat:        214, common_pid:       2042 } hitcount:          1
2621ea272257SMauro Carvalho Chehab { lat:        215, common_pid:       2039 } hitcount:          1
2622ea272257SMauro Carvalho Chehab { lat:        217, common_pid:       2036 } hitcount:          1
2623ea272257SMauro Carvalho Chehab { lat:        217, common_pid:       2040 } hitcount:          1
2624ea272257SMauro Carvalho Chehab { lat:        217, common_pid:       2039 } hitcount:          1
2625ea272257SMauro Carvalho Chehab { lat:        218, common_pid:       2039 } hitcount:          6
2626ea272257SMauro Carvalho Chehab { lat:        219, common_pid:       2039 } hitcount:          9
2627ea272257SMauro Carvalho Chehab { lat:        220, common_pid:       2039 } hitcount:         11
2628ea272257SMauro Carvalho Chehab { lat:        221, common_pid:       2039 } hitcount:          5
2629ea272257SMauro Carvalho Chehab { lat:        221, common_pid:       2042 } hitcount:          1
2630ea272257SMauro Carvalho Chehab { lat:        222, common_pid:       2039 } hitcount:          7
2631ea272257SMauro Carvalho Chehab { lat:        223, common_pid:       2036 } hitcount:          1
2632ea272257SMauro Carvalho Chehab { lat:        223, common_pid:       2039 } hitcount:          3
2633ea272257SMauro Carvalho Chehab { lat:        224, common_pid:       2039 } hitcount:          4
2634ea272257SMauro Carvalho Chehab { lat:        224, common_pid:       2037 } hitcount:          1
2635ea272257SMauro Carvalho Chehab { lat:        224, common_pid:       2036 } hitcount:          2
2636ea272257SMauro Carvalho Chehab { lat:        225, common_pid:       2039 } hitcount:          5
2637ea272257SMauro Carvalho Chehab { lat:        225, common_pid:       2042 } hitcount:          1
2638ea272257SMauro Carvalho Chehab { lat:        226, common_pid:       2039 } hitcount:          7
2639ea272257SMauro Carvalho Chehab { lat:        226, common_pid:       2036 } hitcount:          4
2640ea272257SMauro Carvalho Chehab { lat:        227, common_pid:       2039 } hitcount:          6
2641ea272257SMauro Carvalho Chehab { lat:        227, common_pid:       2036 } hitcount:         12
2642ea272257SMauro Carvalho Chehab { lat:        227, common_pid:       2043 } hitcount:          1
2643ea272257SMauro Carvalho Chehab { lat:        228, common_pid:       2039 } hitcount:          7
2644ea272257SMauro Carvalho Chehab { lat:        228, common_pid:       2036 } hitcount:         14
2645ea272257SMauro Carvalho Chehab { lat:        229, common_pid:       2039 } hitcount:          9
2646ea272257SMauro Carvalho Chehab { lat:        229, common_pid:       2036 } hitcount:          8
2647ea272257SMauro Carvalho Chehab { lat:        229, common_pid:       2038 } hitcount:          1
2648ea272257SMauro Carvalho Chehab { lat:        230, common_pid:       2039 } hitcount:         11
2649ea272257SMauro Carvalho Chehab { lat:        230, common_pid:       2036 } hitcount:          6
2650ea272257SMauro Carvalho Chehab { lat:        230, common_pid:       2043 } hitcount:          1
2651ea272257SMauro Carvalho Chehab { lat:        230, common_pid:       2042 } hitcount:          2
2652ea272257SMauro Carvalho Chehab { lat:        231, common_pid:       2041 } hitcount:          1
2653ea272257SMauro Carvalho Chehab { lat:        231, common_pid:       2036 } hitcount:          6
2654ea272257SMauro Carvalho Chehab { lat:        231, common_pid:       2043 } hitcount:          1
2655ea272257SMauro Carvalho Chehab { lat:        231, common_pid:       2039 } hitcount:          8
2656ea272257SMauro Carvalho Chehab { lat:        232, common_pid:       2037 } hitcount:          1
2657ea272257SMauro Carvalho Chehab { lat:        232, common_pid:       2039 } hitcount:          6
2658ea272257SMauro Carvalho Chehab { lat:        232, common_pid:       2040 } hitcount:          2
2659ea272257SMauro Carvalho Chehab { lat:        232, common_pid:       2036 } hitcount:          5
2660ea272257SMauro Carvalho Chehab { lat:        232, common_pid:       2043 } hitcount:          1
2661ea272257SMauro Carvalho Chehab { lat:        233, common_pid:       2036 } hitcount:          5
2662ea272257SMauro Carvalho Chehab { lat:        233, common_pid:       2039 } hitcount:         11
2663ea272257SMauro Carvalho Chehab { lat:        234, common_pid:       2039 } hitcount:          4
2664ea272257SMauro Carvalho Chehab { lat:        234, common_pid:       2038 } hitcount:          2
2665ea272257SMauro Carvalho Chehab { lat:        234, common_pid:       2043 } hitcount:          2
2666ea272257SMauro Carvalho Chehab { lat:        234, common_pid:       2036 } hitcount:         11
2667ea272257SMauro Carvalho Chehab { lat:        234, common_pid:       2040 } hitcount:          1
2668ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2037 } hitcount:          2
2669ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2036 } hitcount:          8
2670ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2043 } hitcount:          2
2671ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2039 } hitcount:          5
2672ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2042 } hitcount:          2
2673ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2040 } hitcount:          4
2674ea272257SMauro Carvalho Chehab { lat:        235, common_pid:       2041 } hitcount:          1
2675ea272257SMauro Carvalho Chehab { lat:        236, common_pid:       2036 } hitcount:          7
2676ea272257SMauro Carvalho Chehab { lat:        236, common_pid:       2037 } hitcount:          1
2677ea272257SMauro Carvalho Chehab { lat:        236, common_pid:       2041 } hitcount:          5
2678ea272257SMauro Carvalho Chehab { lat:        236, common_pid:       2039 } hitcount:          3
2679ea272257SMauro Carvalho Chehab { lat:        236, common_pid:       2043 } hitcount:          9
2680ea272257SMauro Carvalho Chehab { lat:        236, common_pid:       2040 } hitcount:          7
2681ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2037 } hitcount:          1
2682ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2040 } hitcount:          1
2683ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2036 } hitcount:          9
2684ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2039 } hitcount:          3
2685ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2043 } hitcount:          8
2686ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2042 } hitcount:          2
2687ea272257SMauro Carvalho Chehab { lat:        237, common_pid:       2041 } hitcount:          2
2688ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2043 } hitcount:         10
2689ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2040 } hitcount:          1
2690ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2037 } hitcount:          9
2691ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2038 } hitcount:          1
2692ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2039 } hitcount:          1
2693ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2042 } hitcount:          3
2694ea272257SMauro Carvalho Chehab { lat:        238, common_pid:       2036 } hitcount:          7
2695ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2041 } hitcount:          1
2696ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2043 } hitcount:         11
2697ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2037 } hitcount:         11
2698ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2038 } hitcount:          6
2699ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2036 } hitcount:          7
2700ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2040 } hitcount:          1
2701ea272257SMauro Carvalho Chehab { lat:        239, common_pid:       2042 } hitcount:          9
2702ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2037 } hitcount:         29
2703ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2043 } hitcount:         15
2704ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2040 } hitcount:         44
2705ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2039 } hitcount:          1
2706ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2041 } hitcount:          2
2707ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2038 } hitcount:          1
2708ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2036 } hitcount:         10
2709ea272257SMauro Carvalho Chehab { lat:        240, common_pid:       2042 } hitcount:         13
2710ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2036 } hitcount:         21
2711ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2041 } hitcount:         36
2712ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2037 } hitcount:         34
2713ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2042 } hitcount:         14
2714ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2040 } hitcount:         94
2715ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2039 } hitcount:         12
2716ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2038 } hitcount:          2
2717ea272257SMauro Carvalho Chehab { lat:        241, common_pid:       2043 } hitcount:         28
2718ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2040 } hitcount:        109
2719ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2041 } hitcount:        506
2720ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2039 } hitcount:        155
2721ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2042 } hitcount:         21
2722ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2037 } hitcount:         52
2723ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2043 } hitcount:         21
2724ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2036 } hitcount:         16
2725ea272257SMauro Carvalho Chehab { lat:        242, common_pid:       2038 } hitcount:        156
2726ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2037 } hitcount:         46
2727ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2039 } hitcount:         40
2728ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2042 } hitcount:        119
2729ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2041 } hitcount:        611
2730ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2036 } hitcount:         69
2731ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2038 } hitcount:        784
2732ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2040 } hitcount:        323
2733ea272257SMauro Carvalho Chehab { lat:        243, common_pid:       2043 } hitcount:         14
2734ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2043 } hitcount:         35
2735ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2042 } hitcount:        305
2736ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2039 } hitcount:          8
2737ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2040 } hitcount:       4515
2738ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2038 } hitcount:        371
2739ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2037 } hitcount:         31
2740ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2036 } hitcount:        114
2741ea272257SMauro Carvalho Chehab { lat:        244, common_pid:       2041 } hitcount:       3396
2742ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2036 } hitcount:        700
2743ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2041 } hitcount:       2772
2744ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2037 } hitcount:        268
2745ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2039 } hitcount:        472
2746ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2038 } hitcount:       2758
2747ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2042 } hitcount:       3833
2748ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2040 } hitcount:       3105
2749ea272257SMauro Carvalho Chehab { lat:        245, common_pid:       2043 } hitcount:        645
2750ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2038 } hitcount:       3451
2751ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2041 } hitcount:        142
2752ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2037 } hitcount:       5101
2753ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2040 } hitcount:         68
2754ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2043 } hitcount:       5099
2755ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2039 } hitcount:       5608
2756ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2042 } hitcount:       3723
2757ea272257SMauro Carvalho Chehab { lat:        246, common_pid:       2036 } hitcount:       4738
2758ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2042 } hitcount:        312
2759ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2043 } hitcount:       2385
2760ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2041 } hitcount:        452
2761ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2038 } hitcount:        792
2762ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2040 } hitcount:         78
2763ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2036 } hitcount:       2375
2764ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2039 } hitcount:       1834
2765ea272257SMauro Carvalho Chehab { lat:        247, common_pid:       2037 } hitcount:       2655
2766ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2037 } hitcount:         36
2767ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2042 } hitcount:         11
2768ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2038 } hitcount:        122
2769ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2036 } hitcount:        135
2770ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2039 } hitcount:         26
2771ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2041 } hitcount:        503
2772ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2043 } hitcount:         66
2773ea272257SMauro Carvalho Chehab { lat:        248, common_pid:       2040 } hitcount:         46
2774ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2037 } hitcount:         29
2775ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2038 } hitcount:          1
2776ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2043 } hitcount:         29
2777ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2039 } hitcount:          8
2778ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2042 } hitcount:         56
2779ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2040 } hitcount:         27
2780ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2041 } hitcount:         11
2781ea272257SMauro Carvalho Chehab { lat:        249, common_pid:       2036 } hitcount:         27
2782ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2038 } hitcount:          1
2783ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2036 } hitcount:         30
2784ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2040 } hitcount:         19
2785ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2043 } hitcount:         22
2786ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2042 } hitcount:         20
2787ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2041 } hitcount:          1
2788ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2039 } hitcount:          6
2789ea272257SMauro Carvalho Chehab { lat:        250, common_pid:       2037 } hitcount:         48
2790ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2037 } hitcount:         43
2791ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2039 } hitcount:          1
2792ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2036 } hitcount:         12
2793ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2042 } hitcount:          2
2794ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2041 } hitcount:          1
2795ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2043 } hitcount:         15
2796ea272257SMauro Carvalho Chehab { lat:        251, common_pid:       2040 } hitcount:          3
2797ea272257SMauro Carvalho Chehab { lat:        252, common_pid:       2040 } hitcount:          1
2798ea272257SMauro Carvalho Chehab { lat:        252, common_pid:       2036 } hitcount:         12
2799ea272257SMauro Carvalho Chehab { lat:        252, common_pid:       2037 } hitcount:         21
2800ea272257SMauro Carvalho Chehab { lat:        252, common_pid:       2043 } hitcount:         14
2801ea272257SMauro Carvalho Chehab { lat:        253, common_pid:       2037 } hitcount:         21
2802ea272257SMauro Carvalho Chehab { lat:        253, common_pid:       2039 } hitcount:          2
2803ea272257SMauro Carvalho Chehab { lat:        253, common_pid:       2036 } hitcount:          9
2804ea272257SMauro Carvalho Chehab { lat:        253, common_pid:       2043 } hitcount:          6
2805ea272257SMauro Carvalho Chehab { lat:        253, common_pid:       2040 } hitcount:          1
2806ea272257SMauro Carvalho Chehab { lat:        254, common_pid:       2036 } hitcount:          8
2807ea272257SMauro Carvalho Chehab { lat:        254, common_pid:       2043 } hitcount:          3
2808ea272257SMauro Carvalho Chehab { lat:        254, common_pid:       2041 } hitcount:          1
2809ea272257SMauro Carvalho Chehab { lat:        254, common_pid:       2042 } hitcount:          1
2810ea272257SMauro Carvalho Chehab { lat:        254, common_pid:       2039 } hitcount:          1
2811ea272257SMauro Carvalho Chehab { lat:        254, common_pid:       2037 } hitcount:         12
2812ea272257SMauro Carvalho Chehab { lat:        255, common_pid:       2043 } hitcount:          1
2813ea272257SMauro Carvalho Chehab { lat:        255, common_pid:       2037 } hitcount:          2
2814ea272257SMauro Carvalho Chehab { lat:        255, common_pid:       2036 } hitcount:          2
2815ea272257SMauro Carvalho Chehab { lat:        255, common_pid:       2039 } hitcount:          8
2816ea272257SMauro Carvalho Chehab { lat:        256, common_pid:       2043 } hitcount:          1
2817ea272257SMauro Carvalho Chehab { lat:        256, common_pid:       2036 } hitcount:          4
2818ea272257SMauro Carvalho Chehab { lat:        256, common_pid:       2039 } hitcount:          6
2819ea272257SMauro Carvalho Chehab { lat:        257, common_pid:       2039 } hitcount:          5
2820ea272257SMauro Carvalho Chehab { lat:        257, common_pid:       2036 } hitcount:          4
2821ea272257SMauro Carvalho Chehab { lat:        258, common_pid:       2039 } hitcount:          5
2822ea272257SMauro Carvalho Chehab { lat:        258, common_pid:       2036 } hitcount:          2
2823ea272257SMauro Carvalho Chehab { lat:        259, common_pid:       2036 } hitcount:          7
2824ea272257SMauro Carvalho Chehab { lat:        259, common_pid:       2039 } hitcount:          7
2825ea272257SMauro Carvalho Chehab { lat:        260, common_pid:       2036 } hitcount:          8
2826ea272257SMauro Carvalho Chehab { lat:        260, common_pid:       2039 } hitcount:          6
2827ea272257SMauro Carvalho Chehab { lat:        261, common_pid:       2036 } hitcount:          5
2828ea272257SMauro Carvalho Chehab { lat:        261, common_pid:       2039 } hitcount:          7
2829ea272257SMauro Carvalho Chehab { lat:        262, common_pid:       2039 } hitcount:          5
2830ea272257SMauro Carvalho Chehab { lat:        262, common_pid:       2036 } hitcount:          5
2831ea272257SMauro Carvalho Chehab { lat:        263, common_pid:       2039 } hitcount:          7
2832ea272257SMauro Carvalho Chehab { lat:        263, common_pid:       2036 } hitcount:          7
2833ea272257SMauro Carvalho Chehab { lat:        264, common_pid:       2039 } hitcount:          9
2834ea272257SMauro Carvalho Chehab { lat:        264, common_pid:       2036 } hitcount:          9
2835ea272257SMauro Carvalho Chehab { lat:        265, common_pid:       2036 } hitcount:          5
2836ea272257SMauro Carvalho Chehab { lat:        265, common_pid:       2039 } hitcount:          1
2837ea272257SMauro Carvalho Chehab { lat:        266, common_pid:       2036 } hitcount:          1
2838ea272257SMauro Carvalho Chehab { lat:        266, common_pid:       2039 } hitcount:          3
2839ea272257SMauro Carvalho Chehab { lat:        267, common_pid:       2036 } hitcount:          1
2840ea272257SMauro Carvalho Chehab { lat:        267, common_pid:       2039 } hitcount:          3
2841ea272257SMauro Carvalho Chehab { lat:        268, common_pid:       2036 } hitcount:          1
2842ea272257SMauro Carvalho Chehab { lat:        268, common_pid:       2039 } hitcount:          6
2843ea272257SMauro Carvalho Chehab { lat:        269, common_pid:       2036 } hitcount:          1
2844ea272257SMauro Carvalho Chehab { lat:        269, common_pid:       2043 } hitcount:          1
2845ea272257SMauro Carvalho Chehab { lat:        269, common_pid:       2039 } hitcount:          2
2846ea272257SMauro Carvalho Chehab { lat:        270, common_pid:       2040 } hitcount:          1
2847ea272257SMauro Carvalho Chehab { lat:        270, common_pid:       2039 } hitcount:          6
2848ea272257SMauro Carvalho Chehab { lat:        271, common_pid:       2041 } hitcount:          1
2849ea272257SMauro Carvalho Chehab { lat:        271, common_pid:       2039 } hitcount:          5
2850ea272257SMauro Carvalho Chehab { lat:        272, common_pid:       2039 } hitcount:         10
2851ea272257SMauro Carvalho Chehab { lat:        273, common_pid:       2039 } hitcount:          8
2852ea272257SMauro Carvalho Chehab { lat:        274, common_pid:       2039 } hitcount:          2
2853ea272257SMauro Carvalho Chehab { lat:        275, common_pid:       2039 } hitcount:          1
2854ea272257SMauro Carvalho Chehab { lat:        276, common_pid:       2039 } hitcount:          2
2855ea272257SMauro Carvalho Chehab { lat:        276, common_pid:       2037 } hitcount:          1
2856ea272257SMauro Carvalho Chehab { lat:        276, common_pid:       2038 } hitcount:          1
2857ea272257SMauro Carvalho Chehab { lat:        277, common_pid:       2039 } hitcount:          1
2858ea272257SMauro Carvalho Chehab { lat:        277, common_pid:       2042 } hitcount:          1
2859ea272257SMauro Carvalho Chehab { lat:        278, common_pid:       2039 } hitcount:          1
2860ea272257SMauro Carvalho Chehab { lat:        279, common_pid:       2039 } hitcount:          4
2861ea272257SMauro Carvalho Chehab { lat:        279, common_pid:       2043 } hitcount:          1
2862ea272257SMauro Carvalho Chehab { lat:        280, common_pid:       2039 } hitcount:          3
2863ea272257SMauro Carvalho Chehab { lat:        283, common_pid:       2036 } hitcount:          2
2864ea272257SMauro Carvalho Chehab { lat:        284, common_pid:       2039 } hitcount:          1
2865ea272257SMauro Carvalho Chehab { lat:        284, common_pid:       2043 } hitcount:          1
2866ea272257SMauro Carvalho Chehab { lat:        288, common_pid:       2039 } hitcount:          1
2867ea272257SMauro Carvalho Chehab { lat:        289, common_pid:       2039 } hitcount:          1
2868ea272257SMauro Carvalho Chehab { lat:        300, common_pid:       2039 } hitcount:          1
2869ea272257SMauro Carvalho Chehab { lat:        384, common_pid:       2039 } hitcount:          1
2870ea272257SMauro Carvalho Chehab
2871ea272257SMauro Carvalho Chehab Totals:
2872ea272257SMauro Carvalho Chehab     Hits: 67625
2873ea272257SMauro Carvalho Chehab     Entries: 278
2874ea272257SMauro Carvalho Chehab     Dropped: 0
2875ea272257SMauro Carvalho Chehab
2876ea272257SMauro Carvalho ChehabNote, the writes are around the sleep, so ideally they will all be of 250
2877ea272257SMauro Carvalho Chehabmicroseconds. If you are wondering how there are several that are under
2878ea272257SMauro Carvalho Chehab250 microseconds, that is because the way cyclictest works, is if one
2879ea272257SMauro Carvalho Chehabiteration comes in late, the next one will set the timer to wake up less that
2880ea272257SMauro Carvalho Chehab250. That is, if an iteration came in 50 microseconds late, the next wake up
2881ea272257SMauro Carvalho Chehabwill be at 200 microseconds.
2882ea272257SMauro Carvalho Chehab
2883ea272257SMauro Carvalho ChehabBut this could easily be done in userspace. To make this even more
2884ea272257SMauro Carvalho Chehabinteresting, we can mix the histogram between events that happened in the
2885ea272257SMauro Carvalho Chehabkernel with trace_marker::
2886ea272257SMauro Carvalho Chehab
2887ea272257SMauro Carvalho Chehab # cd /sys/kernel/tracing
2888ea272257SMauro Carvalho Chehab # echo 'latency u64 lat' > synthetic_events
2889ea272257SMauro Carvalho Chehab # echo 'hist:keys=pid:ts0=common_timestamp.usecs' > events/sched/sched_waking/trigger
2890ea272257SMauro 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
2891ea272257SMauro Carvalho Chehab # echo 'hist:keys=lat,common_pid:sort=lat' > events/synthetic/latency/trigger
2892ea272257SMauro Carvalho Chehab
2893ea272257SMauro Carvalho ChehabThe difference this time is that instead of using the trace_marker to start
2894ea272257SMauro Carvalho Chehabthe latency, the sched_waking event is used, matching the common_pid for the
2895ea272257SMauro Carvalho Chehabtrace_marker write with the pid that is being woken by sched_waking.
2896ea272257SMauro Carvalho Chehab
2897ea272257SMauro Carvalho ChehabAfter running cyclictest again with the same parameters, we now have::
2898ea272257SMauro Carvalho Chehab
2899ea272257SMauro Carvalho Chehab # cat events/synthetic/latency/hist
2900ea272257SMauro Carvalho Chehab # event histogram
2901ea272257SMauro Carvalho Chehab #
2902ea272257SMauro Carvalho Chehab # trigger info: hist:keys=lat,common_pid:vals=hitcount:sort=lat:size=2048 [active]
2903ea272257SMauro Carvalho Chehab #
2904ea272257SMauro Carvalho Chehab
2905ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2302 } hitcount:        640
2906ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2299 } hitcount:         42
2907ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2303 } hitcount:         18
2908ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2305 } hitcount:        166
2909ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2306 } hitcount:          1
2910ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2301 } hitcount:         91
2911ea272257SMauro Carvalho Chehab { lat:          7, common_pid:       2300 } hitcount:         17
2912ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2303 } hitcount:       8296
2913ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2304 } hitcount:       6864
2914ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2305 } hitcount:       9464
2915ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2301 } hitcount:       9213
2916ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2306 } hitcount:       6246
2917ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2302 } hitcount:       8797
2918ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2299 } hitcount:       8771
2919ea272257SMauro Carvalho Chehab { lat:          8, common_pid:       2300 } hitcount:       8119
2920ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2305 } hitcount:       1519
2921ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2299 } hitcount:       2346
2922ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2303 } hitcount:       2841
2923ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2301 } hitcount:       1846
2924ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2304 } hitcount:       3861
2925ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2302 } hitcount:       1210
2926ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2300 } hitcount:       2762
2927ea272257SMauro Carvalho Chehab { lat:          9, common_pid:       2306 } hitcount:       4247
2928ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2299 } hitcount:         16
2929ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2306 } hitcount:        333
2930ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2303 } hitcount:         16
2931ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2304 } hitcount:        168
2932ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2302 } hitcount:        240
2933ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2301 } hitcount:         28
2934ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2300 } hitcount:         95
2935ea272257SMauro Carvalho Chehab { lat:         10, common_pid:       2305 } hitcount:         18
2936ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2303 } hitcount:          5
2937ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2305 } hitcount:          8
2938ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2306 } hitcount:        221
2939ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2302 } hitcount:         76
2940ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2304 } hitcount:         26
2941ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2300 } hitcount:        125
2942ea272257SMauro Carvalho Chehab { lat:         11, common_pid:       2299 } hitcount:          2
2943ea272257SMauro Carvalho Chehab { lat:         12, common_pid:       2305 } hitcount:          3
2944ea272257SMauro Carvalho Chehab { lat:         12, common_pid:       2300 } hitcount:          6
2945ea272257SMauro Carvalho Chehab { lat:         12, common_pid:       2306 } hitcount:         90
2946ea272257SMauro Carvalho Chehab { lat:         12, common_pid:       2302 } hitcount:          4
2947ea272257SMauro Carvalho Chehab { lat:         12, common_pid:       2303 } hitcount:          1
2948ea272257SMauro Carvalho Chehab { lat:         12, common_pid:       2304 } hitcount:        122
2949ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2300 } hitcount:         12
2950ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2301 } hitcount:          1
2951ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2306 } hitcount:         32
2952ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2302 } hitcount:          5
2953ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2305 } hitcount:          1
2954ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2303 } hitcount:          1
2955ea272257SMauro Carvalho Chehab { lat:         13, common_pid:       2304 } hitcount:         61
2956ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2303 } hitcount:          4
2957ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2306 } hitcount:          5
2958ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2305 } hitcount:          4
2959ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2304 } hitcount:         62
2960ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2302 } hitcount:         19
2961ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2300 } hitcount:         33
2962ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2299 } hitcount:          1
2963ea272257SMauro Carvalho Chehab { lat:         14, common_pid:       2301 } hitcount:          4
2964ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2305 } hitcount:          1
2965ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2302 } hitcount:         25
2966ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2300 } hitcount:         11
2967ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2299 } hitcount:          5
2968ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2301 } hitcount:          1
2969ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2304 } hitcount:          8
2970ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2303 } hitcount:          1
2971ea272257SMauro Carvalho Chehab { lat:         15, common_pid:       2306 } hitcount:          6
2972ea272257SMauro Carvalho Chehab { lat:         16, common_pid:       2302 } hitcount:         31
2973ea272257SMauro Carvalho Chehab { lat:         16, common_pid:       2306 } hitcount:          3
2974ea272257SMauro Carvalho Chehab { lat:         16, common_pid:       2300 } hitcount:          5
2975ea272257SMauro Carvalho Chehab { lat:         17, common_pid:       2302 } hitcount:          6
2976ea272257SMauro Carvalho Chehab { lat:         17, common_pid:       2303 } hitcount:          1
2977ea272257SMauro Carvalho Chehab { lat:         18, common_pid:       2304 } hitcount:          1
2978ea272257SMauro Carvalho Chehab { lat:         18, common_pid:       2302 } hitcount:          8
2979ea272257SMauro Carvalho Chehab { lat:         18, common_pid:       2299 } hitcount:          1
2980ea272257SMauro Carvalho Chehab { lat:         18, common_pid:       2301 } hitcount:          1
2981ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2303 } hitcount:          4
2982ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2304 } hitcount:          5
2983ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2302 } hitcount:          4
2984ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2299 } hitcount:          3
2985ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2306 } hitcount:          1
2986ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2300 } hitcount:          4
2987ea272257SMauro Carvalho Chehab { lat:         19, common_pid:       2305 } hitcount:          5
2988ea272257SMauro Carvalho Chehab { lat:         20, common_pid:       2299 } hitcount:          2
2989ea272257SMauro Carvalho Chehab { lat:         20, common_pid:       2302 } hitcount:          3
2990ea272257SMauro Carvalho Chehab { lat:         20, common_pid:       2305 } hitcount:          1
2991ea272257SMauro Carvalho Chehab { lat:         20, common_pid:       2300 } hitcount:          2
2992ea272257SMauro Carvalho Chehab { lat:         20, common_pid:       2301 } hitcount:          2
2993ea272257SMauro Carvalho Chehab { lat:         20, common_pid:       2303 } hitcount:          3
2994ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2305 } hitcount:          1
2995ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2299 } hitcount:          5
2996ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2303 } hitcount:          4
2997ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2302 } hitcount:          7
2998ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2300 } hitcount:          1
2999ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2301 } hitcount:          5
3000ea272257SMauro Carvalho Chehab { lat:         21, common_pid:       2304 } hitcount:          2
3001ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2302 } hitcount:          5
3002ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2303 } hitcount:          1
3003ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2306 } hitcount:          3
3004ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2301 } hitcount:          2
3005ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2300 } hitcount:          1
3006ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2299 } hitcount:          1
3007ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2305 } hitcount:          1
3008ea272257SMauro Carvalho Chehab { lat:         22, common_pid:       2304 } hitcount:          1
3009ea272257SMauro Carvalho Chehab { lat:         23, common_pid:       2299 } hitcount:          1
3010ea272257SMauro Carvalho Chehab { lat:         23, common_pid:       2306 } hitcount:          2
3011ea272257SMauro Carvalho Chehab { lat:         23, common_pid:       2302 } hitcount:          6
3012ea272257SMauro Carvalho Chehab { lat:         24, common_pid:       2302 } hitcount:          3
3013ea272257SMauro Carvalho Chehab { lat:         24, common_pid:       2300 } hitcount:          1
3014ea272257SMauro Carvalho Chehab { lat:         24, common_pid:       2306 } hitcount:          2
3015ea272257SMauro Carvalho Chehab { lat:         24, common_pid:       2305 } hitcount:          1
3016ea272257SMauro Carvalho Chehab { lat:         24, common_pid:       2299 } hitcount:          1
3017ea272257SMauro Carvalho Chehab { lat:         25, common_pid:       2300 } hitcount:          1
3018ea272257SMauro Carvalho Chehab { lat:         25, common_pid:       2302 } hitcount:          4
3019ea272257SMauro Carvalho Chehab { lat:         26, common_pid:       2302 } hitcount:          2
3020ea272257SMauro Carvalho Chehab { lat:         27, common_pid:       2305 } hitcount:          1
3021ea272257SMauro Carvalho Chehab { lat:         27, common_pid:       2300 } hitcount:          1
3022ea272257SMauro Carvalho Chehab { lat:         27, common_pid:       2302 } hitcount:          3
3023ea272257SMauro Carvalho Chehab { lat:         28, common_pid:       2306 } hitcount:          1
3024ea272257SMauro Carvalho Chehab { lat:         28, common_pid:       2302 } hitcount:          4
3025ea272257SMauro Carvalho Chehab { lat:         29, common_pid:       2302 } hitcount:          1
3026ea272257SMauro Carvalho Chehab { lat:         29, common_pid:       2300 } hitcount:          2
3027ea272257SMauro Carvalho Chehab { lat:         29, common_pid:       2306 } hitcount:          1
3028ea272257SMauro Carvalho Chehab { lat:         29, common_pid:       2304 } hitcount:          1
3029ea272257SMauro Carvalho Chehab { lat:         30, common_pid:       2302 } hitcount:          4
3030ea272257SMauro Carvalho Chehab { lat:         31, common_pid:       2302 } hitcount:          6
3031ea272257SMauro Carvalho Chehab { lat:         32, common_pid:       2302 } hitcount:          1
3032ea272257SMauro Carvalho Chehab { lat:         33, common_pid:       2299 } hitcount:          1
3033ea272257SMauro Carvalho Chehab { lat:         33, common_pid:       2302 } hitcount:          3
3034ea272257SMauro Carvalho Chehab { lat:         34, common_pid:       2302 } hitcount:          2
3035ea272257SMauro Carvalho Chehab { lat:         35, common_pid:       2302 } hitcount:          1
3036ea272257SMauro Carvalho Chehab { lat:         35, common_pid:       2304 } hitcount:          1
3037ea272257SMauro Carvalho Chehab { lat:         36, common_pid:       2302 } hitcount:          4
3038ea272257SMauro Carvalho Chehab { lat:         37, common_pid:       2302 } hitcount:          6
3039ea272257SMauro Carvalho Chehab { lat:         38, common_pid:       2302 } hitcount:          2
3040ea272257SMauro Carvalho Chehab { lat:         39, common_pid:       2302 } hitcount:          2
3041ea272257SMauro Carvalho Chehab { lat:         39, common_pid:       2304 } hitcount:          1
3042ea272257SMauro Carvalho Chehab { lat:         40, common_pid:       2304 } hitcount:          2
3043ea272257SMauro Carvalho Chehab { lat:         40, common_pid:       2302 } hitcount:          5
3044ea272257SMauro Carvalho Chehab { lat:         41, common_pid:       2304 } hitcount:          1
3045ea272257SMauro Carvalho Chehab { lat:         41, common_pid:       2302 } hitcount:          8
3046ea272257SMauro Carvalho Chehab { lat:         42, common_pid:       2302 } hitcount:          6
3047ea272257SMauro Carvalho Chehab { lat:         42, common_pid:       2304 } hitcount:          1
3048ea272257SMauro Carvalho Chehab { lat:         43, common_pid:       2302 } hitcount:          3
3049ea272257SMauro Carvalho Chehab { lat:         43, common_pid:       2304 } hitcount:          4
3050ea272257SMauro Carvalho Chehab { lat:         44, common_pid:       2302 } hitcount:          6
3051ea272257SMauro Carvalho Chehab { lat:         45, common_pid:       2302 } hitcount:          5
3052ea272257SMauro Carvalho Chehab { lat:         46, common_pid:       2302 } hitcount:          5
3053ea272257SMauro Carvalho Chehab { lat:         47, common_pid:       2302 } hitcount:          7
3054ea272257SMauro Carvalho Chehab { lat:         48, common_pid:       2301 } hitcount:          1
3055ea272257SMauro Carvalho Chehab { lat:         48, common_pid:       2302 } hitcount:          9
3056ea272257SMauro Carvalho Chehab { lat:         49, common_pid:       2302 } hitcount:          3
3057ea272257SMauro Carvalho Chehab { lat:         50, common_pid:       2302 } hitcount:          1
3058ea272257SMauro Carvalho Chehab { lat:         50, common_pid:       2301 } hitcount:          1
3059ea272257SMauro Carvalho Chehab { lat:         51, common_pid:       2302 } hitcount:          2
3060ea272257SMauro Carvalho Chehab { lat:         51, common_pid:       2301 } hitcount:          1
3061ea272257SMauro Carvalho Chehab { lat:         61, common_pid:       2302 } hitcount:          1
3062ea272257SMauro Carvalho Chehab { lat:        110, common_pid:       2302 } hitcount:          1
3063ea272257SMauro Carvalho Chehab
3064ea272257SMauro Carvalho Chehab Totals:
3065ea272257SMauro Carvalho Chehab     Hits: 89565
3066ea272257SMauro Carvalho Chehab     Entries: 158
3067ea272257SMauro Carvalho Chehab     Dropped: 0
3068ea272257SMauro Carvalho Chehab
3069ea272257SMauro Carvalho ChehabThis doesn't tell us any information about how late cyclictest may have
3070ea272257SMauro Carvalho Chehabwoken up, but it does show us a nice histogram of how long it took from
3071ea272257SMauro Carvalho Chehabthe time that cyclictest was woken to the time it made it into user space.
3072