Skip to content

perf tools: Introduce an abstraction for AUX Area and Instruction Tracing

Adrian Hunter lkml 13 versions – Applied

Status from this message: Applied

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest25 patches 24 repliesApplied
  2. v7 posting 2/210 patches 0 repliesSuperseded
  3. v6 posting 2/217 patches 26 repliesSuperseded
Earlier versions · 10
VersionPostedPatchesRepliesStatus
v5 posting 2/216 patches1 replySuperseded
v4 posting 2/224 patches17 repliesSuperseded
v3 posting 2/225 patches15 repliesSuperseded
v7 posting 1/225 patches11 repliesSuperseded
v6 posting 1/225 patches7 repliesSuperseded
v5 posting 1/225 patches5 repliesSuperseded
v4 posting 1/223 patches2 repliesSuperseded
v3 posting 1/222 patches6 repliesSuperseded
v222 patches4 repliesSuperseded
v125 patches0 repliesSuperseded

Patches in v8 Applied

#Subject and filesSizeRepliesApplied
1/25perf auxtrace: Add Intel PT as an AUX area tracing typetools/perf/util/auxtrace.c tools/perf/util/auxtrace.h+2 -00 replies
2/25perf tools: Add Intel PT packet decodertools/perf/util/Build tools/perf/util/intel-pt-decoder/Build tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c +1 more+466 -00 replies
3/25perf tools: Add Intel PT instruction decodertools/build/Makefile.build tools/perf/.gitignore tools/perf/Makefile.perf +10 more+2832 -34 replies
4/25perf tools: Add Intel PT logtools/perf/util/intel-pt-decoder/Build tools/perf/util/intel-pt-decoder/intel-pt-log.c tools/perf/util/intel-pt-decoder/intel-pt-log.h+208 -10 replies
5/25perf tools: Add Intel PT decodertools/perf/util/intel-pt-decoder/Build tools/perf/util/intel-pt-decoder/intel-pt-decoder.c tools/perf/util/intel-pt-decoder/intel-pt-decoder.h+1921 -10 replies
6/25perf tools: Add Intel PT supporttools/perf/arch/x86/util/Build tools/perf/arch/x86/util/intel-pt.c tools/perf/util/Build +2 more+2717 -00 replies
7/25perf tools: Take Intel PT into usetools/perf/Documentation/intel-pt.txt tools/perf/arch/x86/util/Build tools/perf/arch/x86/util/auxtrace.c +3 more+649 -30 replies
8/25perf tools: Add Intel BTS supporttools/perf/Documentation/intel-bts.txt tools/perf/arch/x86/util/Build tools/perf/arch/x86/util/auxtrace.c +8 more+1576 -610 replies
9/25perf tools: Put itrace options into an asciidoc includetools/perf/Documentation/itrace.txt tools/perf/Documentation/perf-inject.txt tools/perf/Documentation/perf-report.txt +1 more+25 -660 replies
10/25perf tools: Add example call-graph scripttools/perf/scripts/python/call-graph-from-postgresql.py tools/perf/scripts/python/export-to-postgresql.py+374 -07 replies
11/25perf auxtrace: Fix period type 'i' not workingtools/perf/util/auxtrace.c+5 -11 reply
12/25perf tools: Fix perf-with-kcore handling of arguments containing spacestools/perf/perf-with-kcore.sh+14 -141 reply
13/25perf tools: Fix Intel PT 'instructions' sample periodtools/perf/util/intel-pt-decoder/intel-pt-decoder.c tools/perf/util/intel-pt-decoder/intel-pt-decoder.h tools/perf/util/intel-pt.c+8 -10 replies
14/25perf tools: Add perf_pmu__format_bits()tools/perf/util/pmu.c tools/perf/util/pmu.h+17 -11 reply
15/25perf tools: Validate config term maximum valuetools/perf/util/pmu.c+29 -11 reply
16/25perf tools: Extend the event parser maximum error indextools/perf/util/parse-events.c+1 -11 reply
17/25perf tools: Add Intel PT support for PSB periodstools/perf/arch/x86/util/intel-pt.c+210 -70 replies
18/25perf tools: Add new Intel PT packet definitionstools/perf/util/intel-pt-decoder/intel-pt-decoder.c tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.h+201 -170 replies
19/25perf tools: Pass Intel PT information for decoding MTC and CYCtools/perf/arch/x86/util/intel-pt.c tools/perf/util/intel-pt-decoder/intel-pt-decoder.h tools/perf/util/intel-pt.c +1 more+83 -110 replies
20/25perf tools: Add Intel PT support for decoding MTC packetstools/perf/util/intel-pt-decoder/intel-pt-decoder.c tools/perf/util/intel-pt-decoder/intel-pt-decoder.h+159 -40 replies
21/25perf tools: Add Intel PT support for using MTC packetstools/perf/arch/x86/util/intel-pt.c+25 -10 replies
22/25perf tools: Add Intel PT support for decoding CYC packetstools/perf/util/intel-pt-decoder/intel-pt-decoder.c+306 -50 replies
23/25perf tools: Add Intel PT support for using CYC packetstools/perf/arch/x86/util/intel-pt.c+6 -00 replies
24/25perf tools: Add Intel PT support for decoding TRACESTOP packetstools/perf/util/intel-pt-decoder/intel-pt-decoder.c+11 -00 replies
25/25perf tools: Update Intel PT documentationtools/perf/Documentation/intel-pt.txt+186 -80 replies

Reviews trailers per patch

1 of 25 patches has a Reviewed-by or Acked-by.

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

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

Read the v8 thread

Cover letter [PATCH V8 00/25] perf tools: Introduce an abstraction for AUX Area and Instruction Tracing

Hi

Here is V8 patches for the introduction of an abstraction for using the AUX area and Instruction tracing. The patches for AUX area support have been applied, just leaving patches for Intel PT and Intel BTS. These have now been updated to reflect new Intel PT features, plus a couple of fixes.

The patches can also be found here:

http://git.infradead.org/users/ahunter/linux-perf.git

An example (unchanged from V3) perf.data file and build id archive can be found here:

http://git.infradead.org/~ahunter/tfr/

There is also a tar of the 3 most relevant files with debugging symbols. These need to be placed in under the correct paths in /usr/lib/debug to get symbols.

Changes in V8:

New patches:
perf auxtrace: Fix period type 'i' not working
perf tools: Fix perf-with-kcore handling of arguments containing spaces perf tools: Fix Intel PT 'instructions' sample period
perf tools: Add perf_pmu__format_bits()
perf tools: Validate config term maximum value
perf tools: Extend the event parser maximum error index perf tools: Add Intel PT support for PSB periods
perf tools: Add new Intel PT packet definitions
perf tools: Pass Intel PT information for decoding MTC and CYC perf tools: Add Intel PT support for decoding MTC packets perf tools: Add Intel PT support for using MTC packets
perf tools: Add Intel PT support for decoding CYC packets perf tools: Add Intel PT support for using CYC packets
perf tools: Add Intel PT support for decoding TRACESTOP packets perf tools: Update Intel PT documentation

Changes in V7:

Patches already applied:
perf db-export: Fix thread ref-counting
perf tools: Ensure thread-stack is flushed
perf tools: Allow auxtrace data alignment

perf tools: Add Intel PT instruction decoder
Copy the x86 instruction decoder into perf tools source

perf tools: Add Intel PT decoder
Fix Intel PT getting stuck in a loop

Check for being stuck in a loop. That can happen if a decoder error results in the decoder erroneously setting the ip to an address that is itself in an infinite loop that consumes no packets. The only way to be in a loop that consumes no packets is if it consists of unconditional branches. So the check for being stuck is if we see a repeating cycle of consecutive unconditional branches.

perf tools: Add Intel PT support
Add missing err check in intel-pt.
Fix missing thread__puts
Improve Intel PT sync to sideband events

To help synchronize trace data with sideband events the timestamp when returning to userspace is estimated.

That was not always being done if switch information was not available, but it is still useful for sync'ing to mmap changes, so simplify by doing it always when TSC is available. Also add log prints to help debug synchronization to sideband.

Improve Intel PT timestamp estimation

Intel PT uses timestamps to synchronize side-band information to trace data. However timestamps may not be frequent enough. To improve accuracy, an estimated timestamp is calculated based on the number of instructions executed since the last known timestamp.

This patch improves that estimate by taking into account the CPU frequency as represented by the Intel PT CBR (core-to-bus ratio) packet.

perf tools: Add Intel BTS support
Fix missing thread__puts
Add a fix for an infinite loop in intel_bts_process_buffer misplaced in a followup patch in the original patchkit

perf tools: Output sample flags and insn_len from intel_pt
Folded into: perf tools: Add Intel PT support

perf tools: Output sample flags and insn_len from intel_bts
Folded into: perf tools: Add Intel BTS support

perf tools: Intel PT to always update thread stack trace number
Folded into: perf tools: Add Intel PT support

perf tools: Intel BTS to always update thread stack trace number
Folded into: perf tools: Add Intel BTS support

Changes in V6:

Some minor expansion of commit messages.

Patches already applied:
perf tools: Disallow PMU events intel_pt and intel_bts until there is support

perf db-export: Fix thread ref-counting
New patch

perf tools: Ensure thread-stack is flushed
New patch

perf tools: Add Intel PT support
Support thread ref-counting

perf tools: Add Intel PT decoder
Fix a bug: FUP packet in PSB to update last IP

perf tools: Take Intel PT into use
Add Overview and Quickstart sections to intel_pt.txt

perf tools: Add Intel BTS support
Add Overview to intel_bts.txt
Support thread ref-counting

perf tools: Add example call-graph script
Add documentation comments to scripts

Changes in V5:

Patches already applied:
perf report: Fix placement of itrace option in documentation perf tools: Add AUX area tracing index
perf tools: Hit all build ids when AUX area tracing
perf tools: Add build option NO_AUXTRACE to exclude AUX area tracing perf auxtrace: Add option to synthesize events for transactions perf tools: Add support for PERF_RECORD_AUX
perf tools: Add support for PERF_RECORD_ITRACE_START perf tools: Add AUX area tracing Snapshot Mode
perf record: Add AUX area tracing Snapshot Mode support

perf tools: Disallow PMU events intel_pt and intel_bts until there is support
New patch

perf tools: Add Intel PT decoder
Style improvements pointed out by Acme: aligning '=', single line initializing Make use of zalloc() not malloc / memset
Make use of zfree
Map internal error codes to fixed constants for output
Change intel_pt_error_message() to intel_pt__strerror()

perf tools: Add Intel PT support
Make use of zfree

perf tools: Take Intel PT into use
Allow "intel_pt" PMU to be selected as an event

perf tools: Add Intel BTS support
Allow "intel_bts" PMU to be selected as an event Make use of zfree
Map internal error codes to fixed constants for output Let "intel_bts" show up in 'perf list'

perf tools: Output sample flags and insn_len from intel_bts
Map internal error codes to fixed constants for output

Changes on V4:

perf tools: Amend mmap ref counting for the AUX area mmap
Dropped because already applied

perf script: Always allow fields 'addr' and 'cpu' for auxtrace
Dropped because already applied

perf report: Add Instruction Tracing support
Dropped because already applied

perf report: Fix placement of itrace option in documentation
New patch

perf tools: Add AUX area tracing index
Change size checks for more flexibility i.e.
- don't mind if an indexed auxtrace_event is bigger than struct auxtrace_event
- don't mind if the auxtrace index does not fill the whole file section
Rename 'index' variable to 'ent' to avoid build errors on older gcc

perf tools: Add build option NO_AUXTRACE to exclude AUX area tracing
Fix whitespace alignment of NO_AUXTRACE=1
Add NO_AUXTRACE=1 to make_minimal

perf tools: Add support for PERF_RECORD_AUX
Expand commit message

perf tools: Add AUX area tracing Snapshot Mode
Whitespace fixups

perf record: Add AUX area tracing Snapshot Mode support
Whitespace fixups
Don't init static variables to 0 or NULL

perf tools: Add Intel PT packet decoder
Whitespace fixups

perf tools: Add Intel PT instruction decoder
Avoid build error on older (broken) gcc by adding -Wno-override-init Avoid build errors due to funny collate sequences i.e. use LC_COLLATE=C etc

perf tools: Add Intel PT decoder
Avoid build errors initializing structures to 0

perf tools: Add Intel PT support
Avoid build errors initializing structures to 0
Allow for perf_pmu__config_terms() having an extra parameter now Allow for parse_events() having an extra parameter now Rename 'div' variable to 'd' to avoid build errors Whitespace fixup
Remove a couple of unused enums

perf tools: Add Intel BTS support
Avoid build errors initializing structures to 0 Allow for parse_events() having an extra parameter now

perf tools: Put itrace options into an asciidoc include
New patch

Changes in V3:

New patch:
perf tools: Amend mmap ref counting for the AUX area mmap

Move some code under arch:
perf tools: Add Intel PT support
perf tools: Add Intel BTS support

Updated documentation:
perf report: Add Instruction Tracing support
perf auxtrace: Add option to synthesize events for transactions perf tools: Take Intel PT into use
perf tools: Add Intel BTS support

Patches already applied:
perf header: Add AUX area tracing feature
perf evlist: Add support for mmapping an AUX area buffer
perf tools: Add user events for AUX area tracing
perf tools: Add support for AUX area recording
perf record: Add basic AUX area tracing support
perf record: Extend -m option for AUX area tracing mmap pages perf tools: Add a user event for AUX area tracing errors
perf session: Add hooks to allow transparent decoding of AUX area tracing data perf session: Add instruction tracing options
perf auxtrace: Add helpers for AUX area tracing errors
perf auxtrace: Add helpers for queuing AUX area tracing data perf auxtrace: Add a heap for sorting AUX area tracing queues perf auxtrace: Add processing for AUX area tracing events
perf auxtrace: Add a hashtable for caching
perf tools: Add member to struct dso for an instruction cache perf script: Add Instruction Tracing support
perf inject: Re-pipe AUX area tracing events
perf inject: Add Instruction Tracing support
perf script: Add field option 'flags' to print sample flags
perf tools: Add aux_watermark member of struct perf_event_attr

Changes in V2:

Get rid of MIN()
perf auxtrace: Add helpers for AUX area tracing errors perf inject: Re-pipe AUX area tracing events
perf tools: Add build option NO_AUXTRACE to exclude AUX area tracing

Intel BTS can be used on most recent Intel CPUs. Intel PT is available on Broadwell.

Examples:

Trace 'ls' with Intel BTS userspace only

perf record --per-thread -e intel_bts//u ls perf report
perf script

Trace 'ls' with Intel BTS kernel and userspace

~/libexec/perf-core/perf-with-kcore record bts-ls --per-thread -e intel_bts// -- ls ~/libexec/perf-core/perf-with-kcore report bts-ls ~/libexec/perf-core/perf-with-kcore script bts-ls

Trace 'ls' with Intel PT userspace only

perf record -e intel_pt//u ls
perf report
perf script

Trace 'ls' with Intel PT kernel and userspace

~/libexec/perf-core/perf-with-kcore record pt-ls -e intel_pt// -- ls ~/libexec/perf-core/perf-with-kcore report pt-ls ~/libexec/perf-core/perf-with-kcore script pt-ls

The abstraction has two separate aspects:
1. recording AUX area data
2. processing AUX area data

Recording consists of mmapping a separate buffer and copying the data into the perf.data file. The buffer is an AUX area buffer. The data is written preceded by a new user event PERF_RECORD_AUXTRACE. The data is too big to fit in the event but follows immediately afterward. Session processing has to skip to get to the next event header in a similar fashion to the existing PERF_RECORD_HEADER_TRACING_DATA
event. The main recording patches are:

perf evlist: Add support for mmapping an AUX area buffer perf tools: Add user events for AUX area tracing perf tools: Add support for AUX area recording perf record: Add basic AUX area tracing support

Processing consists of providing hooks in session processing to enable a decoder to see all the events and deliver synthesized events transparently into the event stream. The main processing patch is:

perf session: Add hooks to allow transparent decoding of AUX area tracing data

Adrian Hunter (25):
perf auxtrace: Add Intel PT as an AUX area tracing type perf tools: Add Intel PT packet decoder
perf tools: Add Intel PT instruction decoder
perf tools: Add Intel PT log
perf tools: Add Intel PT decoder
perf tools: Add Intel PT support
perf tools: Take Intel PT into use
perf tools: Add Intel BTS support
perf tools: Put itrace options into an asciidoc include perf tools: Add example call-graph script
perf auxtrace: Fix period type 'i' not working
perf tools: Fix perf-with-kcore handling of arguments containing spaces perf tools: Fix Intel PT 'instructions' sample period
perf tools: Add perf_pmu__format_bits()
perf tools: Validate config term maximum value
perf tools: Extend the event parser maximum error index perf tools: Add Intel PT support for PSB periods
perf tools: Add new Intel PT packet definitions
perf tools: Pass Intel PT information for decoding MTC and CYC perf tools: Add Intel PT support for decoding MTC packets perf tools: Add Intel PT support for using MTC packets
perf tools: Add Intel PT support for decoding CYC packets perf tools: Add Intel PT support for using CYC packets
perf tools: Add Intel PT support for decoding TRACESTOP packets perf tools: Update Intel PT documentation

 tools/build/Makefile.build                         |    2 +
 tools/perf/.gitignore                              |    1 +
 tools/perf/Documentation/intel-bts.txt             |   86 +
 tools/perf/Documentation/intel-pt.txt              |  766 +++++++
 tools/perf/Documentation/itrace.txt                |   22 +
 tools/perf/Documentation/perf-inject.txt           |   23 +-
 tools/perf/Documentation/perf-report.txt           |   23 +-
 tools/perf/Documentation/perf-script.txt           |   23 +-
 tools/perf/Makefile.perf                           |   12 +-
 tools/perf/arch/x86/util/Build                     |    5 +
 tools/perf/arch/x86/util/auxtrace.c                |   83 +
 tools/perf/arch/x86/util/intel-bts.c               |  458 ++++
 tools/perf/arch/x86/util/intel-pt.c                | 1007 +++++++++
 tools/perf/arch/x86/util/pmu.c                     |   18 +
 tools/perf/perf-with-kcore.sh                      |   28 +-
 .../scripts/python/call-graph-from-postgresql.py   |  327 +++
 tools/perf/scripts/python/export-to-postgresql.py  |   47 +
 tools/perf/util/Build                              |    3 +
 tools/perf/util/auxtrace.c                         |   15 +-
 tools/perf/util/auxtrace.h                         |    2 +
 tools/perf/util/intel-bts.c                        |  933 ++++++++
 tools/perf/util/intel-bts.h                        |   43 +
 tools/perf/util/intel-pt-decoder/Build             |   11 +
 .../util/intel-pt-decoder/gen-insn-attr-x86.awk    |  386 ++++
 tools/perf/util/intel-pt-decoder/inat.c            |   96 +
 tools/perf/util/intel-pt-decoder/inat.h            |  221 ++
 tools/perf/util/intel-pt-decoder/inat_types.h      |   29 +
 tools/perf/util/intel-pt-decoder/insn.c            |  594 +++++
 tools/perf/util/intel-pt-decoder/insn.h            |  201 ++
 .../perf/util/intel-pt-decoder/intel-pt-decoder.c  | 2345 ++++++++++++++++++++
 .../perf/util/intel-pt-decoder/intel-pt-decoder.h  |  109 +
 .../util/intel-pt-decoder/intel-pt-insn-decoder.c  |  246 ++
 .../util/intel-pt-decoder/intel-pt-insn-decoder.h  |   65 +
 tools/perf/util/intel-pt-decoder/intel-pt-log.c    |  155 ++
 tools/perf/util/intel-pt-decoder/intel-pt-log.h    |   52 +
 .../util/intel-pt-decoder/intel-pt-pkt-decoder.c   |  518 +++++
 .../util/intel-pt-decoder/intel-pt-pkt-decoder.h   |   70 +
 .../perf/util/intel-pt-decoder/x86-opcode-map.txt  |  970 ++++++++
 tools/perf/util/intel-pt.c                         | 1956 ++++++++++++++++
 tools/perf/util/intel-pt.h                         |   56 +
 tools/perf/util/parse-events.c                     |    2 +-
 tools/perf/util/pmu.c                              |   51 +-
 tools/perf/util/pmu.h                              |    1 +
 43 files changed, 11970 insertions(+), 91 deletions(-)
 create mode 100644 tools/perf/Documentation/intel-bts.txt
 create mode 100644 tools/perf/Documentation/intel-pt.txt
 create mode 100644 tools/perf/Documentation/itrace.txt
 create mode 100644 tools/perf/arch/x86/util/auxtrace.c
 create mode 100644 tools/perf/arch/x86/util/intel-bts.c
 create mode 100644 tools/perf/arch/x86/util/intel-pt.c
 create mode 100644 tools/perf/arch/x86/util/pmu.c
 create mode 100644 tools/perf/scripts/python/call-graph-from-postgresql.py
 create mode 100644 tools/perf/util/intel-bts.c
 create mode 100644 tools/perf/util/intel-bts.h
 create mode 100644 tools/perf/util/intel-pt-decoder/Build
 create mode 100644 tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk
 create mode 100644 tools/perf/util/intel-pt-decoder/inat.c
 create mode 100644 tools/perf/util/intel-pt-decoder/inat.h
 create mode 100644 tools/perf/util/intel-pt-decoder/inat_types.h
 create mode 100644 tools/perf/util/intel-pt-decoder/insn.c
 create mode 100644 tools/perf/util/intel-pt-decoder/insn.h
 create mode 100644 tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
 create mode 100644 tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
 create mode 100644 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c
 create mode 100644 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.h
 create mode 100644 tools/perf/util/intel-pt-decoder/intel-pt-log.c
 create mode 100644 tools/perf/util/intel-pt-decoder/intel-pt-log.h
 create mode 100644 tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
 create mode 100644 tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.h
 create mode 100644 tools/perf/util/intel-pt-decoder/x86-opcode-map.txt
 create mode 100644 tools/perf/util/intel-pt.c
 create mode 100644 tools/perf/util/intel-pt.h

Regards
Adrian