perf: Add support for Intel Processor Trace
Get series with b4
b4 am 1386765443-26966-1-git-send-email-alexander.shishkin@linux.intel.comVersions newest first
- v0 Latest71 patches 86 repliesIn review
Patches in v0 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/71 | perf: Disable all pmus on unthrottling and reschedulingkernel/ | +24 | 4 replies | |
| 2/71 | x86: Add Intel Processor Trace (INTEL_PT) cpu feature detectionarch/ arch/ | +2 | 0 replies | |
| 3/71 | perf: Abstract ring_buffer backing store operationskernel/ kernel/ kernel/ | +122 | 0 replies | |
| 4/71 | itrace: Infrastructure for instruction flow tracing unitsfs/ fs/ include/ +12 more | +1020 | 42 replies | |
| 5/71 | x86: perf: Intel PT PMU driverarch/ arch/ arch/ +3 more | +1329 | 0 replies | |
| 6/71 | perf: Allow set-output for task contexts of different typeskernel/ | +2 | 0 replies | |
| 7/71 | perf tools: Record whether a dso is 64-bittools/ tools/ tools/ +3 more | +30 | 10 replies | |
| 8/71 | perf tools: Let a user specify a PMU event without any config termstools/ tools/ | +16 | 0 replies | |
| 9/71 | perf tools: Let default config be defined for a PMUtools/ tools/ tools/ +1 more | +41 | 0 replies | |
| 10/71 | perf tools: Add perf_pmu__scan_file()tools/ tools/ | +40 | 0 replies | |
| 11/71 | perf tools: Add perf_event_paranoid()tools/ tools/ tools/ | +23 | 0 replies | |
| 12/71 | perf tools: Add dsos__hit_all()tools/ tools/ | +43 | 0 replies | |
| 13/71 | perf tools: Add machine__get_thread_pid()tools/ tools/ | +12 | 4 replies | |
| 14/71 | perf tools: Add cpu to struct threadtools/ tools/ tools/ +1 more | +31 | 5 replies | |
| 15/71 | perf tools: Add ability to record the current tid for each cputools/ tools/ | +43 | 0 replies | |
| 16/71 | perf tools: Allow header->data_offset to be predeterminedtools/ | +2 | 0 replies | |
| 17/71 | perf tools: Add perf_evlist__can_select_event()tools/ tools/ | +39 | 0 replies | |
| 18/71 | perf session: Flag if the event stream is entirely in memorytools/ tools/ | +11 | 0 replies | |
| 19/71 | perf evlist: Pass mmap parameters in a structtools/ | +26 | 0 replies | |
| 20/71 | perf tools: Move mem_bswap32/64 to util.ctools/ tools/ tools/ +1 more | +25 | 0 replies | |
| 21/71 | perf tools: Add feature test for __sync_val_compare_and_swaptools/ tools/ tools/ +1 more | +28 | 4 replies | |
| 22/71 | perf tools: Add option macro OPT_CALLBACK_OPTARGtools/ | +5 | 0 replies | |
| 23/71 | perf evlist: Add perf_evlist__to_front()tools/ tools/ | +20 | 2 replies | |
| 24/71 | perf evlist: Add perf_evlist__set_tracking_event()tools/ tools/ | +22 | 0 replies | |
| 25/71 | perf evsel: Add 'no_aux_samples' optiontools/ tools/ | +4 | 0 replies | |
| 26/71 | perf evsel: Add 'immediate' optiontools/ tools/ | +6 | 0 replies | |
| 27/71 | perf evlist: Add 'system_wide' optiontools/ tools/ tools/ | +64 | 2 replies | |
| 28/71 | perf tools: Add id indextools/ tools/ tools/ +5 more | +177 | 0 replies | |
| 29/71 | perf pmu: Let pmu's with no events show up on perf listtools/ tools/ | +12 | 0 replies | |
| 30/71 | perf session: Add ability to skip 4GiB or moretools/ | +13 | 0 replies | |
| 31/71 | perf session: Add perf_session__deliver_synth_event()tools/ tools/ | +19 | 0 replies | |
| 32/71 | perf tools: Allow TSC conversion on any archtools/ tools/ tools/ +3 more | +40 | 0 replies | |
| 33/71 | perf tools: Move rdtsc() functiontools/ tools/ tools/ +1 more | +15 | 0 replies | |
| 34/71 | perf evlist: Add perf_evlist__enable_event_idx()tools/ tools/ | +49 | 0 replies | |
| 35/71 | perf tools: Add itrace members of struct perf_event_attrtools/ tools/ | +8 | 0 replies | |
| 36/71 | perf tools: Add support for parsing pmu itrace_configtools/ tools/ tools/ +4 more | +19 | 0 replies | |
| 37/71 | perf tools: Add support for PERF_RECORD_ITRACE_LOSTtools/ tools/ tools/ +4 more | +47 | 0 replies | |
| 38/71 | perf tools: Add itrace sample parsingtools/ tools/ tools/ +4 more | +72 | 0 replies | |
| 39/71 | perf header: Add Instruction Tracing featuretools/ tools/ | +15 | 0 replies | |
| 40/71 | perf evlist: Add ability to mmap itrace bufferstools/ tools/ tools/ +2 more | +283 | 0 replies | |
| 41/71 | perf tools: Add user events for Instruction Tracingtools/ tools/ tools/ +1 more | +101 | 0 replies | |
| 42/71 | perf tools: Add support for Instruction Trace recordingtools/ tools/ tools/ +1 more | +247 | 0 replies | |
| 43/71 | perf record: Add basic Instruction Tracing supporttools/ | +87 | 0 replies | |
| 44/71 | perf record: Extend -m option for Instruction Tracing mmap pagestools/ tools/ tools/ +1 more | +60 | 0 replies | |
| 45/71 | perf tools: Add a user event for Instruction Tracing errorstools/ tools/ tools/ +1 more | +44 | 0 replies | |
| 46/71 | perf session: Add Instruction Tracing hookstools/ tools/ tools/ | +91 | 0 replies | |
| 47/71 | perf session: Add Instruction Tracing optionstools/ tools/ tools/ | +135 | 0 replies | |
| 48/71 | perf session: Make perf_event__itrace_swap() non-statictools/ tools/ | +3 | 0 replies | |
| 49/71 | perf itrace: Add helpers for Instruction Tracing errorstools/ tools/ | +71 | 0 replies | |
| 50/71 | perf itrace: Add helpers for queuing Instruction Tracing datatools/ tools/ | +355 | 0 replies | |
| 51/71 | perf itrace: Add a heap for sorting Instruction Tracing queuestools/ tools/ | +115 | 0 replies | |
| 52/71 | perf itrace: Add processing for Instruction Tracing eventstools/ tools/ | +65 | 0 replies | |
| 53/71 | perf script: Add Instruction Tracing supporttools/ tools/ | +32 | 0 replies | |
| 54/71 | perf script: Always allow fields 'addr' and 'cpu' for itracetools/ | +2 | 2 replies | |
| 55/71 | perf report: Add Instruction Tracing supporttools/ tools/ | +33 | 0 replies | |
| 56/71 | perf tools: Add Instruction Trace sampling supporttools/ tools/ tools/ +3 more | +176 | 0 replies | |
| 57/71 | perf record: Add Instruction Trace sampling supporttools/ tools/ | +18 | 0 replies | |
| 58/71 | perf tools: Add Instruction Tracing Snapshot Modetools/ tools/ tools/ | +93 | 0 replies | |
| 59/71 | perf record: Add Instruction Tracing Snapshot Mode supporttools/ tools/ | +95 | 0 replies | |
| 60/71 | perf inject: Re-pipe Instruction Tracing eventstools/ | +59 | 0 replies | |
| 61/71 | perf inject: Add Instruction Tracing supporttools/ tools/ | +89 | 0 replies | |
| 62/71 | perf inject: Cut Instruction Tracing samplestools/ | +29 | 0 replies | |
| 63/71 | perf tools: Add Instruction Tracing indextools/ tools/ tools/ +4 more | +313 | 0 replies | |
| 64/71 | perf tools: Hit all build ids when Instruction Tracingtools/ tools/ tools/ | +26 | 0 replies | |
| 65/71 | perf itrace: Add Intel PT as an Instruction Tracing typetools/ tools/ | +2 | 0 replies | |
| 66/71 | perf tools: Add Intel PT packet decodertools/ tools/ tools/ | +474 | 0 replies | |
| 67/71 | perf tools: Add Intel PT instruction decodertools/ tools/ tools/ | +308 | 0 replies | |
| 68/71 | perf tools: Add Intel PT logtools/ tools/ tools/ | +173 | 0 replies | |
| 69/71 | perf tools: Add Intel PT decodertools/ tools/ tools/ | +1763 | 0 replies | |
| 70/71 | perf tools: Add Intel PT supporttools/ tools/ tools/ | +2235 | 0 replies | |
| 71/71 | perf tools: Take Intel PT into usetools/ tools/ tools/ +2 more | +642 | 0 replies |
Reviews trailers per patch
1 of 71 patches has a Reviewed-by or Acked-by.
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v0 00/71] perf: Add support for Intel Processor Trace
Hi,
This patchset adds support for Intel Processor Trace (PT) extension [1] of Intel Architecture that allows the capture of information about software execution flow, to the perf kernel and userspace infrastructure. We provide an abstraction for it called "itrace" for "instruction trace" ([2]).
The single most notable thing is that while PT outputs trace data in a compressed binary format, it will still generate hundreds of megabytes of trace data per second per core. Decoding this binary stream takes 2-3 orders of magnitude the cpu time that it takes to generate it. These considerations make it impossible to carry out decoding in kernel space. Therefore, the trace data is exported to userspace as a zero-copy mapping that userspace can collect and store for later decoding. To that end, perf is extended to support an additional ring buffer per event, which will export the trace data. This ring buffer is mapped from the event's file descriptor with a special "magic" offset. This ring buffer has its own user page with data_head and data_tail (in case the buffer is mapped writable) pointers used as read/write pointers in the buffer.
This way we get a normal perf data stream that provides sideband information that is required to decode the trace data, such as MMAPs, COMMs etc, plus the actual trace in a separate buffer.
If the trace buffer is mapped writable, the driver will stop tracing when it fills up (data_head approaches data_tail), till data is read, data_tail pointer is moved forward and an ioctl() is issued to re-enable tracing. If the trace buffer is mapped read only, the tracing will continue, overwriting older data, so that the buffer always contains the most recent data. Tracing can be stopped with an ioctl() and restarted once the data is collected.
Another use case is annotating samples of other perf events: if you set PERF_SAMPLE_ITRACE, attr.itrace_sample_size bytes of trace will be included in each event's sample.
Also, itrace data can be included in process core dumps, which can be enabled with a new rlimit -- RLIMIT_ITRACE.
This patchset consists of necessary changes to the perf kernel infrastructure, PT pmu driver and the remaining 60+ patches meticulously add itrace/PT support to perf userspace.
Patch Summary
1 - 5 kernel support for Intel PT
6 Allow set-output for task contexts of different types
7 - 34 perf tools preparatory changes
35 - 64 perf tools Instruction Tracing support
65 - 71 perf tools Intel PT support
[1] http://software.intel.com/en-us/intel-isa-extensions
[2] http://events.linuxfoundation.org/sites/events/files/slides/lcna13_kleen.pdf
Adrian Hunter (66):
perf: Allow set-output for task contexts of different types perf tools: Record whether a dso is 64-bit
perf tools: Let a user specify a PMU event without any config terms perf tools: Let default config be defined for a PMU
perf tools: Add perf_pmu__scan_file()
perf tools: Add perf_event_paranoid()
perf tools: Add dsos__hit_all()
perf tools: Add machine__get_thread_pid()
perf tools: Add cpu to struct thread
perf tools: Add ability to record the current tid for each cpu perf tools: Allow header->data_offset to be predetermined perf tools: Add perf_evlist__can_select_event()
perf session: Flag if the event stream is entirely in memory perf evlist: Pass mmap parameters in a struct
perf tools: Move mem_bswap32/64 to util.c
perf tools: Add feature test for __sync_val_compare_and_swap perf tools: Add option macro OPT_CALLBACK_OPTARG
perf evlist: Add perf_evlist__to_front()
perf evlist: Add perf_evlist__set_tracking_event()
perf evsel: Add 'no_aux_samples' option
perf evsel: Add 'immediate' option
perf evlist: Add 'system_wide' option
perf tools: Add id index
perf pmu: Let pmu's with no events show up on perf list perf session: Add ability to skip 4GiB or more
perf session: Add perf_session__deliver_synth_event() perf tools: Allow TSC conversion on any arch
perf tools: Move rdtsc() function
perf evlist: Add perf_evlist__enable_event_idx()
perf tools: Add itrace members of struct perf_event_attr perf tools: Add support for parsing pmu itrace_config perf tools: Add support for PERF_RECORD_ITRACE_LOST
perf tools: Add itrace sample parsing
perf header: Add Instruction Tracing feature
perf evlist: Add ability to mmap itrace buffers
perf tools: Add user events for Instruction Tracing
perf tools: Add support for Instruction Trace recording perf record: Add basic Instruction Tracing support
perf record: Extend -m option for Instruction Tracing mmap pages perf tools: Add a user event for Instruction Tracing errors perf session: Add Instruction Tracing hooks
perf session: Add Instruction Tracing options
perf session: Make perf_event__itrace_swap() non-static perf itrace: Add helpers for Instruction Tracing errors perf itrace: Add helpers for queuing Instruction Tracing data perf itrace: Add a heap for sorting Instruction Tracing queues perf itrace: Add processing for Instruction Tracing events perf script: Add Instruction Tracing support
perf script: Always allow fields 'addr' and 'cpu' for itrace perf report: Add Instruction Tracing support
perf tools: Add Instruction Trace sampling support
perf record: Add Instruction Trace sampling support
perf tools: Add Instruction Tracing Snapshot Mode
perf record: Add Instruction Tracing Snapshot Mode support perf inject: Re-pipe Instruction Tracing events
perf inject: Add Instruction Tracing support
perf inject: Cut Instruction Tracing samples
perf tools: Add Instruction Tracing index
perf tools: Hit all build ids when Instruction Tracing perf itrace: Add Intel PT as an Instruction 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
Alexander Shishkin (5):
perf: Disable all pmus on unthrottling and rescheduling
x86: Add Intel Processor Trace (INTEL_PT) cpu feature detection
perf: Abstract ring_buffer backing store operations
itrace: Infrastructure for instruction flow tracing units
x86: perf: Intel PT PMU driver
arch/x86/include/asm/cpufeature.h | 1 + arch/x86/include/uapi/asm/msr-index.h | 18 + arch/x86/kernel/cpu/Makefile | 1 + arch/x86/kernel/cpu/intel_pt.h | 129 ++ arch/x86/kernel/cpu/perf_event.c | 4 + arch/x86/kernel/cpu/perf_event_intel.c | 10 + arch/x86/kernel/cpu/perf_event_intel_pt.c | 1167 +++++++++++ arch/x86/kernel/cpu/scattered.c | 1 + fs/binfmt_elf.c | 6 + fs/proc/base.c | 1 + include/asm-generic/resource.h | 1 + include/linux/itrace.h | 147 ++ include/linux/perf_event.h | 33 +- include/uapi/asm-generic/resource.h | 3 +- include/uapi/linux/elf.h | 1 + include/uapi/linux/perf_event.h | 25 +- kernel/events/Makefile | 2 +- kernel/events/core.c | 329 ++- kernel/events/internal.h | 21 +- kernel/events/itrace.c | 589 ++++++ kernel/events/ring_buffer.c | 176 +- kernel/exit.c | 3 + kernel/sys.c | 5 + tools/perf/Documentation/intel-pt.txt | 581 ++++++ tools/perf/Documentation/perf-inject.txt | 20 + tools/perf/Documentation/perf-record.txt | 14 + tools/perf/Documentation/perf-report.txt | 21 + tools/perf/Documentation/perf-script.txt | 21 + tools/perf/Makefile.perf | 30 +- tools/perf/arch/x86/Makefile | 2 + tools/perf/arch/x86/util/itrace.c | 41 + tools/perf/arch/x86/util/pmu.c | 13 + tools/perf/arch/x86/util/tsc.c | 31 +- tools/perf/arch/x86/util/tsc.h | 3 - tools/perf/builtin-buildid-list.c | 9 + tools/perf/builtin-inject.c | 193 +- tools/perf/builtin-record.c | 277 ++- tools/perf/builtin-report.c | 12 + tools/perf/builtin-script.c | 13 + tools/perf/config/Makefile | 5 + tools/perf/config/feature-checks/Makefile | 4 + tools/perf/config/feature-checks/test-all.c | 5 + .../feature-checks/test-sync-compare-and-swap.c | 14 + tools/perf/perf.h | 14 + tools/perf/tests/perf-time-to-tsc.c | 12 +- tools/perf/tests/pmu.c | 2 +- tools/perf/tests/sample-parsing.c | 7 +- tools/perf/util/dso.c | 1 + tools/perf/util/dso.h | 1 + tools/perf/util/event.c | 21 + tools/perf/util/event.h | 70 + tools/perf/util/evlist.c | 289 ++- tools/perf/util/evlist.h | 19 + tools/perf/util/evsel.c | 86 +- tools/perf/util/evsel.h | 19 +- tools/perf/util/header.c | 73 +- tools/perf/util/header.h | 3 + .../perf/util/intel-pt-decoder/intel-pt-decoder.c | 1678 +++++++++++++++ .../perf/util/intel-pt-decoder/intel-pt-decoder.h | 83 + .../util/intel-pt-decoder/intel-pt-insn-decoder.c | 224 ++ .../util/intel-pt-decoder/intel-pt-insn-decoder.h | 67 + tools/perf/util/intel-pt-decoder/intel-pt-log.c | 119 ++ tools/perf/util/intel-pt-decoder/intel-pt-log.h | 52 + .../util/intel-pt-decoder/intel-pt-pkt-decoder.c | 404 ++++ .../util/intel-pt-decoder/intel-pt-pkt-decoder.h | 68 + tools/perf/util/intel-pt.c | 2193 ++++++++++++++++++++ tools/perf/util/intel-pt.h | 40 + tools/perf/util/itrace.c | 1273 ++++++++++++ tools/perf/util/itrace.h | 476 +++++ tools/perf/util/machine.c | 85 + tools/perf/util/machine.h | 11 + tools/perf/util/parse-events.c | 17 +- tools/perf/util/parse-events.h | 1 + tools/perf/util/parse-events.l | 1 + tools/perf/util/parse-events.y | 10 + tools/perf/util/parse-options.h | 5 + tools/perf/util/pmu.c | 95 +- tools/perf/util/pmu.h | 14 +- tools/perf/util/pmu.l | 1 + tools/perf/util/pmu.y | 9 +- tools/perf/util/record.c | 43 +- tools/perf/util/session.c | 343 ++- tools/perf/util/session.h | 27 +- tools/perf/util/symbol-elf.c | 3 + tools/perf/util/symbol-minimal.c | 23 + tools/perf/util/symbol.c | 1 + tools/perf/util/symbol.h | 1 + tools/perf/util/thread.c | 1 + tools/perf/util/thread.h | 1 + tools/perf/util/tool.h | 12 +- tools/perf/util/tsc.c | 30 + tools/perf/util/tsc.h | 12 + tools/perf/util/util.c | 41 + tools/perf/util/util.h | 6 + 94 files changed, 11708 insertions(+), 361 deletions(-) create mode 100644 arch/x86/kernel/cpu/intel_pt.h create mode 100644 arch/x86/kernel/cpu/perf_event_intel_pt.c create mode 100644 include/linux/itrace.h create mode 100644 kernel/events/itrace.c create mode 100644 tools/perf/Documentation/intel-pt.txt create mode 100644 tools/perf/arch/x86/util/itrace.c create mode 100644 tools/perf/arch/x86/util/pmu.c create mode 100644 tools/perf/config/feature-checks/test-sync-compare-and-swap.c 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.c create mode 100644 tools/perf/util/intel-pt.h create mode 100644 tools/perf/util/itrace.c create mode 100644 tools/perf/util/itrace.h create mode 100644 tools/perf/util/tsc.c create mode 100644 tools/perf/util/tsc.h
Signature · 1 line
1.8.5.1