Skip to content

RFC perf tools: Add traceevent plugins support

Jiri Olsa lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest24 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/24perf tools: Fix 'make install prefix=...' build ruletools/perf/Makefile+1 -01 reply
2/24perf tools: Remove unused trace-event-* codetools/perf/util/trace-event-parse.c tools/perf/util/trace-event.h+0 -451 reply
3/24perf tools: Unify page_size usagetools/perf/builtin-record.c tools/perf/perf.c tools/perf/util/python.c+3 -41 reply
4/24tools list traceevent: Add plugin supporttools/lib/traceevent/Makefile tools/lib/traceevent/event-parse.h tools/lib/traceevent/event-plugin.c +1 more+209 -21 reply
5/24tools list traceevent: Add options supporttools/lib/traceevent/Makefile tools/lib/traceevent/event-option.c tools/lib/traceevent/event-parse.h+283 -11 reply
6/24tools list traceevent: Add plugin build supporttools/lib/traceevent/Makefile+33 -40 replies
7/24tools list traceevent: Add traceevent_host_bigendian functiontools/lib/traceevent/event-parse.h+9 -00 replies
8/24tools list traceevent: Add pevent_print_func_field functiontools/lib/traceevent/event-parse.c tools/lib/traceevent/event-parse.h+46 -00 replies
9/24tools list traceevent: Add jbd2 plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_jbd2.c+70 -00 replies
10/24tools list traceevent: Add blk plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_blk.c+404 -20 replies
11/24tools list traceevent: Add hrtimer plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_hrtimer.c+95 -10 replies
12/24tools list traceevent: Add kmem plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_kmem.c+77 -10 replies
13/24tools list traceevent: Add kvm plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_kvm.c+465 -10 replies
14/24tools list traceevent: Add mac80211 plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_mac80211.c+206 -10 replies
15/24tools list traceevent: Add sched_switch plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_sched_switch.c+148 -10 replies
16/24tools list traceevent: Add function plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_function.c+183 -10 replies
17/24tools list traceevent: Update kvm plugin with is_writable_pte helpertools/lib/traceevent/plugin_kvm.c+16 -00 replies
18/24tools list traceevent: Add xen plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_xen.c+133 -10 replies
19/24tools list traceevent: Add scsi plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_scsi.c+432 -10 replies
20/24tools list traceevent: Change pevent_parse_event to return event formattools/lib/traceevent/event-parse.c tools/lib/traceevent/event-parse.h tools/perf/util/evsel.c +1 more+14 -270 replies
21/24perf tools: Add traceevents Makefile install ruletools/perf/Makefile tools/perf/config/Makefile+10 -30 replies
22/24perf tools: Add trace-event objecttools/perf/Makefile tools/perf/builtin-script.c tools/perf/util/header.c +7 more+52 -320 replies
23/24perf tools: Add traceevent object to interface traceevent libtools/perf/builtin-trace.c tools/perf/util/evsel.c tools/perf/util/trace-event.c +1 more+107 -440 replies
24/24perf tools: Overload pr_stat traceevent print functiontools/perf/util/debug.c tools/perf/util/debug.h+18 -00 replies

Reviews trailers per patch

3 of 24 patches have a Reviewed-by or Acked-by.

PatchNamhyung Kim
1/24A-b
2/24A-b
3/24A-b
4/24
5/24
6/24
7/24
8/24
9/24
10/24
11/24
12/24
13/24
14/24
15/24
16/24
17/24
18/24
19/24
20/24
21/24
22/24
23/24
24/24

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC 00/24] perf tools: Add traceevent plugins support

hi,
backporting traceevent plugin support from trace-cmd.

Having plugins allow traceevent to properly parse 'print fmt' line of tracepoint format and display proper/additional data in perf script command, like:

- displaying call_site details in kmem:* tracepoints:

  $ sudo perf record -e kmem:kmalloc ls

before:
ls 31708 [003] 15123.850504: kmem:kmalloc: call_site=ffffffff812030eb ptr=0xffff8801cbb91840 bytes_req=40 bytes_alloc=64 gfp_ ls 31708 [003] 15123.850506: kmem:kmalloc: call_site=ffffffff811be761 ptr=0xffff8801cbbddd20 bytes_req=32 bytes_alloc=32 gfp_ ls 31708 [003] 15123.850507: kmem:kmalloc: call_site=ffffffff811be6ab ptr=0xffff880163bf1800 bytes_req=112 bytes_alloc=128 gf ls 31708 [003] 15123.850535: kmem:kmalloc: call_site=ffffffff811bed5e ptr=0xffff88017d41b000 bytes_req=4096 bytes_alloc=4096 ls 31708 [003] 15123.850691: kmem:kmalloc: call_site=ffffffff81128333 ptr=0xffff88020eedc000 bytes_req=4104 bytes_alloc=8192 ls 31708 [003] 15123.850838: kmem:kmalloc: call_site=ffffffff8121c28e ptr=0xffff8801cb981940 bytes_req=48 bytes_alloc=64 gfp_ ls 31708 [003] 15123.850848: kmem:kmalloc: call_site=ffffffff8121c418 ptr=0xffff8801cb916bc0 bytes_req=50 bytes_alloc=64 gfp_ ls 31708 [003] 15123.850850: kmem:kmalloc: call_site=ffffffff8121c418 ptr=0xffff8801cb916b40 bytes_req=51 bytes_alloc=64 gfp_

now:

  $ sudo perf script
  ...
  ls 30512 [001] 14717.425867: kmem:kmalloc: (perf_event_mmap+0xf3) call_site=ffffffff81128333 ptr=0xffff880211cea000 bytes_req
  ls 30512 [001] 14717.425981: kmem:kmalloc: (proc_reg_open+0x4b) call_site=ffffffff812030eb ptr=0xffff88017de85a40 bytes_req=4
  ls 30512 [001] 14717.425982: kmem:kmalloc: (single_open+0x41) call_site=ffffffff811be761 ptr=0xffff8801958e1e00 bytes_req=32 
  ls 30512 [001] 14717.425982: kmem:kmalloc: (seq_open+0xfb) call_site=ffffffff811be6ab ptr=0xffff880211d88f00 bytes_req=112 by
  ls 30512 [001] 14717.425989: kmem:kmalloc: (seq_read+0x2ee) call_site=ffffffff811bed5e ptr=0xffff88017be8c000 bytes_req=4096 
  ls 30512 [001] 14717.426034: kmem:kmalloc: (perf_event_mmap+0xf3) call_site=ffffffff81128333 ptr=0xffff880211cea000 bytes_req
  ls 30512 [001] 14717.426079: kmem:kmalloc: (ext4_readdir+0x6fe) call_site=ffffffff8121c28e ptr=0xffff88017de85f00 bytes_req=4
  ls 30512 [001] 14717.426081: kmem:kmalloc: (ext4_htree_store_dirent+0x38) call_site=ffffffff8121c418 ptr=0xffff88017de85080 b
  ...

- displaying details for timer_expire_entry and hrtimer_start tracepoints:

  $ sudo perf record -e timer:* ls

before:
ls 31727 [001] 15171.487282: timer:hrtimer_cancel: hrtimer=0xffff88021e24e4c0
ls 31727 [001] 15171.487284: timer:hrtimer_expire_entry: [FAILED TO PARSE] hrtimer=0xffff88021e24e4c0 now=15167505000662 func ls 31727 [001] 15171.487290: timer:hrtimer_expire_exit: hrtimer=0xffff88021e24e4c0
ls 31727 [001] 15171.487290: timer:hrtimer_start: [FAILED TO PARSE] hrtimer=0xffff88021e24e4c0 function=0xffffffff810b6460 ex

now:

  $ sudo perf script
  ..
  ls 30557 [001] 14855.443889: timer:hrtimer_cancel: hrtimer=0xffff88021e24e4c0
  ls 30557 [001] 14855.443891: timer:hrtimer_expire_entry: hrtimer=0xffff88021e24e4c0 now=14851544000735 function=tick_sched_timer/0x0
  ls 30557 [001] 14855.443897: timer:hrtimer_expire_exit: hrtimer=0xffff88021e24e4c0
  ls 30557 [001] 14855.443897: timer:hrtimer_start: hrtimer=0xffff88021e24e4c0 function=tick_sched_timer expires=14851545000000 softexpires=14851545000000
  ls 30557 [001] 14855.443899: timer:timer_cancel: timer=0xffff88021e250b68
  ls 30557 [001] 14855.443900: timer:timer_expire_entry: timer=0xffff88021e250b68 function=delayed_work_timer_fn now=4309518840
  ls 30557 [001] 14855.443903: timer:timer_expire_exit: timer=0xffff88021e250b68
  ls 30557 [001] 14855.444888: timer:hrtimer_cancel: hrtimer=0xffff88021e24e4c0
  ls 30557 [001] 14855.444889: timer:hrtimer_expire_entry: hrtimer=0xffff88021e24e4c0 now=14851545000598 function=tick_sched_timer/0x0
  ...

All plugins present in trace-cmd are backported plus added new scsi and xen. The 'xen' plugin still cannot handle all the 'print fmt' functions, since I dont follow xen code ;-) Also xen tracepoints use 'sizeof' in the format string and it's not clear yet how to handle that.

Plugins get installed to following locations:
'$(HOME)/.traceevent/plugins'
- if no prefix is provided
'$(perfexecdir)/traceevent/plugins'
- if prefix is provided

thanks for comments,
jirka

Cc Corey Ashford <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc David Ahern <[email protected]>

---
Jiri Olsa (24):
perf tools: Fix 'make install prefix=...' build rule
perf tools: Remove unused trace-event-* code
perf tools: Unify page_size usage
tools list traceevent: Add plugin support
tools list traceevent: Add options support
tools list traceevent: Add plugin build support
tools list traceevent: Add traceevent_host_bigendian function tools list traceevent: Add pevent_print_func_field function tools list traceevent: Add jbd2 plugin
tools list traceevent: Add blk plugin
tools list traceevent: Add hrtimer plugin
tools list traceevent: Add kmem plugin
tools list traceevent: Add kvm plugin
tools list traceevent: Add mac80211 plugin
tools list traceevent: Add sched_switch plugin
tools list traceevent: Add function plugin
tools list traceevent: Update kvm plugin with is_writable_pte helper tools list traceevent: Add xen plugin
tools list traceevent: Add scsi plugin
tools list traceevent: Change pevent_parse_event to return event format perf tools: Add traceevents Makefile install rule
perf tools: Add trace-event object
perf tools: Add traceevent object to interface traceevent lib perf tools: Overload pr_stat traceevent print function

 tools/lib/traceevent/Makefile              |  57 +++++++++--
 tools/lib/traceevent/event-option.c        | 278 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/lib/traceevent/event-parse.c         |  70 +++++++++----
 tools/lib/traceevent/event-parse.h         |  29 +++++-
 tools/lib/traceevent/event-plugin.c        | 202 +++++++++++++++++++++++++++++++++++++
 tools/lib/traceevent/plugin_blk.c          | 389 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/lib/traceevent/plugin_function.c     | 182 +++++++++++++++++++++++++++++++++
 tools/lib/traceevent/plugin_hrtimer.c      |  94 ++++++++++++++++++
 tools/lib/traceevent/plugin_jbd2.c         |  68 +++++++++++++
 tools/lib/traceevent/plugin_kmem.c         |  76 ++++++++++++++
 tools/lib/traceevent/plugin_kvm.c          | 480 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/lib/traceevent/plugin_mac80211.c     | 204 +++++++++++++++++++++++++++++++++++++
 tools/lib/traceevent/plugin_sched_switch.c | 147 +++++++++++++++++++++++++++
 tools/lib/traceevent/plugin_scsi.c         | 431 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/lib/traceevent/plugin_xen.c          | 132 ++++++++++++++++++++++++
 tools/perf/Makefile                        |  13 ++-
 tools/perf/builtin-record.c                |   5 +-
 tools/perf/builtin-script.c                |   2 +-
 tools/perf/builtin-trace.c                 |   5 +-
 tools/perf/config/Makefile                 |   4 +-
 tools/perf/perf.c                          |   1 +
 tools/perf/util/debug.c                    |  16 +++
 tools/perf/util/debug.h                    |   2 +
 tools/perf/util/evsel.c                    |  44 +-------
 tools/perf/util/header.c                   |   8 +-
 tools/perf/util/python-ext-sources         |   1 +
 tools/perf/util/python.c                   |   1 +
 tools/perf/util/session.c                  |   2 +-
 tools/perf/util/session.h                  |   3 +-
 tools/perf/util/trace-event-parse.c        |  53 +---------
 tools/perf/util/trace-event-read.c         |  20 ++--
 tools/perf/util/trace-event.c              | 121 ++++++++++++++++++++++
 tools/perf/util/trace-event.h              |  22 ++--
 33 files changed, 3002 insertions(+), 160 deletions(-)
 create mode 100644 tools/lib/traceevent/event-option.c
 create mode 100644 tools/lib/traceevent/event-plugin.c
 create mode 100644 tools/lib/traceevent/plugin_blk.c
 create mode 100644 tools/lib/traceevent/plugin_function.c
 create mode 100644 tools/lib/traceevent/plugin_hrtimer.c
 create mode 100644 tools/lib/traceevent/plugin_jbd2.c
 create mode 100644 tools/lib/traceevent/plugin_kmem.c
 create mode 100644 tools/lib/traceevent/plugin_kvm.c
 create mode 100644 tools/lib/traceevent/plugin_mac80211.c
 create mode 100644 tools/lib/traceevent/plugin_sched_switch.c
 create mode 100644 tools/lib/traceevent/plugin_scsi.c
 create mode 100644 tools/lib/traceevent/plugin_xen.c
 create mode 100644 tools/perf/util/trace-event.c