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
107107
108108 class EventHeaders:
109109 def __init__(self, common_cpu, common_secs, common_nsecs,
110− common_pid, common_comm):
110+ common_pid, common_comm, common_callchain):
111111 self.cpu = common_cpu
112112 self.secs = common_secs
113113 self.nsecs = common_nsecs
114114 self.pid = common_pid
115115 self.comm = common_comm
116+ self.callchain = common_callchain
116117
117118 def ts(self):
118119 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
2727
2828 def irq__softirq_entry(event_name, context, common_cpu,
2929 common_secs, common_nsecs, common_pid, common_comm,
30− vec):
30+ common_callchain, vec):
3131 print_header(event_name, common_cpu, common_secs, common_nsecs,
3232 common_pid, common_comm)
3333
@@ -38,7 +38,7 @@ def irq__softirq_entry(event_name, context, common_cpu, · 4 unmodified lines
3838
3939 def kmem__kmalloc(event_name, context, common_cpu,
4040 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,
4242 gfp_flags):
4343 print_header(event_name, common_cpu, common_secs, common_nsecs,
4444 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
3939
4040 def raw_syscalls__sys_exit(event_name, context, common_cpu,
4141 common_secs, common_nsecs, common_pid, common_comm,
42− id, ret):
42+ common_callchain, id, ret):
4343 if (for_comm and common_comm != for_comm) or \
4444 (for_pid and common_pid != for_pid ):
4545 return
tools/perf/scripts/python/futex-contention.py+2−2
@@ -21,7 +21,7 @@ thread_blocktime = {} · 20 unmodified lines
2121 lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time
2222 process_names = {} # long-lived pid-to-execname mapping
2323
24−def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm,
24+def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, callchain,
2525 nr, uaddr, op, val, utime, uaddr2, val3):
2626 cmd = op & FUTEX_CMD_MASK
2727 if cmd != FUTEX_WAIT:
@@ -31,7 +31,7 @@ def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, · 3 unmodified lines
3131 thread_thislock[tid] = uaddr
3232 thread_blocktime[tid] = nsecs(s, ns)
3333
34−def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm,
34+def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, callchain,
3535 nr, ret):
3636 if thread_blocktime.has_key(tid):
3737 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
6666 print_drop_table()
6767
6868 # called from perf, when it finds a correspoinding event
69−def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm,
69+def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, callchain,
7070 skbaddr, location, protocol):
7171 slocation = str(location)
7272 try:
tools/perf/scripts/python/netdev-times.py+13−13
@@ -224,75 +224,75 @@ def trace_end(): · 223 unmodified lines
224224 (len(rx_skb_list), of_count_rx_skb_list)
225225
226226 # called from perf, when it finds a correspoinding event
227−def irq__softirq_entry(name, context, cpu, sec, nsec, pid, comm, vec):
227+def irq__softirq_entry(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
228228 if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
229229 return
230230 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
231231 all_event_list.append(event_info)
232232
233−def irq__softirq_exit(name, context, cpu, sec, nsec, pid, comm, vec):
233+def irq__softirq_exit(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
234234 if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
235235 return
236236 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
237237 all_event_list.append(event_info)
238238
239−def irq__softirq_raise(name, context, cpu, sec, nsec, pid, comm, vec):
239+def irq__softirq_raise(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
240240 if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
241241 return
242242 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
243243 all_event_list.append(event_info)
244244
245245 def irq__irq_handler_entry(name, context, cpu, sec, nsec, pid, comm,
246− irq, irq_name):
246+ callchain, irq, irq_name):
247247 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
248248 irq, irq_name)
249249 all_event_list.append(event_info)
250250
251−def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, irq, ret):
251+def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, callchain, irq, ret):
252252 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, irq, ret)
253253 all_event_list.append(event_info)
254254
255−def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, napi, dev_name):
255+def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi, dev_name):
256256 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
257257 napi, dev_name)
258258 all_event_list.append(event_info)
259259
260−def net__netif_receive_skb(name, context, cpu, sec, nsec, pid, comm, skbaddr,
260+def net__netif_receive_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr,
261261 skblen, dev_name):
262262 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
263263 skbaddr, skblen, dev_name)
264264 all_event_list.append(event_info)
265265
266−def net__netif_rx(name, context, cpu, sec, nsec, pid, comm, skbaddr,
266+def net__netif_rx(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr,
267267 skblen, dev_name):
268268 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
269269 skbaddr, skblen, dev_name)
270270 all_event_list.append(event_info)
271271
272−def net__net_dev_queue(name, context, cpu, sec, nsec, pid, comm,
272+def net__net_dev_queue(name, context, cpu, sec, nsec, pid, comm, callchain,
273273 skbaddr, skblen, dev_name):
274274 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
275275 skbaddr, skblen, dev_name)
276276 all_event_list.append(event_info)
277277
278−def net__net_dev_xmit(name, context, cpu, sec, nsec, pid, comm,
278+def net__net_dev_xmit(name, context, cpu, sec, nsec, pid, comm, callchain,
279279 skbaddr, skblen, rc, dev_name):
280280 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
281281 skbaddr, skblen, rc ,dev_name)
282282 all_event_list.append(event_info)
283283
284−def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm,
284+def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, callchain,
285285 skbaddr, protocol, location):
286286 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
287287 skbaddr, protocol, location)
288288 all_event_list.append(event_info)
289289
290−def skb__consume_skb(name, context, cpu, sec, nsec, pid, comm, skbaddr):
290+def skb__consume_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr):
291291 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
292292 skbaddr)
293293 all_event_list.append(event_info)
294294
295−def skb__skb_copy_datagram_iovec(name, context, cpu, sec, nsec, pid, comm,
295+def skb__skb_copy_datagram_iovec(name, context, cpu, sec, nsec, pid, comm, callchain,
296296 skbaddr, skblen):
297297 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
298298 skbaddr, skblen)
tools/perf/scripts/python/sched-migration.py+20−21
@@ -369,93 +369,92 @@ def trace_end(): · 368 unmodified lines
369369
370370 def sched__sched_stat_runtime(event_name, context, common_cpu,
371371 common_secs, common_nsecs, common_pid, common_comm,
372− comm, pid, runtime, vruntime):
372+ common_callchain, comm, pid, runtime, vruntime):
373373 pass
374374
375375 def sched__sched_stat_iowait(event_name, context, common_cpu,
376376 common_secs, common_nsecs, common_pid, common_comm,
377− comm, pid, delay):
377+ common_callchain, comm, pid, delay):
378378 pass
379379
380380 def sched__sched_stat_sleep(event_name, context, common_cpu,
381381 common_secs, common_nsecs, common_pid, common_comm,
382− comm, pid, delay):
382+ common_callchain, comm, pid, delay):
383383 pass
384384
385385 def sched__sched_stat_wait(event_name, context, common_cpu,
386386 common_secs, common_nsecs, common_pid, common_comm,
387− comm, pid, delay):
387+ common_callchain, comm, pid, delay):
388388 pass
389389
390390 def sched__sched_process_fork(event_name, context, common_cpu,
391391 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):
393393 pass
394394
395395 def sched__sched_process_wait(event_name, context, common_cpu,
396396 common_secs, common_nsecs, common_pid, common_comm,
397− comm, pid, prio):
397+ common_callchain, comm, pid, prio):
398398 pass
399399
400400 def sched__sched_process_exit(event_name, context, common_cpu,
401401 common_secs, common_nsecs, common_pid, common_comm,
402− comm, pid, prio):
402+ common_callchain, comm, pid, prio):
403403 pass
404404
405405 def sched__sched_process_free(event_name, context, common_cpu,
406406 common_secs, common_nsecs, common_pid, common_comm,
407− comm, pid, prio):
407+ common_callchain, comm, pid, prio):
408408 pass
409409
410410 def sched__sched_migrate_task(event_name, context, common_cpu,
411411 common_secs, common_nsecs, common_pid, common_comm,
412− comm, pid, prio, orig_cpu,
412+ common_callchain, comm, pid, prio, orig_cpu,
413413 dest_cpu):
414414 headers = EventHeaders(common_cpu, common_secs, common_nsecs,
415− common_pid, common_comm)
415+ common_pid, common_comm, common_callchain)
416416 parser.migrate(headers, pid, prio, orig_cpu, dest_cpu)
417417
418418 def 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,
420420 prev_comm, prev_pid, prev_prio, prev_state,
421421 next_comm, next_pid, next_prio):
422422
423423 headers = EventHeaders(common_cpu, common_secs, common_nsecs,
424− common_pid, common_comm)
424+ common_pid, common_comm, common_callchain)
425425 parser.sched_switch(headers, prev_comm, prev_pid, prev_prio, prev_state,
426426 next_comm, next_pid, next_prio)
427427
428428 def sched__sched_wakeup_new(event_name, context, common_cpu,
429429 common_secs, common_nsecs, common_pid, common_comm,
430− comm, pid, prio, success,
430+ common_callchain, comm, pid, prio, success,
431431 target_cpu):
432432 headers = EventHeaders(common_cpu, common_secs, common_nsecs,
433− common_pid, common_comm)
433+ common_pid, common_comm, common_callchain)
434434 parser.wake_up(headers, comm, pid, success, target_cpu, 1)
435435
436436 def sched__sched_wakeup(event_name, context, common_cpu,
437437 common_secs, common_nsecs, common_pid, common_comm,
438− comm, pid, prio, success,
438+ common_callchain, comm, pid, prio, success,
439439 target_cpu):
440440 headers = EventHeaders(common_cpu, common_secs, common_nsecs,
441− common_pid, common_comm)
441+ common_pid, common_comm, common_callchain)
442442 parser.wake_up(headers, comm, pid, success, target_cpu, 0)
443443
444444 def sched__sched_wait_task(event_name, context, common_cpu,
445445 common_secs, common_nsecs, common_pid, common_comm,
446− comm, pid, prio):
446+ common_callchain, comm, pid, prio):
447447 pass
448448
449449 def sched__sched_kthread_stop_ret(event_name, context, common_cpu,
450450 common_secs, common_nsecs, common_pid, common_comm,
451− ret):
451+ common_callchain, ret):
452452 pass
453453
454454 def sched__sched_kthread_stop(event_name, context, common_cpu,
455455 common_secs, common_nsecs, common_pid, common_comm,
456− comm, pid):
456+ common_callchain, comm, pid):
457457 pass
458458
459−def trace_unhandled(event_name, context, common_cpu, common_secs, common_nsecs,
460− common_pid, common_comm):
459+def trace_unhandled(event_name, context, event_fields_dict):
461460 pass
tools/perf/scripts/python/sctop.py+1−1
@@ -44,7 +44,7 @@ def trace_begin(): · 43 unmodified lines
4444
4545 def raw_syscalls__sys_enter(event_name, context, common_cpu,
4646 common_secs, common_nsecs, common_pid, common_comm,
47− id, args):
47+ common_callchain, id, args):
4848 if for_comm is not None:
4949 if common_comm != for_comm:
5050 return
tools/perf/scripts/python/syscall-counts-by-pid.py+1−1
@@ -38,7 +38,7 @@ def trace_end(): · 37 unmodified lines
3838
3939 def raw_syscalls__sys_enter(event_name, context, common_cpu,
4040 common_secs, common_nsecs, common_pid, common_comm,
41− id, args):
41+ common_callchain, id, args):
4242
4343 if (for_comm and common_comm != for_comm) or \
4444 (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
3535
3636 def raw_syscalls__sys_enter(event_name, context, common_cpu,
3737 common_secs, common_nsecs, common_pid, common_comm,
38− id, args):
38+ common_callchain, id, args):
3939 if for_comm is not None:
4040 if common_comm != for_comm:
4141 return