Em Mon, Jul 11, 2022 at 12:31:43PM +0300, Adrian Hunter escreveu: > 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. Applied locally, going thru tests. - Arnaldo > > 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 -- - Arnaldo