Skip to content

perf intel-pt: Add support for tracing virtual machine user space on the host

Adrian Hunter kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest35 patches 47 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/35perf tools: Fix dso_id inode generation comparisontools/perf/util/dsos.c+8 -24 replies
2/35perf tools: Export dsos__for_each_with_build_id()tools/perf/util/build-id.c tools/perf/util/dso.h+6 -61 reply
3/35perf ordered_events: Add ordered_events__last_flush_time()tools/perf/util/ordered-events.h+6 -01 reply
4/35perf tools: Export perf_event__process_finished_round()tools/perf/util/session.c tools/perf/util/session.h+8 -82 replies
5/35perf tools: Factor out evsel__id_hdr_size()tools/perf/util/evlist.c tools/perf/util/evsel.c tools/perf/util/evsel.h+29 -273 replies
6/35perf tools: Add perf_event__synthesize_id_sample()tools/perf/util/synthetic-events.c tools/perf/util/synthetic-events.h+48 -01 reply
7/35perf script: Add --dump-unsorted-raw-trace optiontools/perf/Documentation/perf-script.txt tools/perf/builtin-script.c+11 -01 reply
8/35perf buildid-cache: Add guestmount'd files to the build ID cachetools/perf/util/build-id.c tools/perf/util/build-id.h+63 -202 replies
9/35perf buildid-cache: Do not require purge files to also be in the file systemtools/perf/util/build-id.c+2 -51 reply
10/35perf tools: Add machine_pid and vcpu to id_indextools/lib/perf/include/internal/evsel.h tools/lib/perf/include/perf/event.h tools/perf/util/session.c +2 more+84 -172 replies
11/35perf session: Create guest machines from id_indextools/perf/util/session.c+31 -01 reply
12/35perf tools: Add guest_cpu to hypervisor threadstools/perf/util/session.c tools/perf/util/thread.c tools/perf/util/thread.h+20 -01 reply
13/35perf tools: Add machine_pid and vcpu to perf_sampletools/perf/util/event.h tools/perf/util/evlist.c tools/perf/util/evsel.c+16 -11 reply
14/35perf tools: Use sample->machine_pid to find guest machinetools/perf/util/session.c+3 -11 reply
15/35perf script: Add machine_pid and vcputools/perf/Documentation/perf-script.txt tools/perf/builtin-script.c+17 -11 reply
16/35perf dlfilter: Add machine_pid and vcputools/perf/Documentation/perf-dlfilter.txt tools/perf/include/perf/perf_dlfilter.h tools/perf/util/dlfilter.c+32 -01 reply
17/35perf auxtrace: Add machine_pid and vcpu to auxtrace_errortools/lib/perf/include/perf/event.h tools/perf/util/auxtrace.c tools/perf/util/auxtrace.h +2 more+37 -71 reply
18/35perf script python: Add machine_pid and vcputools/perf/util/scripting-engines/trace-event-python.c+10 -11 reply
19/35perf script python: intel-pt-events: Add machine_pid and vcputools/perf/scripts/python/intel-pt-events.py+27 -51 reply
20/35perf tools: Remove also guest kcore_dir with host kcore_dirtools/perf/util/util.c+35 -21 reply
21/35perf tools: Make has_kcore_dir() work also for guest kcore_dirtools/perf/util/data.c+15 -91 reply
22/35perf tools: Automatically use guest kcore_dir if presenttools/perf/util/data.c tools/perf/util/data.h tools/perf/util/machine.h +2 more+27 -21 reply
23/35perf tools: Add reallocarray_as_needed()tools/perf/util/util.c tools/perf/util/util.h+48 -02 replies
24/35perf inject: Add support for injecting guest sideband eventstools/perf/Documentation/perf-inject.txt tools/perf/builtin-inject.c+1059 -12 replies
25/35perf machine: Use realloc_array_as_needed() in machine__set_current_tid()tools/perf/util/machine.c tools/perf/util/machine.h+8 -190 replies
26/35perf tools: Handle injected guest kernel mmap eventtools/perf/util/machine.c+12 -31 reply
27/35perf tools: Add perf_event__is_guest()tools/perf/util/event.h+21 -03 replies
28/35perf intel-pt: Remove guest_machine_pidtools/perf/util/intel-pt.c+1 -31 reply
29/35perf intel-pt: Add some more logging to intel_pt_walk_next_insn()tools/perf/util/intel-pt.c+20 -51 reply
30/35perf intel-pt: Track guest context switchestools/perf/util/intel-pt.c+23 -01 reply
31/35perf intel-pt: Disable sync switch with guest sidebandtools/perf/util/intel-pt.c+29 -01 reply
32/35perf intel-pt: Determine guest thread from guest sidebandtools/perf/util/intel-pt.c+67 -21 reply
33/35perf intel-pt: Add machine_pid and vcpu to auxtrace_errortools/perf/util/intel-pt.c+20 -61 reply
34/35perf intel-pt: Use guest pid/tid etc in guest samplestools/perf/util/intel-pt.c+11 -01 reply
35/35perf intel-pt: Add documentation for tracing guest machine user spacetools/perf/Documentation/perf-intel-pt.txt+177 -41 reply

Reviews trailers per patch

23 of 35 patches have a Reviewed-by or Acked-by.

PatchIan Rogers
1/35
2/35A-b
3/35A-b
4/35A-b
5/35
6/35
7/35A-b
8/35A-b
9/35
10/35
11/35A-b
12/35
13/35A-b
14/35A-b
15/35
16/35A-b
17/35A-b
18/35A-b
19/35A-b
20/35A-b
21/35A-b
22/35
23/35
24/35
25/35
26/35A-b
27/35
28/35A-b
29/35A-b
30/35A-b
31/35A-b
32/35A-b
33/35A-b
34/35A-b
35/35A-b

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

Read the v1 thread

Cover letter [PATCH 00/35] perf intel-pt: Add support for tracing virtual machine user space on the host

Hi

Here are patches to support decoding an Intel PT trace that contains data from virtual machine userspace.

This is done by adding functionality to perf inject to be able to inject sideband events needed for decoding, into the perf.data file recorded on the host. That is, inject events from a perf.data file recorded in a virtual machine into a perf.data file recorded on the host at the same time.

For more details, see the example in the documentation added in the last patch.

Note there was already support for tracing virtual machines kernel-only:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Documentation/perf-intel-pt.txt?h=v5.19-rc1#n1221

or the special case of tracing KVM self tests:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Documentation/perf-intel-pt.txt?h=v5.19-rc1#n1403

For general information about Intel PT also see the wiki page:

https://perf.wiki.kernel.org/index.php/Perf_tools_support_for_Intel%C2%AE_Processor_Trace

The patches fall into 5 groups:
1. the first patch is a fix
2. the next 22 patches are preparation
3. the main patch is "perf inject: Add support for injecting guest sideband events"
4. 3 more preparation patches
5. Intel PT decoding changes

The patches are mostly small except for "perf inject: Add support for injecting guest sideband events". However the code there adds new functionality, does not affect existing functionality and is consequently pretty self-contained.

Adrian Hunter (35):
perf tools: Fix dso_id inode generation comparison
perf tools: Export dsos__for_each_with_build_id()
perf ordered_events: Add ordered_events__last_flush_time()
perf tools: Export perf_event__process_finished_round()
perf tools: Factor out evsel__id_hdr_size()
perf tools: Add perf_event__synthesize_id_sample()
perf script: Add --dump-unsorted-raw-trace option
perf buildid-cache: Add guestmount'd files to the build ID cache perf buildid-cache: Do not require purge files to also be in the file system perf tools: Add machine_pid and vcpu to id_index
perf session: Create guest machines from id_index
perf tools: Add guest_cpu to hypervisor threads
perf tools: Add machine_pid and vcpu to perf_sample
perf tools: Use sample->machine_pid to find guest machine
perf script: Add machine_pid and vcpu
perf dlfilter: Add machine_pid and vcpu
perf auxtrace: Add machine_pid and vcpu to auxtrace_error
perf script python: Add machine_pid and vcpu
perf script python: intel-pt-events: Add machine_pid and vcpu perf tools: Remove also guest kcore_dir with host kcore_dir perf tools: Make has_kcore_dir() work also for guest kcore_dir perf tools: Automatically use guest kcore_dir if present
perf tools: Add reallocarray_as_needed()
perf inject: Add support for injecting guest sideband events perf machine: Use realloc_array_as_needed() in machine__set_current_tid() perf tools: Handle injected guest kernel mmap event
perf tools: Add perf_event__is_guest()
perf intel-pt: Remove guest_machine_pid
perf intel-pt: Add some more logging to intel_pt_walk_next_insn() perf intel-pt: Track guest context switches
perf intel-pt: pt disable sync switch
perf intel-pt: Determine guest thread from guest sideband
perf intel-pt: Add machine_pid and vcpu to auxtrace_error
perf intel-pt: Use guest pid/tid etc in guest samples
perf intel-pt: Add documentation for tracing guest machine user space

 tools/lib/perf/include/internal/evsel.h            |    4 +
 tools/lib/perf/include/perf/event.h                |    7 +
 tools/perf/Documentation/perf-dlfilter.txt         |   22 +
 tools/perf/Documentation/perf-inject.txt           |   17 +
 tools/perf/Documentation/perf-intel-pt.txt         |  181 +++-
 tools/perf/Documentation/perf-script.txt           |   10 +-
 tools/perf/builtin-inject.c                        | 1043 +++++++++++++++++++-
 tools/perf/builtin-script.c                        |   19 +
 tools/perf/include/perf/perf_dlfilter.h            |    8 +
 tools/perf/scripts/python/intel-pt-events.py       |   32 +-
 tools/perf/util/auxtrace.c                         |   30 +-
 tools/perf/util/auxtrace.h                         |    4 +
 tools/perf/util/build-id.c                         |   80 +-
 tools/perf/util/build-id.h                         |   16 +-
 tools/perf/util/data.c                             |   43 +-
 tools/perf/util/data.h                             |    1 +
 tools/perf/util/dlfilter.c                         |    2 +
 tools/perf/util/dso.h                              |    6 +
 tools/perf/util/dsos.c                             |   10 +-
 tools/perf/util/event.h                            |   23 +
 tools/perf/util/evlist.c                           |   42 +-
 tools/perf/util/evsel.c                            |   27 +
 tools/perf/util/evsel.h                            |    2 +
 tools/perf/util/intel-pt.c                         |  183 +++-
 tools/perf/util/machine.c                          |   41 +-
 tools/perf/util/machine.h                          |    2 +
 tools/perf/util/ordered-events.h                   |    6 +
 .../util/scripting-engines/trace-event-python.c    |   15 +-
 tools/perf/util/session.c                          |  111 ++-
 tools/perf/util/session.h                          |    4 +
 tools/perf/util/symbol.c                           |    6 +-
 tools/perf/util/synthetic-events.c                 |   98 +-
 tools/perf/util/synthetic-events.h                 |    2 +
 tools/perf/util/thread.c                           |    1 +
 tools/perf/util/thread.h                           |    1 +
 tools/perf/util/util.c                             |   70 +-
 tools/perf/util/util.h                             |   15 +
 37 files changed, 2029 insertions(+), 155 deletions(-)

Regards
Adrian