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