From: Ben Gainey <Ben.Gainey@arm.com>
To: "linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-perf-users@vger.kernel.org"
<linux-perf-users@vger.kernel.org>
Cc: "alexander.shishkin@linux.intel.com"
<alexander.shishkin@linux.intel.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"acme@kernel.org" <acme@kernel.org>,
"mingo@redhat.com" <mingo@redhat.com>,
Mark Rutland <Mark.Rutland@arm.com>,
"will@kernel.org" <will@kernel.org>,
"irogers@google.com" <irogers@google.com>,
"jolsa@kernel.org" <jolsa@kernel.org>,
"namhyung@kernel.org" <namhyung@kernel.org>
Subject: Re: [PATCH 1/1] tools: perf: Expose sample ID / stream ID to python scripts
Date: Tue, 23 Jan 2024 11:24:04 +0000 [thread overview]
Message-ID: <5c04369faf89ce1d1e3deb497199f8b1014cfd81.camel@arm.com> (raw)
In-Reply-To: <8568a3c6-00c9-4801-b710-e70cc06e021b@intel.com>
On Tue, 2024-01-23 at 13:04 +0200, Adrian Hunter wrote:
> On 23/01/24 12:31, Ben Gainey wrote:
> > perf script exposes the evsel_name to python scripts as part of the
> > data
> > passed to the sample or tracepoint handler function, and it passes
> > the id and
> > stream_id to the throttled/unthrottled handler functions. This
> > makes matching
> > throttle events and samples difficult.
> >
> > To make this possible, this change exposes the sample id and
> > stream_id values
> > to the script.
> >
> > Signed-off-by: Ben Gainey <ben.gainey@arm.com>
> > ---
> > tools/perf/Documentation/perf-script-python.txt | 4 ++--
> > tools/perf/util/scripting-engines/trace-event-python.c | 8
> > +++++++-
> > 2 files changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/Documentation/perf-script-python.txt
> > b/tools/perf/Documentation/perf-script-python.txt
> > index 6a8581012e162..13e37e9385ee4 100644
> > --- a/tools/perf/Documentation/perf-script-python.txt
> > +++ b/tools/perf/Documentation/perf-script-python.txt
> > @@ -642,8 +642,8 @@ SUPPORTED FIELDS
> >
> > Currently supported fields:
> >
> > -ev_name, comm, pid, tid, cpu, ip, time, period, phys_addr, addr,
> > -symbol, symoff, dso, time_enabled, time_running, values,
> > callchain,
> > +ev_name, comm, id, stream_id, pid, tid, cpu, ip, time, period,
> > phys_addr,
> > +addr, symbol, symoff, dso, time_enabled, time_running, values,
> > callchain,
> > brstack, brstacksym, datasrc, datasrc_decode, iregs, uregs,
> > weight, transaction, raw_buf, attr, cpumode.
> >
> > diff --git a/tools/perf/util/scripting-engines/trace-event-python.c
> > b/tools/perf/util/scripting-engines/trace-event-python.c
> > index 860e1837ba969..d88966645b2f4 100644
> > --- a/tools/perf/util/scripting-engines/trace-event-python.c
> > +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> > @@ -858,6 +858,10 @@ static PyObject *get_perf_sample_dict(struct
> > perf_sample *sample,
> > pydict_set_item_string_decref(dict, "ev_name",
> > _PyUnicode_FromString(evsel__name(evsel)));
> > pydict_set_item_string_decref(dict, "attr",
> > _PyBytes_FromStringAndSize((const char *)&evsel->core.attr,
> > sizeof(evsel->core.attr)));
> >
> > + pydict_set_item_string_decref(dict_sample, "id",
> > + PyLong_FromUnsignedLongLong(sample->id));
> > + pydict_set_item_string_decref(dict_sample, "stream_id",
> > + PyLong_FromUnsignedLongLong(sample-
> > >stream_id));
> > pydict_set_item_string_decref(dict_sample, "pid",
> > _PyLong_FromLong(sample->pid));
> > pydict_set_item_string_decref(dict_sample, "tid",
> > @@ -1306,7 +1310,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(27);
> >
> > tuple_set_d64(t, 0, es->db_id);
> > tuple_set_d64(t, 1, es->evsel->db_id);
> > @@ -1333,6 +1337,8 @@ 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_d64(t, 25, es->sample->id);
> > + tuple_set_d64(t, 26, es->sample->stream_id);
>
> Unless you actually plan to use the db_export interface with
> these, there is no need to add them at this time.
>
For the particular script I was using the db export interface.
> >
> > call_object(tables->sample_handler, t, "sample_table");
> >
>
next prev parent reply other threads:[~2024-01-23 11:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 10:31 [PATCH 0/1] " Ben Gainey
2024-01-23 10:31 ` [PATCH 1/1] " Ben Gainey
2024-01-23 11:04 ` Adrian Hunter
2024-01-23 11:24 ` Ben Gainey [this message]
2024-02-02 17:05 ` Adrian Hunter
2024-01-23 11:32 ` [PATCH 0/1] " Adrian Hunter
2024-02-03 1:54 ` Namhyung Kim
2024-02-06 0:19 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5c04369faf89ce1d1e3deb497199f8b1014cfd81.camel@arm.com \
--to=ben.gainey@arm.com \
--cc=Mark.Rutland@arm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®