History

perf script: Add callchain to generic and tracepoint events

This provides valuable information for tracing performance problems. Since this change alters the interface for the python scripts, also adjust the script generation and the provided scripts.

Joseph Schuchart committed 12 years ago

Commit 0f5f5bc1 parent 05f832e11 files · +146 −48Browse files

Showing the changes to tools/perf/scripts/python (10 of 11 files). Show all

Unified · Split

10 files
  1. tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py +2 −1
  2. tools/perf/scripts/python/check-perf-trace.py +2 −2
  3. tools/perf/scripts/python/failed-syscalls-by-pid.py +1 −1
  4. tools/perf/scripts/python/futex-contention.py +2 −2
  5. tools/perf/scripts/python/net_dropmonitor.py +1 −1
  6. tools/perf/scripts/python/netdev-times.py +13 −13
  7. tools/perf/scripts/python/sched-migration.py +20 −21
  8. tools/perf/scripts/python/sctop.py +1 −1
  9. tools/perf/scripts/python/syscall-counts-by-pid.py +1 −1
  10. tools/perf/scripts/python/syscall-counts.py +1 −1
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py+2−1
@@ -107,12 +107,13 @@ def taskState(state): · 106 unmodified lines
107 107
108class EventHeaders:108class EventHeaders:
109 def __init__(self, common_cpu, common_secs, common_nsecs,109 def __init__(self, common_cpu, common_secs, common_nsecs,
110 common_pid, common_comm):110 common_pid, common_comm, common_callchain):
111 self.cpu = common_cpu111 self.cpu = common_cpu
112 self.secs = common_secs112 self.secs = common_secs
113 self.nsecs = common_nsecs113 self.nsecs = common_nsecs
114 self.pid = common_pid114 self.pid = common_pid
115 self.comm = common_comm115 self.comm = common_comm
116 self.callchain = common_callchain
116 117
117 def ts(self):118 def ts(self):
118 return (self.secs * (10 ** 9)) + self.nsecs119 return (self.secs * (10 ** 9)) + self.nsecs
tools/perf/scripts/python/check-perf-trace.py+2−2
@@ -27,7 +27,7 @@ def trace_end(): · 26 unmodified lines
27 27
28def irq__softirq_entry(event_name, context, common_cpu,28def irq__softirq_entry(event_name, context, common_cpu,
29 common_secs, common_nsecs, common_pid, common_comm,29 common_secs, common_nsecs, common_pid, common_comm,
30 vec):30 common_callchain, vec):
31 print_header(event_name, common_cpu, common_secs, common_nsecs,31 print_header(event_name, common_cpu, common_secs, common_nsecs,
32 common_pid, common_comm)32 common_pid, common_comm)
33 33
@@ -38,7 +38,7 @@ def irq__softirq_entry(event_name, context, common_cpu, · 4 unmodified lines
38 38
39def kmem__kmalloc(event_name, context, common_cpu,39def kmem__kmalloc(event_name, context, common_cpu,
40 common_secs, common_nsecs, common_pid, common_comm,40 common_secs, common_nsecs, common_pid, common_comm,
41 call_site, ptr, bytes_req, bytes_alloc,41 common_callchain, call_site, ptr, bytes_req, bytes_alloc,
42 gfp_flags):42 gfp_flags):
43 print_header(event_name, common_cpu, common_secs, common_nsecs,43 print_header(event_name, common_cpu, common_secs, common_nsecs,
44 common_pid, common_comm)44 common_pid, common_comm)
tools/perf/scripts/python/failed-syscalls-by-pid.py+1−1
@@ -39,7 +39,7 @@ def trace_end(): · 38 unmodified lines
39 39
40def raw_syscalls__sys_exit(event_name, context, common_cpu,40def raw_syscalls__sys_exit(event_name, context, common_cpu,
41 common_secs, common_nsecs, common_pid, common_comm,41 common_secs, common_nsecs, common_pid, common_comm,
42 id, ret):42 common_callchain, id, ret):
43 if (for_comm and common_comm != for_comm) or \43 if (for_comm and common_comm != for_comm) or \
44 (for_pid and common_pid != for_pid ):44 (for_pid and common_pid != for_pid ):
45 return45 return
tools/perf/scripts/python/futex-contention.py+2−2
@@ -21,7 +21,7 @@ thread_blocktime = {} · 20 unmodified lines
21lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time21lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time
22process_names = {} # long-lived pid-to-execname mapping22process_names = {} # long-lived pid-to-execname mapping
23 23
24def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm,24def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, callchain,
25 nr, uaddr, op, val, utime, uaddr2, val3):25 nr, uaddr, op, val, utime, uaddr2, val3):
26 cmd = op & FUTEX_CMD_MASK26 cmd = op & FUTEX_CMD_MASK
27 if cmd != FUTEX_WAIT:27 if cmd != FUTEX_WAIT:
@@ -31,7 +31,7 @@ def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, · 3 unmodified lines
31 thread_thislock[tid] = uaddr31 thread_thislock[tid] = uaddr
32 thread_blocktime[tid] = nsecs(s, ns)32 thread_blocktime[tid] = nsecs(s, ns)
33 33
34def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm,34def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, callchain,
35 nr, ret):35 nr, ret):
36 if thread_blocktime.has_key(tid):36 if thread_blocktime.has_key(tid):
37 elapsed = nsecs(s, ns) - thread_blocktime[tid]37 elapsed = nsecs(s, ns) - thread_blocktime[tid]
tools/perf/scripts/python/net_dropmonitor.py+1−1
@@ -66,7 +66,7 @@ def trace_end(): · 65 unmodified lines
66 print_drop_table()66 print_drop_table()
67 67
68# called from perf, when it finds a correspoinding event68# called from perf, when it finds a correspoinding event
69def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm,69def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, callchain,
70 skbaddr, location, protocol):70 skbaddr, location, protocol):
71 slocation = str(location)71 slocation = str(location)
72 try:72 try:
tools/perf/scripts/python/netdev-times.py+13−13
@@ -224,75 +224,75 @@ def trace_end(): · 223 unmodified lines
224 (len(rx_skb_list), of_count_rx_skb_list)224 (len(rx_skb_list), of_count_rx_skb_list)
225 225
226# called from perf, when it finds a correspoinding event226# called from perf, when it finds a correspoinding event
227def irq__softirq_entry(name, context, cpu, sec, nsec, pid, comm, vec):227def irq__softirq_entry(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
228 if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":228 if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
229 return229 return
230 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)230 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
231 all_event_list.append(event_info)231 all_event_list.append(event_info)
232 232
233def irq__softirq_exit(name, context, cpu, sec, nsec, pid, comm, vec):233def irq__softirq_exit(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
234 if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":234 if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
235 return235 return
236 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)236 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
237 all_event_list.append(event_info)237 all_event_list.append(event_info)
238 238
239def irq__softirq_raise(name, context, cpu, sec, nsec, pid, comm, vec):239def irq__softirq_raise(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
240 if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":240 if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
241 return241 return
242 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)242 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
243 all_event_list.append(event_info)243 all_event_list.append(event_info)
244 244
245def irq__irq_handler_entry(name, context, cpu, sec, nsec, pid, comm,245def irq__irq_handler_entry(name, context, cpu, sec, nsec, pid, comm,
246 irq, irq_name):246 callchain, irq, irq_name):
247 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,247 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
248 irq, irq_name)248 irq, irq_name)
249 all_event_list.append(event_info)249 all_event_list.append(event_info)
250 250
251def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, irq, ret):251def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, callchain, irq, ret):
252 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, irq, ret)252 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, irq, ret)
253 all_event_list.append(event_info)253 all_event_list.append(event_info)
254 254
255def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, napi, dev_name):255def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi, dev_name):
256 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,256 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
257 napi, dev_name)257 napi, dev_name)
258 all_event_list.append(event_info)258 all_event_list.append(event_info)
259 259
260def net__netif_receive_skb(name, context, cpu, sec, nsec, pid, comm, skbaddr,260def net__netif_receive_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr,
261 skblen, dev_name):261 skblen, dev_name):
262 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,262 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
263 skbaddr, skblen, dev_name)263 skbaddr, skblen, dev_name)
264 all_event_list.append(event_info)264 all_event_list.append(event_info)
265 265
266def net__netif_rx(name, context, cpu, sec, nsec, pid, comm, skbaddr,266def net__netif_rx(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr,
267 skblen, dev_name):267 skblen, dev_name):
268 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,268 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
269 skbaddr, skblen, dev_name)269 skbaddr, skblen, dev_name)
270 all_event_list.append(event_info)270 all_event_list.append(event_info)
271 271
272def net__net_dev_queue(name, context, cpu, sec, nsec, pid, comm,272def net__net_dev_queue(name, context, cpu, sec, nsec, pid, comm, callchain,
273 skbaddr, skblen, dev_name):273 skbaddr, skblen, dev_name):
274 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,274 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
275 skbaddr, skblen, dev_name)275 skbaddr, skblen, dev_name)
276 all_event_list.append(event_info)276 all_event_list.append(event_info)
277 277
278def net__net_dev_xmit(name, context, cpu, sec, nsec, pid, comm,278def net__net_dev_xmit(name, context, cpu, sec, nsec, pid, comm, callchain,
279 skbaddr, skblen, rc, dev_name):279 skbaddr, skblen, rc, dev_name):
280 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,280 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
281 skbaddr, skblen, rc ,dev_name)281 skbaddr, skblen, rc ,dev_name)
282 all_event_list.append(event_info)282 all_event_list.append(event_info)
283 283
284def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm,284def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, callchain,
285 skbaddr, protocol, location):285 skbaddr, protocol, location):
286 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,286 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
287 skbaddr, protocol, location)287 skbaddr, protocol, location)
288 all_event_list.append(event_info)288 all_event_list.append(event_info)
289 289
290def skb__consume_skb(name, context, cpu, sec, nsec, pid, comm, skbaddr):290def skb__consume_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr):
291 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,291 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
292 skbaddr)292 skbaddr)
293 all_event_list.append(event_info)293 all_event_list.append(event_info)
294 294
295def skb__skb_copy_datagram_iovec(name, context, cpu, sec, nsec, pid, comm,295def skb__skb_copy_datagram_iovec(name, context, cpu, sec, nsec, pid, comm, callchain,
296 skbaddr, skblen):296 skbaddr, skblen):
297 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,297 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
298 skbaddr, skblen)298 skbaddr, skblen)
tools/perf/scripts/python/sched-migration.py+20−21
@@ -369,93 +369,92 @@ def trace_end(): · 368 unmodified lines
369 369
370def sched__sched_stat_runtime(event_name, context, common_cpu,370def sched__sched_stat_runtime(event_name, context, common_cpu,
371 common_secs, common_nsecs, common_pid, common_comm,371 common_secs, common_nsecs, common_pid, common_comm,
372 comm, pid, runtime, vruntime):372 common_callchain, comm, pid, runtime, vruntime):
373 pass373 pass
374 374
375def sched__sched_stat_iowait(event_name, context, common_cpu,375def sched__sched_stat_iowait(event_name, context, common_cpu,
376 common_secs, common_nsecs, common_pid, common_comm,376 common_secs, common_nsecs, common_pid, common_comm,
377 comm, pid, delay):377 common_callchain, comm, pid, delay):
378 pass378 pass
379 379
380def sched__sched_stat_sleep(event_name, context, common_cpu,380def sched__sched_stat_sleep(event_name, context, common_cpu,
381 common_secs, common_nsecs, common_pid, common_comm,381 common_secs, common_nsecs, common_pid, common_comm,
382 comm, pid, delay):382 common_callchain, comm, pid, delay):
383 pass383 pass
384 384
385def sched__sched_stat_wait(event_name, context, common_cpu,385def sched__sched_stat_wait(event_name, context, common_cpu,
386 common_secs, common_nsecs, common_pid, common_comm,386 common_secs, common_nsecs, common_pid, common_comm,
387 comm, pid, delay):387 common_callchain, comm, pid, delay):
388 pass388 pass
389 389
390def sched__sched_process_fork(event_name, context, common_cpu,390def sched__sched_process_fork(event_name, context, common_cpu,
391 common_secs, common_nsecs, common_pid, common_comm,391 common_secs, common_nsecs, common_pid, common_comm,
392 parent_comm, parent_pid, child_comm, child_pid):392 common_callchain, parent_comm, parent_pid, child_comm, child_pid):
393 pass393 pass
394 394
395def sched__sched_process_wait(event_name, context, common_cpu,395def sched__sched_process_wait(event_name, context, common_cpu,
396 common_secs, common_nsecs, common_pid, common_comm,396 common_secs, common_nsecs, common_pid, common_comm,
397 comm, pid, prio):397 common_callchain, comm, pid, prio):
398 pass398 pass
399 399
400def sched__sched_process_exit(event_name, context, common_cpu,400def sched__sched_process_exit(event_name, context, common_cpu,
401 common_secs, common_nsecs, common_pid, common_comm,401 common_secs, common_nsecs, common_pid, common_comm,
402 comm, pid, prio):402 common_callchain, comm, pid, prio):
403 pass403 pass
404 404
405def sched__sched_process_free(event_name, context, common_cpu,405def sched__sched_process_free(event_name, context, common_cpu,
406 common_secs, common_nsecs, common_pid, common_comm,406 common_secs, common_nsecs, common_pid, common_comm,
407 comm, pid, prio):407 common_callchain, comm, pid, prio):
408 pass408 pass
409 409
410def sched__sched_migrate_task(event_name, context, common_cpu,410def sched__sched_migrate_task(event_name, context, common_cpu,
411 common_secs, common_nsecs, common_pid, common_comm,411 common_secs, common_nsecs, common_pid, common_comm,
412 comm, pid, prio, orig_cpu,412 common_callchain, comm, pid, prio, orig_cpu,
413 dest_cpu):413 dest_cpu):
414 headers = EventHeaders(common_cpu, common_secs, common_nsecs,414 headers = EventHeaders(common_cpu, common_secs, common_nsecs,
415 common_pid, common_comm)415 common_pid, common_comm, common_callchain)
416 parser.migrate(headers, pid, prio, orig_cpu, dest_cpu)416 parser.migrate(headers, pid, prio, orig_cpu, dest_cpu)
417 417
418def sched__sched_switch(event_name, context, common_cpu,418def sched__sched_switch(event_name, context, common_cpu,
419 common_secs, common_nsecs, common_pid, common_comm,419 common_secs, common_nsecs, common_pid, common_comm, common_callchain,
420 prev_comm, prev_pid, prev_prio, prev_state,420 prev_comm, prev_pid, prev_prio, prev_state,
421 next_comm, next_pid, next_prio):421 next_comm, next_pid, next_prio):
422 422
423 headers = EventHeaders(common_cpu, common_secs, common_nsecs,423 headers = EventHeaders(common_cpu, common_secs, common_nsecs,
424 common_pid, common_comm)424 common_pid, common_comm, common_callchain)
425 parser.sched_switch(headers, prev_comm, prev_pid, prev_prio, prev_state,425 parser.sched_switch(headers, prev_comm, prev_pid, prev_prio, prev_state,
426 next_comm, next_pid, next_prio)426 next_comm, next_pid, next_prio)
427 427
428def sched__sched_wakeup_new(event_name, context, common_cpu,428def sched__sched_wakeup_new(event_name, context, common_cpu,
429 common_secs, common_nsecs, common_pid, common_comm,429 common_secs, common_nsecs, common_pid, common_comm,
430 comm, pid, prio, success,430 common_callchain, comm, pid, prio, success,
431 target_cpu):431 target_cpu):
432 headers = EventHeaders(common_cpu, common_secs, common_nsecs,432 headers = EventHeaders(common_cpu, common_secs, common_nsecs,
433 common_pid, common_comm)433 common_pid, common_comm, common_callchain)
434 parser.wake_up(headers, comm, pid, success, target_cpu, 1)434 parser.wake_up(headers, comm, pid, success, target_cpu, 1)
435 435
436def sched__sched_wakeup(event_name, context, common_cpu,436def sched__sched_wakeup(event_name, context, common_cpu,
437 common_secs, common_nsecs, common_pid, common_comm,437 common_secs, common_nsecs, common_pid, common_comm,
438 comm, pid, prio, success,438 common_callchain, comm, pid, prio, success,
439 target_cpu):439 target_cpu):
440 headers = EventHeaders(common_cpu, common_secs, common_nsecs,440 headers = EventHeaders(common_cpu, common_secs, common_nsecs,
441 common_pid, common_comm)441 common_pid, common_comm, common_callchain)
442 parser.wake_up(headers, comm, pid, success, target_cpu, 0)442 parser.wake_up(headers, comm, pid, success, target_cpu, 0)
443 443
444def sched__sched_wait_task(event_name, context, common_cpu,444def sched__sched_wait_task(event_name, context, common_cpu,
445 common_secs, common_nsecs, common_pid, common_comm,445 common_secs, common_nsecs, common_pid, common_comm,
446 comm, pid, prio):446 common_callchain, comm, pid, prio):
447 pass447 pass
448 448
449def sched__sched_kthread_stop_ret(event_name, context, common_cpu,449def sched__sched_kthread_stop_ret(event_name, context, common_cpu,
450 common_secs, common_nsecs, common_pid, common_comm,450 common_secs, common_nsecs, common_pid, common_comm,
451 ret):451 common_callchain, ret):
452 pass452 pass
453 453
454def sched__sched_kthread_stop(event_name, context, common_cpu,454def sched__sched_kthread_stop(event_name, context, common_cpu,
455 common_secs, common_nsecs, common_pid, common_comm,455 common_secs, common_nsecs, common_pid, common_comm,
456 comm, pid):456 common_callchain, comm, pid):
457 pass457 pass
458 458
459def trace_unhandled(event_name, context, common_cpu, common_secs, common_nsecs,459def trace_unhandled(event_name, context, event_fields_dict):
460 common_pid, common_comm):
461 pass460 pass
tools/perf/scripts/python/sctop.py+1−1
@@ -44,7 +44,7 @@ def trace_begin(): · 43 unmodified lines
44 44
45def raw_syscalls__sys_enter(event_name, context, common_cpu,45def raw_syscalls__sys_enter(event_name, context, common_cpu,
46 common_secs, common_nsecs, common_pid, common_comm,46 common_secs, common_nsecs, common_pid, common_comm,
47 id, args):47 common_callchain, id, args):
48 if for_comm is not None:48 if for_comm is not None:
49 if common_comm != for_comm:49 if common_comm != for_comm:
50 return50 return
tools/perf/scripts/python/syscall-counts-by-pid.py+1−1
@@ -38,7 +38,7 @@ def trace_end(): · 37 unmodified lines
38 38
39def raw_syscalls__sys_enter(event_name, context, common_cpu,39def raw_syscalls__sys_enter(event_name, context, common_cpu,
40 common_secs, common_nsecs, common_pid, common_comm,40 common_secs, common_nsecs, common_pid, common_comm,
41 id, args):41 common_callchain, id, args):
42 42
43 if (for_comm and common_comm != for_comm) or \43 if (for_comm and common_comm != for_comm) or \
44 (for_pid and common_pid != for_pid ):44 (for_pid and common_pid != for_pid ):
tools/perf/scripts/python/syscall-counts.py+1−1
@@ -35,7 +35,7 @@ def trace_end(): · 34 unmodified lines
35 35
36def raw_syscalls__sys_enter(event_name, context, common_cpu,36def raw_syscalls__sys_enter(event_name, context, common_cpu,
37 common_secs, common_nsecs, common_pid, common_comm,37 common_secs, common_nsecs, common_pid, common_comm,
38 id, args):38 common_callchain, id, args):
39 if for_comm is not None:39 if for_comm is not None:
40 if common_comm != for_comm:40 if common_comm != for_comm:
41 return41 return