diff mbox series

[14/35] perf tools: Use sample->machine_pid to find guest machine

Message ID 20220711093218.10967-15-adrian.hunter@intel.com (mailing list archive)
State New, archived
Headers show
Series perf intel-pt: Add support for tracing virtual machine user space on the host | expand

Commit Message

Adrian Hunter July 11, 2022, 9:31 a.m. UTC
If machine_pid is set, use it to find the guest machine.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/session.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ian Rogers July 20, 2022, 12:37 a.m. UTC | #1
On Mon, Jul 11, 2022 at 2:33 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> 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>

Thanks,
Ian

> ---
>  tools/perf/util/session.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 91a091c35945..f3e9fa557bc9 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -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
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 91a091c35945..f3e9fa557bc9 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -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