diff mbox series

[18/35] perf script python: Add machine_pid and vcpu

Message ID 20220711093218.10967-19-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
Add machine_pid and vcpu to python sample events and context switch events.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 .../perf/util/scripting-engines/trace-event-python.c  | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Ian Rogers July 20, 2022, 12:43 a.m. UTC | #1
On Mon, Jul 11, 2022 at 2:33 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> Add machine_pid and vcpu to python sample events and context switch events.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

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

Thanks,
Ian

> ---
>  .../perf/util/scripting-engines/trace-event-python.c  | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
> index 3367c5479199..5bbc1b16f368 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -861,6 +861,13 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,
>         brstacksym = python_process_brstacksym(sample, al->thread);
>         pydict_set_item_string_decref(dict, "brstacksym", brstacksym);
>
> +       if (sample->machine_pid) {
> +               pydict_set_item_string_decref(dict_sample, "machine_pid",
> +                               _PyLong_FromLong(sample->machine_pid));
> +               pydict_set_item_string_decref(dict_sample, "vcpu",
> +                               _PyLong_FromLong(sample->vcpu));
> +       }
> +
>         pydict_set_item_string_decref(dict_sample, "cpumode",
>                         _PyLong_FromLong((unsigned long)sample->cpumode));
>
> @@ -1509,7 +1516,7 @@ static void python_do_process_switch(union perf_event *event,
>                 np_tid = event->context_switch.next_prev_tid;
>         }
>
> -       t = tuple_new(9);
> +       t = tuple_new(11);
>         if (!t)
>                 return;
>
> @@ -1522,6 +1529,8 @@ static void python_do_process_switch(union perf_event *event,
>         tuple_set_s32(t, 6, machine->pid);
>         tuple_set_bool(t, 7, out);
>         tuple_set_bool(t, 8, out_preempt);
> +       tuple_set_s32(t, 9, sample->machine_pid);
> +       tuple_set_s32(t, 10, sample->vcpu);
>
>         call_object(handler, t, handler_name);
>
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 3367c5479199..5bbc1b16f368 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -861,6 +861,13 @@  static PyObject *get_perf_sample_dict(struct perf_sample *sample,
 	brstacksym = python_process_brstacksym(sample, al->thread);
 	pydict_set_item_string_decref(dict, "brstacksym", brstacksym);
 
+	if (sample->machine_pid) {
+		pydict_set_item_string_decref(dict_sample, "machine_pid",
+				_PyLong_FromLong(sample->machine_pid));
+		pydict_set_item_string_decref(dict_sample, "vcpu",
+				_PyLong_FromLong(sample->vcpu));
+	}
+
 	pydict_set_item_string_decref(dict_sample, "cpumode",
 			_PyLong_FromLong((unsigned long)sample->cpumode));
 
@@ -1509,7 +1516,7 @@  static void python_do_process_switch(union perf_event *event,
 		np_tid = event->context_switch.next_prev_tid;
 	}
 
-	t = tuple_new(9);
+	t = tuple_new(11);
 	if (!t)
 		return;
 
@@ -1522,6 +1529,8 @@  static void python_do_process_switch(union perf_event *event,
 	tuple_set_s32(t, 6, machine->pid);
 	tuple_set_bool(t, 7, out);
 	tuple_set_bool(t, 8, out_preempt);
+	tuple_set_s32(t, 9, sample->machine_pid);
+	tuple_set_s32(t, 10, sample->vcpu);
 
 	call_object(handler, t, handler_name);