mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf script python: Add the ins_lat field to event handler
@ 2024-08-08  8:00 Zixian Cai
  2024-08-08 11:12 ` Adrian Hunter
  0 siblings, 1 reply; 3+ messages in thread
From: Zixian Cai @ 2024-08-08  8:00 UTC (permalink / raw)
  Cc: fzczx123, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, Adrian Hunter, linux-perf-users, linux-kernel

For example, when using the Alder Lake PMU memory load event, the
instruction latency is stored in ins_lat, while the cache latency is
stored in weight.

This patch reports the ins_lat field for Python scripting.

Signed-off-by: Zixian Cai <fzczx123@gmail.com>
---
 tools/perf/util/scripting-engines/trace-event-python.c | 5 ++++-
 1 file changed, 4 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 41d4f9e6a..68eb0586c 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -861,6 +861,8 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,
 	set_sample_read_in_dict(dict_sample, sample, evsel);
 	pydict_set_item_string_decref(dict_sample, "weight",
 			PyLong_FromUnsignedLongLong(sample->weight));
+	pydict_set_item_string_decref(dict_sample, "ins_lat",
+			PyLong_FromUnsignedLongLong(sample->ins_lat));
 	pydict_set_item_string_decref(dict_sample, "transaction",
 			PyLong_FromUnsignedLongLong(sample->transaction));
 	set_sample_datasrc_in_dict(dict_sample, sample);
@@ -1286,7 +1288,7 @@ static void python_export_sample_table(struct db_export *dbe,
 	struct tables *tables = container_of(dbe, struct tables, dbe);
 	PyObject *t;

-	t = tuple_new(25);
+	t = tuple_new(26);

 	tuple_set_d64(t, 0, es->db_id);
 	tuple_set_d64(t, 1, es->evsel->db_id);
@@ -1313,6 +1315,7 @@ static void python_export_sample_table(struct db_export *dbe,
 	tuple_set_d64(t, 22, es->sample->insn_cnt);
 	tuple_set_d64(t, 23, es->sample->cyc_cnt);
 	tuple_set_s32(t, 24, es->sample->flags);
+	tuple_set_s32(t, 25, es->sample->ins_lat);

 	call_object(tables->sample_handler, t, "sample_table");

--
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf script python: Add the ins_lat field to event handler
  2024-08-08  8:00 [PATCH] perf script python: Add the ins_lat field to event handler Zixian Cai
@ 2024-08-08 11:12 ` Adrian Hunter
  2024-08-08 13:28   ` Zixian Cai
  0 siblings, 1 reply; 3+ messages in thread
From: Adrian Hunter @ 2024-08-08 11:12 UTC (permalink / raw)
  To: Zixian Cai
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, linux-perf-users, linux-kernel

On 8/08/24 11:00, Zixian Cai wrote:
> For example, when using the Alder Lake PMU memory load event, the
> instruction latency is stored in ins_lat, while the cache latency is
> stored in weight.
> 
> This patch reports the ins_lat field for Python scripting.

Patch does not apply.

Needs to be based on upstream kernel.  Latest perf tools kernel
tree and branch is:

	git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git	perf-tools-next

> 
> Signed-off-by: Zixian Cai <fzczx123@gmail.com>
> ---
>  tools/perf/util/scripting-engines/trace-event-python.c | 5 ++++-
>  1 file changed, 4 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 41d4f9e6a..68eb0586c 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -861,6 +861,8 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,
>  	set_sample_read_in_dict(dict_sample, sample, evsel);
>  	pydict_set_item_string_decref(dict_sample, "weight",
>  			PyLong_FromUnsignedLongLong(sample->weight));
> +	pydict_set_item_string_decref(dict_sample, "ins_lat",
> +			PyLong_FromUnsignedLongLong(sample->ins_lat));
>  	pydict_set_item_string_decref(dict_sample, "transaction",
>  			PyLong_FromUnsignedLongLong(sample->transaction));
>  	set_sample_datasrc_in_dict(dict_sample, sample);
> @@ -1286,7 +1288,7 @@ static void python_export_sample_table(struct db_export *dbe,
>  	struct tables *tables = container_of(dbe, struct tables, dbe);
>  	PyObject *t;
> 
> -	t = tuple_new(25);
> +	t = tuple_new(26);
> 
>  	tuple_set_d64(t, 0, es->db_id);
>  	tuple_set_d64(t, 1, es->evsel->db_id);
> @@ -1313,6 +1315,7 @@ static void python_export_sample_table(struct db_export *dbe,
>  	tuple_set_d64(t, 22, es->sample->insn_cnt);
>  	tuple_set_d64(t, 23, es->sample->cyc_cnt);
>  	tuple_set_s32(t, 24, es->sample->flags);
> +	tuple_set_s32(t, 25, es->sample->ins_lat);
> 
>  	call_object(tables->sample_handler, t, "sample_table");
> 
> --
> 2.25.1
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf script python: Add the ins_lat field to event handler
  2024-08-08 11:12 ` Adrian Hunter
@ 2024-08-08 13:28   ` Zixian Cai
  0 siblings, 0 replies; 3+ messages in thread
From: Zixian Cai @ 2024-08-08 13:28 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, linux-perf-users, linux-kernel

On 8/8/2024 21:12, Adrian Hunter wrote:

> Patch does not apply.
>
> Needs to be based on upstream kernel.  Latest perf tools kernel
> tree and branch is:
>
> 	git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git	perf-tools-next
>

Sorry for the mistake. I cloned the default master branch, and generated a patch on top of it.
Will send in a V2.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-08 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-08  8:00 [PATCH] perf script python: Add the ins_lat field to event handler Zixian Cai
2024-08-08 11:12 ` Adrian Hunter
2024-08-08 13:28   ` Zixian Cai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®