mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] perf script python: Add the ins_lat field to event handler
@ 2024-08-08 13:32 Zixian Cai
  2024-08-08 15:50 ` Adrian Hunter
  0 siblings, 1 reply; 4+ messages in thread
From: Zixian Cai @ 2024-08-08 13:32 UTC (permalink / raw)
  Cc: Zixian Cai, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter, Liang,
	Kan, James Clark, Paran Lee, Ben Gainey, 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>
---
v2) rebase on top of perf-tools-next

 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 fb00f3ad6815..c9e8dbd6feb5 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -888,6 +888,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);
@@ -1317,7 +1319,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(27);
+	t = tuple_new(28);

 	tuple_set_d64(t, 0, es->db_id);
 	tuple_set_d64(t, 1, es->evsel->db_id);
@@ -1346,6 +1348,7 @@ static void python_export_sample_table(struct db_export *dbe,
 	tuple_set_s32(t, 24, es->sample->flags);
 	tuple_set_d64(t, 25, es->sample->id);
 	tuple_set_d64(t, 26, es->sample->stream_id);
+	tuple_set_s32(t, 27, es->sample->ins_lat);

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

--
2.25.1


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

* Re: [PATCH v2] perf script python: Add the ins_lat field to event handler
  2024-08-08 13:32 [PATCH v2] perf script python: Add the ins_lat field to event handler Zixian Cai
@ 2024-08-08 15:50 ` Adrian Hunter
  2024-08-08 20:32   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 4+ messages in thread
From: Adrian Hunter @ 2024-08-08 15:50 UTC (permalink / raw)
  To: Zixian Cai
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Liang, Kan, James Clark, Paran Lee, Ben Gainey,
	linux-perf-users, linux-kernel

On 8/08/24 16:32, 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.
> 
> Signed-off-by: Zixian Cai <fzczx123@gmail.com>

Minor comments, otherwise:

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> v2) rebase on top of perf-tools-next
> 
>  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 fb00f3ad6815..c9e8dbd6feb5 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -888,6 +888,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));

ins_lat is u16 so it could be PyLong_FromUnsignedLong()

>  	pydict_set_item_string_decref(dict_sample, "transaction",
>  			PyLong_FromUnsignedLongLong(sample->transaction));
>  	set_sample_datasrc_in_dict(dict_sample, sample);
> @@ -1317,7 +1319,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(27);
> +	t = tuple_new(28);
> 
>  	tuple_set_d64(t, 0, es->db_id);
>  	tuple_set_d64(t, 1, es->evsel->db_id);
> @@ -1346,6 +1348,7 @@ static void python_export_sample_table(struct db_export *dbe,
>  	tuple_set_s32(t, 24, es->sample->flags);
>  	tuple_set_d64(t, 25, es->sample->id);
>  	tuple_set_d64(t, 26, es->sample->stream_id);
> +	tuple_set_s32(t, 27, es->sample->ins_lat);

ins_lat is u16 so it could be tuple_set_u32()

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


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

* Re: [PATCH v2] perf script python: Add the ins_lat field to event handler
  2024-08-08 15:50 ` Adrian Hunter
@ 2024-08-08 20:32   ` Arnaldo Carvalho de Melo
  2024-08-09  2:15     ` Zixian Cai
  0 siblings, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-08-08 20:32 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Zixian Cai, Peter Zijlstra, Ingo Molnar, Namhyung Kim,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers, Liang,
	Kan, James Clark, Paran Lee, Ben Gainey, linux-perf-users,
	linux-kernel

On Thu, Aug 08, 2024 at 06:50:16PM +0300, Adrian Hunter wrote:
> On 8/08/24 16:32, 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.
> > 
> > Signed-off-by: Zixian Cai <fzczx123@gmail.com>
> 
> Minor comments, otherwise:
> 
> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

Thanks, I'm then waiting for a v3 with those comments addressed and your
Reviewed-by tag collected,

Thanks,

- Arnaldo
 
> > ---
> > v2) rebase on top of perf-tools-next
> > 
> >  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 fb00f3ad6815..c9e8dbd6feb5 100644
> > --- a/tools/perf/util/scripting-engines/trace-event-python.c
> > +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> > @@ -888,6 +888,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));
> 
> ins_lat is u16 so it could be PyLong_FromUnsignedLong()
> 
> >  	pydict_set_item_string_decref(dict_sample, "transaction",
> >  			PyLong_FromUnsignedLongLong(sample->transaction));
> >  	set_sample_datasrc_in_dict(dict_sample, sample);
> > @@ -1317,7 +1319,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(27);
> > +	t = tuple_new(28);
> > 
> >  	tuple_set_d64(t, 0, es->db_id);
> >  	tuple_set_d64(t, 1, es->evsel->db_id);
> > @@ -1346,6 +1348,7 @@ static void python_export_sample_table(struct db_export *dbe,
> >  	tuple_set_s32(t, 24, es->sample->flags);
> >  	tuple_set_d64(t, 25, es->sample->id);
> >  	tuple_set_d64(t, 26, es->sample->stream_id);
> > +	tuple_set_s32(t, 27, es->sample->ins_lat);
> 
> ins_lat is u16 so it could be tuple_set_u32()
> 
> > 
> >  	call_object(tables->sample_handler, t, "sample_table");
> > 
> > --
> > 2.25.1
> > 

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

* Re: [PATCH v2] perf script python: Add the ins_lat field to event handler
  2024-08-08 20:32   ` Arnaldo Carvalho de Melo
@ 2024-08-09  2:15     ` Zixian Cai
  0 siblings, 0 replies; 4+ messages in thread
From: Zixian Cai @ 2024-08-09  2:15 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Adrian Hunter
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Liang, Kan,
	James Clark, Paran Lee, Ben Gainey, linux-perf-users,
	linux-kernel

On 9/8/2024 06:32, Arnaldo Carvalho de Melo wrote:
> On Thu, Aug 08, 2024 at 06:50:16PM +0300, Adrian Hunter wrote:
>>
>> Minor comments, otherwise:
>>
>> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
> 
> Thanks, I'm then waiting for a v3 with those comments addressed and your
> Reviewed-by tag collected,
> 
> Thanks,
> 
> - Arnaldo

v3 submitted with the comments addressed.

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

end of thread, other threads:[~2024-08-09  2:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-08 13:32 [PATCH v2] perf script python: Add the ins_lat field to event handler Zixian Cai
2024-08-08 15:50 ` Adrian Hunter
2024-08-08 20:32   ` Arnaldo Carvalho de Melo
2024-08-09  2:15     ` 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®