perf session: Use sample->machine_pid to find guest machine
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 11 Jul 2022 09:31:57 +0000 (12:31 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 20 Jul 2022 14:08:08 +0000 (11:08 -0300)
If machine_pid is set, use it to find the guest machine.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: kvm@vger.kernel.org
Link: https://lore.kernel.org/r/20220711093218.10967-15-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/session.c

index 91a091c359450ca4388f5fda95b0eaf5a8e2338c..f3e9fa557bc92a22b18a8676dbbb672b914bf7ae 100644 (file)
@@ -1418,7 +1418,9 @@ static struct machine *machines__find_for_cpumode(struct machines *machines,
             (sample->cpumode == PERF_RECORD_MISC_GUEST_USER))) {
                u32 pid;
 
-               if (event->header.type == PERF_RECORD_MMAP
+               if (sample->machine_pid)
+                       pid = sample->machine_pid;
+               else if (event->header.type == PERF_RECORD_MMAP
                    || event->header.type == PERF_RECORD_MMAP2)
                        pid = event->mmap.pid;
                else