Skip to content

perf tools: Add traceevent plugins support

Jiri Olsa lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest28 patches 13 repliesIn review
  2. v20 of 27 patches 0 repliesSuperseded
  3. v122 patches 54 repliesSuperseded

Changes in v3 from the cover letter

- rebased to current Arnaldo's perf/core
- patches order changed so the build framework gets in before actual plugins
- the perf/core_plugins branch includes also change from Steven, which got acked but is not in yet (it's not included in the patchset, just in branch)
- following patch got in:
perf tools: Include test-stackprotector-all.c in test-all
- factored plugin_function.c stack helpers re/allocation
- indented 'diff' like output in several changelogs

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/28perf tools: Remove stackprotector feature checktools/perf/config/Makefile tools/perf/config/feature-checks/Makefile tools/perf/config/feature-checks/test-stackprotector.c+1 -160 replies
2/28tools lib traceevent: Add plugin supporttools/lib/traceevent/Makefile tools/lib/traceevent/event-parse.h tools/lib/traceevent/event-plugin.c+212 -10 replies
3/28tools lib traceevent: Add plugin build supporttools/lib/traceevent/Makefile+47 -50 replies
4/28tools lib traceevent: Add traceevent_host_bigendian functiontools/lib/traceevent/event-parse.h+10 -00 replies
5/28tools lib traceevent: Change pevent_parse_format to include pevent handletools/lib/traceevent/event-parse.c tools/lib/traceevent/event-parse.h tools/perf/util/evsel.c+39 -230 replies
6/28tools lib traceevent: Harmonize the install messages in lib-traceeventtools/lib/traceevent/Makefile+1 -10 replies
7/28perf tools: Add build and install plugins targetstools/perf/Makefile.perf tools/perf/config/Makefile+20 -50 replies
8/28perf tools: Add filename__read_str util functiontools/perf/util/util.c tools/perf/util/util.h+50 -00 replies
9/28perf tools: Add trace-event objecttools/perf/Makefile.perf tools/perf/builtin-script.c tools/perf/util/header.c +6 more+51 -310 replies
10/28perf tools: Add trace-event global object for tracepoint interfacetools/perf/builtin-trace.c tools/perf/util/evsel.c tools/perf/util/trace-event.c +1 more+68 -440 replies
11/28perf tools: Overload pr_stat traceevent print functiontools/perf/util/debug.c tools/perf/util/debug.h+29 -30 replies
12/28tools lib traceevent: Add jbd2 plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_jbd2.c+68 -00 replies
13/28tools lib traceevent: Add hrtimer plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_hrtimer.c+95 -10 replies
14/28tools lib traceevent: Add kmem plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_kmem.c+73 -00 replies
15/28tools lib traceevent: Add kvm plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_kvm.c+420 -00 replies
16/28tools lib traceevent: Add mac80211 plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_mac80211.c+96 -00 replies
17/28tools lib traceevent: Add sched_switch plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_sched_switch.c+149 -00 replies
18/28tools lib traceevent: Add function plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_function.c+152 -00 replies
19/28tools lib traceevent: Add xen plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_xen.c+131 -00 replies
20/28tools lib traceevent: Add scsi plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_scsi.c+424 -00 replies
21/28tools lib traceevent: Add cfg80211 plugintools/lib/traceevent/Makefile tools/lib/traceevent/plugin_cfg80211.c+25 -00 replies
22/28tools lib traceevent: Remove malloc_or_die from event-plugin.ctools/lib/traceevent/event-plugin.c+16 -34 replies
23/28tools lib traceevent: Use static functions in jbd2 plugintools/lib/traceevent/plugin_jbd2.c+6 -40 replies
24/28tools lib traceevent: Use pevent_print_func_field in hrtimer_start handlertools/lib/traceevent/plugin_hrtimer.c+2 -170 replies
25/28tools lib traceevent: Several cleanups for function plugintools/lib/traceevent/plugin_function.c+4 -60 replies
26/28tools lib traceevent: Remove malloc_or_die from plugin_function.ctools/lib/traceevent/plugin_function.c+20 -90 replies
27/28tools lib traceevent: Update kvm plugin with is_writable_pte helpertools/lib/traceevent/plugin_kvm.c+17 -00 replies
28/28perf tools: Add udis86 disassembler feature checktools/perf/Makefile.perf tools/perf/config/Makefile tools/perf/config/feature-checks/Makefile +2 more+30 -210 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCHv3 00/28] perf tools: Add traceevent plugins support

hi,
backporting traceevent plugin support from trace-cmd.

Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git

Initial RFC is here:
http://marc.info/?l=linux-kernel&m=137803257921043&w=2

Having plugins allow traceevent to properly parse 'print fmt' line of tracepoint format and display proper/additional data in perf script command (check examples below).

Plugins backported from trace-cmd:
plugin_function.c
plugin_hrtimer.c
plugin_jbd2.c
plugin_kmem.c
plugin_kvm.c
plugin_mac80211.c
plugin_sched_switch.c

Plugins newly added:
plugin_cfg80211.c
plugin_scsi.c
plugin_xen.c

v3 changes:
- rebased to current Arnaldo's perf/core
- patches order changed so the build framework gets in before actual plugins
- the perf/core_plugins branch includes also change from Steven, which got acked but is not in yet (it's not included in the patchset, just in branch)
- following patch got in:
perf tools: Include test-stackprotector-all.c in test-all
- factored plugin_function.c stack helpers re/allocation
- indented 'diff' like output in several changelogs

v2 changes:
- removing usage of malloc_or_die from event-pluginc.c
- using static methods in plugins where possible
- added Steven's Signed-off-by tags
- changed traceevent_host_bigendian with code suggested by Steven
- using pevent_print_func_field in hrtimer_start handler
- plugin_function.c changes:
* switching malloc_or_die into malloc
* removing index field from struct func_stack as it's not needed
* renaming get_index into add_and_get_index
* using '%*X' format string capability instead of the loop
- changing pevent_parse_format interface instead
of the pevent_parse_event as requested by Steven
- breakout LIBTRACEEVENT_FLAGS in Makefile.perf as suggested by Namhyung
- added better error handling for filename__read_str suggested by Nmahyung
- using _eprintf code in pr_stat function as suggested by Namhyung
- removing stackprotector feature check as it's not needed and is causing warnings - build failures on old gcc

Changes from RFC:
- added comment about repo/HEAD of the backport source
- omitted options plugin support
- change plugins installation path to:

    $(perfexecdir)/traceevent/plugins

The code is available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/core_plugins

thanks,
jirka

Examples (diffs of 'perf script' output):

* data was generated by 'perf record -e 'cfg80211:*' -a' --- script.cfg80211.old
+++ script.cfg80211.new
- ifconfig 2705 [003] 662.896560: cfg80211:cfg80211_tx_mlme_mgmt: [FAILED TO PARSE] name=wlan0 ifindex=3 frame=ARRAY[c0, 00,
+ ifconfig 2705 [003] 662.896560: cfg80211:cfg80211_tx_mlme_mgmt: netdev:wlan0(3), ftype:0xc0
- kworker/u16:0 1697 [002] 664.808210: cfg80211:cfg80211_rx_mlme_mgmt: [FAILED TO PARSE] name=wlan0 ifindex=3 frame=ARRAY[b0, 00,
+ kworker/u16:0 1697 [002] 664.808210: cfg80211:cfg80211_rx_mlme_mgmt: netdev:wlan0(3), ftype:0xb0

* data was generated by 'perf record -e sched:sched_switch -a' --- script.sched_switch.old
+++ script.sched_switch.new
- perf 577 [002] 30965.311852: sched:sched_switch: prev_comm=perf prev_pid=577 prev_prio=120 prev_state=S ==> next_comm=sw
+ perf 577 [002] 30965.311852: sched:sched_switch: perf:577 [120] S ==> swapper/2:0 [120]

* data was generated by 'perf record -e ftrace:function ls' --- script.function.old
+++ script.function.new
- ls 10781 [001] 32667.291379: ftrace:function: ffffffff811adb80 <-- ffffffff811afc48
- ls 10781 [001] 32667.291379: ftrace:function: ffffffff811b35d0 <-- ffffffff811adb9b
- ls 10781 [001] 32667.291380: ftrace:function: ffffffff811b3520 <-- ffffffff811b35e8
- ls 10781 [001] 32667.291380: ftrace:function: ffffffff811b2720 <-- ffffffff811b3549
- ls 10781 [001] 32667.291381: ftrace:function: ffffffff81297e10 <-- ffffffff811b356c
- ls 10781 [001] 32667.291381: ftrace:function: ffffffff81298f40 <-- ffffffff81297e2c
- ls 10781 [001] 32667.291382: ftrace:function: ffffffff81076160 <-- ffffffff811afbf0
- ls 10781 [001] 32667.291383: ftrace:function: ffffffff811c3eb0 <-- ffffffff811afbfc
- ls 10781 [001] 32667.291383: ftrace:function: ffffffff8164e100 <-- ffffffff811c3ed8
- ls 10781 [001] 32667.291384: ftrace:function: ffffffff811a5d10 <-- ffffffff811c3f53
- ls 10781 [001] 32667.291384: ftrace:function: ffffffff811e8e70 <-- ffffffff811a5d58
- ls 10781 [001] 32667.291385: ftrace:function: ffffffff811f38e0 <-- ffffffff811a5d63
- ls 10781 [001] 32667.291385: ftrace:function: ffffffff811a9ff0 <-- ffffffff811a5d6b
- ls 10781 [001] 32667.291386: ftrace:function: ffffffff811a9fa0 <-- ffffffff811aa015
- ls 10781 [001] 32667.291387: ftrace:function: ffffffff810851c0 <-- ffffffff811aa053
- ls 10781 [001] 32667.291387: ftrace:function: ffffffff81090e00 <-- ffffffff81085211
+ ls 10781 [001] 32667.291379: ftrace:function: would_dump <-- setup_new_exec
+ ls 10781 [001] 32667.291379: ftrace:function: inode_permission <-- would_dump
+ ls 10781 [001] 32667.291380: ftrace:function: __inode_permission <-- inode_permission
+ ls 10781 [001] 32667.291380: ftrace:function: generic_permission <-- __inode_permission
+ ls 10781 [001] 32667.291381: ftrace:function: security_inode_permission <-- __inode_permission
+ ls 10781 [001] 32667.291381: ftrace:function: cap_inode_permission <-- security_inode_permission
+ ls 10781 [001] 32667.291382: ftrace:function: flush_signal_handlers <-- setup_new_exec
+ ls 10781 [001] 32667.291383: ftrace:function: do_close_on_exec <-- setup_new_exec
+ ls 10781 [001] 32667.291383: ftrace:function: _raw_spin_lock <-- do_close_on_exec
+ ls 10781 [001] 32667.291384: ftrace:function: filp_close <-- do_close_on_exec
+ ls 10781 [001] 32667.291384: ftrace:function: dnotify_flush <-- filp_close
+ ls 10781 [001] 32667.291385: ftrace:function: locks_remove_posix <-- filp_close
+ ls 10781 [001] 32667.291385: ftrace:function: fput <-- filp_close
+ ls 10781 [001] 32667.291386: ftrace:function: file_sb_list_del <-- fput
+ ls 10781 [001] 32667.291387: ftrace:function: task_work_add <-- fput
+ ls 10781 [001] 32667.291387: ftrace:function: kick_process <-- task_work_add

* data was generated by 'perf record -e 'kvm:*,kvmmmu:*' -a'
--- script.kvm.old
+++ script.kvm.new
qemu-system-x86 17414 [000] 6868.995053: kvm:kvm_exit: reason EPT_VIOLATION rip 0xfff0 info 184 0 qemu-system-x86 17414 [000] 6868.995109: kvm:kvm_emulate_insn: f0000:c46b:e4 71 (real)
- qemu-system-x86 3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: [FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root_count=0
+ qemu-system-x86 3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: new sp gfn 0 0/4 q0 direct --- !pge !nxe root 0 sync
- qemu-system-x86 3006 [002] 10562.080502: kvmmmu:kvm_mmu_prepare_zap_page: [FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root
+ qemu-system-x86 3006 [002] 10562.080502: kvmmmu:kvm_mmu_prepare_zap_page: 0/4 q0 direct --- !pge !nxe root 1 sync qemu-system-x86 3290 [002] 10708.755312: kvmmmu:fast_page_fault: [FAILED TO PARSE] vcpu_id=0 gva=4094486080 error_code=3 sptep=0xfff
- insmod 2576 [001] 781.731666: kvmmmu:kvm_mmu_sync_page: [FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count=1
+ insmod 2576 [001] 781.731666: kvmmmu:kvm_mmu_sync_page: 3/0 q0 --- !pge !nxe root 10 unsync
- insmod 2576 [001] 781.731668: kvmmmu:kvm_mmu_unsync_page: [FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count
+ insmod 2576 [001] 781.731668: kvmmmu:kvm_mmu_unsync_page: 3/0 q0 --- !pge !nxe root 10 unsync

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 (28):
perf tools: Remove stackprotector feature check
tools lib traceevent: Add plugin support
tools lib traceevent: Add plugin build support
tools lib traceevent: Add traceevent_host_bigendian function tools lib traceevent: Change pevent_parse_format to include pevent handle tools lib traceevent: Harmonize the install messages in lib-traceevent perf tools: Add build and install plugins targets
perf tools: Add filename__read_str util function
perf tools: Add trace-event object
perf tools: Add trace-event global object for tracepoint interface perf tools: Overload pr_stat traceevent print function
tools lib traceevent: Add jbd2 plugin
tools lib traceevent: Add hrtimer plugin
tools lib traceevent: Add kmem plugin
tools lib traceevent: Add kvm plugin
tools lib traceevent: Add mac80211 plugin
tools lib traceevent: Add sched_switch plugin
tools lib traceevent: Add function plugin
tools lib traceevent: Add xen plugin
tools lib traceevent: Add scsi plugin
tools lib traceevent: Add cfg80211 plugin
tools lib traceevent: Remove malloc_or_die from event-plugin.c tools lib traceevent: Use static functions in jbd2 plugin tools lib traceevent: Use pevent_print_func_field in hrtimer_start handler tools lib traceevent: Several cleanups for function plugin tools lib traceevent: Remove malloc_or_die from plugin_function.c tools lib traceevent: Update kvm plugin with is_writable_pte helper perf tools: Add udis86 disassembler feature check

 tools/lib/traceevent/Makefile                          |  71 +++++++++++--
 tools/lib/traceevent/event-parse.c                     |  56 ++++++----
 tools/lib/traceevent/event-parse.h                     |  19 +++-
 tools/lib/traceevent/event-plugin.c                    | 215 +++++++++++++++++++++++++++++++++++++
 tools/lib/traceevent/plugin_cfg80211.c                 |  24 +++++
 tools/lib/traceevent/plugin_function.c                 | 160 ++++++++++++++++++++++++++++
 tools/lib/traceevent/plugin_hrtimer.c                  |  78 ++++++++++++++
 tools/lib/traceevent/plugin_jbd2.c                     |  68 ++++++++++++
 tools/lib/traceevent/plugin_kmem.c                     |  72 +++++++++++++
 tools/lib/traceevent/plugin_kvm.c                      | 436 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/lib/traceevent/plugin_mac80211.c                 |  95 +++++++++++++++++
 tools/lib/traceevent/plugin_sched_switch.c             | 148 ++++++++++++++++++++++++++
 tools/lib/traceevent/plugin_scsi.c                     | 423 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/lib/traceevent/plugin_xen.c                      | 130 +++++++++++++++++++++++
 tools/perf/Makefile.perf                               |  18 +++-
 tools/perf/builtin-script.c                            |   2 +-
 tools/perf/builtin-trace.c                             |   5 +-
 tools/perf/config/Makefile                             |  21 +++-
 tools/perf/config/feature-checks/Makefile              |  12 +--
 tools/perf/config/feature-checks/test-all.c            |   5 +
 tools/perf/config/feature-checks/test-stackprotector.c |   6 --
 tools/perf/config/feature-checks/test-udis86.c         |  11 ++
 tools/perf/util/debug.c                                |  30 +++++-
 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/session.h                              |   3 +-
 tools/perf/util/trace-event-parse.c                    |  13 ---
 tools/perf/util/trace-event-read.c                     |  20 ++--
 tools/perf/util/trace-event.c                          |  82 +++++++++++++++
 tools/perf/util/trace-event.h                          |  15 ++-
 tools/perf/util/util.c                                 |  49 +++++++++
 tools/perf/util/util.h                                 |   1 +
 34 files changed, 2214 insertions(+), 129 deletions(-)
 create mode 100644 tools/lib/traceevent/event-plugin.c
 create mode 100644 tools/lib/traceevent/plugin_cfg80211.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
 delete mode 100644 tools/perf/config/feature-checks/test-stackprotector.c
 create mode 100644 tools/perf/config/feature-checks/test-udis86.c
 create mode 100644 tools/perf/util/trace-event.c