diff mbox series

[34/35] perf intel-pt: Use guest pid/tid etc in guest samples

Message ID 20220711093218.10967-35-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:32 a.m. UTC
When decoding with guest sideband information, for VMX non-root (NR)
i.e. guest events, replace the host (hypervisor) pid/tid with guest values,
and provide also the new machine_pid and vcpu values.

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

Comments

Ian Rogers July 20, 2022, 5:28 a.m. UTC | #1
On Mon, Jul 11, 2022 at 2:34 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> When decoding with guest sideband information, for VMX non-root (NR)
> i.e. guest events, replace the host (hypervisor) pid/tid with guest values,
> and provide also the new machine_pid and vcpu values.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/util/intel-pt.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
> index 143a096b567b..d5e9fc8106dd 100644
> --- a/tools/perf/util/intel-pt.c
> +++ b/tools/perf/util/intel-pt.c
> @@ -1657,6 +1657,17 @@ static void intel_pt_prep_a_sample(struct intel_pt_queue *ptq,
>
>         sample->pid = ptq->pid;
>         sample->tid = ptq->tid;
> +
> +       if (ptq->pt->have_guest_sideband) {
> +               if ((ptq->state->from_ip && ptq->state->from_nr) ||
> +                   (ptq->state->to_ip && ptq->state->to_nr)) {
> +                       sample->pid = ptq->guest_pid;
> +                       sample->tid = ptq->guest_tid;
> +                       sample->machine_pid = ptq->guest_machine_pid;
> +                       sample->vcpu = ptq->vcpu;
> +               }
> +       }
> +
>         sample->cpu = ptq->cpu;
>         sample->insn_len = ptq->insn_len;
>         memcpy(sample->insn, ptq->insn, INTEL_PT_INSN_BUF_SZ);
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 143a096b567b..d5e9fc8106dd 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1657,6 +1657,17 @@  static void intel_pt_prep_a_sample(struct intel_pt_queue *ptq,
 
 	sample->pid = ptq->pid;
 	sample->tid = ptq->tid;
+
+	if (ptq->pt->have_guest_sideband) {
+		if ((ptq->state->from_ip && ptq->state->from_nr) ||
+		    (ptq->state->to_ip && ptq->state->to_nr)) {
+			sample->pid = ptq->guest_pid;
+			sample->tid = ptq->guest_tid;
+			sample->machine_pid = ptq->guest_machine_pid;
+			sample->vcpu = ptq->vcpu;
+		}
+	}
+
 	sample->cpu = ptq->cpu;
 	sample->insn_len = ptq->insn_len;
 	memcpy(sample->insn, ptq->insn, INTEL_PT_INSN_BUF_SZ);