From: tip-bot for Joseph Schuchart <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, paulus@samba.org,
mingo@redhat.com, hpa@zytor.com, mingo@kernel.org,
a.p.zijlstra@chello.nl, namhyung@gmail.com, jolsa@redhat.com,
thomas.ilsche@tu-dresden.de, joseph.schuchart@tu-dresden.de,
tglx@linutronix.de
Subject: [tip:perf/core] perf script: Provide additional sample information on generic events
Date: Thu, 17 Jul 2014 21:23:02 -0700 [thread overview]
Message-ID: <tip-57608cfd8827a74237d264a197722e2c99f72da4@git.kernel.org> (raw)
In-Reply-To: <53BE7E20.8080500@tu-dresden.de>
Commit-ID: 57608cfd8827a74237d264a197722e2c99f72da4
Gitweb: http://git.kernel.org/tip/57608cfd8827a74237d264a197722e2c99f72da4
Author: Joseph Schuchart <joseph.schuchart@tu-dresden.de>
AuthorDate: Thu, 10 Jul 2014 13:50:56 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 16 Jul 2014 17:57:33 -0300
perf script: Provide additional sample information on generic events
To python scripts, including pid, tid, and cpu for which the event was
recorded.
At the moment, the pointer to the sample struct is passed to scripts,
which seems to be of little use.
The patch puts this information in dictionaries for easy access by
Python scripts.
Signed-off-by: Joseph Schuchart <joseph.schuchart@tu-dresden.de>
Acked-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Ilsche <thomas.ilsche@tu-dresden.de>
Link: http://lkml.kernel.org/r/53BE7E20.8080500@tu-dresden.de
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
.../util/scripting-engines/trace-event-python.c | 23 +++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index cf65404..b366b48 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -473,7 +473,7 @@ static void python_process_general_event(struct perf_sample *sample,
struct thread *thread,
struct addr_location *al)
{
- PyObject *handler, *retval, *t, *dict, *callchain;
+ PyObject *handler, *retval, *t, *dict, *callchain, *dict_sample;
static char handler_name[64];
unsigned n = 0;
@@ -489,6 +489,10 @@ static void python_process_general_event(struct perf_sample *sample,
if (!dict)
Py_FatalError("couldn't create Python dictionary");
+ dict_sample = PyDict_New();
+ if (!dict_sample)
+ Py_FatalError("couldn't create Python dictionary");
+
snprintf(handler_name, sizeof(handler_name), "%s", "process_event");
handler = PyDict_GetItemString(main_dict, handler_name);
@@ -498,8 +502,21 @@ static void python_process_general_event(struct perf_sample *sample,
pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel)));
pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize(
(const char *)&evsel->attr, sizeof(evsel->attr)));
- pydict_set_item_string_decref(dict, "sample", PyString_FromStringAndSize(
- (const char *)sample, sizeof(*sample)));
+
+ pydict_set_item_string_decref(dict_sample, "pid",
+ PyInt_FromLong(sample->pid));
+ pydict_set_item_string_decref(dict_sample, "tid",
+ PyInt_FromLong(sample->tid));
+ pydict_set_item_string_decref(dict_sample, "cpu",
+ PyInt_FromLong(sample->cpu));
+ pydict_set_item_string_decref(dict_sample, "ip",
+ PyLong_FromUnsignedLongLong(sample->ip));
+ pydict_set_item_string_decref(dict_sample, "time",
+ PyLong_FromUnsignedLongLong(sample->time));
+ pydict_set_item_string_decref(dict_sample, "period",
+ PyLong_FromUnsignedLongLong(sample->period));
+ pydict_set_item_string_decref(dict, "sample", dict_sample);
+
pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize(
(const char *)sample->raw_data, sample->raw_size));
pydict_set_item_string_decref(dict, "comm",
next prev parent reply other threads:[~2014-07-18 4:23 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-18 8:43 [PATCH] Provide additional sample information to Python scripts Joseph Schuchart
2014-03-07 14:18 ` Arnaldo Carvalho de Melo
2014-03-12 15:29 ` Thomas Ilsche
2014-03-12 18:39 ` Arnaldo Carvalho de Melo
2014-04-03 8:57 ` Joseph Schuchart
2014-05-29 6:01 ` Namhyung Kim
2014-06-04 12:07 ` Joseph Schuchart
2014-06-04 12:07 ` [PATCH 1/3] Add missing calls to Py_DECREF Joseph Schuchart
2014-06-04 14:44 ` Namhyung Kim
2014-06-04 12:07 ` [PATCH 2/3] Add callchain to generic and tracepoint events Joseph Schuchart
2014-06-04 14:46 ` Namhyung Kim
2014-07-07 17:17 ` Jiri Olsa
2014-07-09 7:40 ` [PATCH 1/3] perf script: Add missing calls to Py_DECREF for return values Joseph Schuchart
2014-07-09 8:14 ` Namhyung Kim
2014-07-09 7:40 ` [PATCH 2/3] perf script: Add callchain to generic and tracepoint events Joseph Schuchart
2014-07-09 8:15 ` Namhyung Kim
2014-07-09 11:27 ` Jiri Olsa
2014-07-09 11:43 ` Joseph Schuchart
2014-07-09 11:49 ` Jiri Olsa
2014-07-09 14:16 ` Joseph Schuchart
2014-07-09 14:16 ` [PATCH 1/3] perf script: Add missing calls to Py_DECREF Joseph Schuchart
2014-07-09 19:07 ` Arnaldo Carvalho de Melo
2014-07-18 4:22 ` [tip:perf/core] perf script: Add missing calls to Py_DECREF for return values tip-bot for Joseph Schuchart
2014-07-09 14:16 ` [PATCH 2/3] perf script: Add callchain to generic and tracepoint events Joseph Schuchart
2014-07-09 19:09 ` Arnaldo Carvalho de Melo
2014-07-09 19:12 ` Arnaldo Carvalho de Melo
2014-07-09 19:29 ` Arnaldo Carvalho de Melo
2014-07-10 11:50 ` Joseph Schuchart
2014-07-10 11:50 ` Joseph Schuchart
2014-07-18 4:22 ` [tip:perf/core] " tip-bot for Joseph Schuchart
2014-07-10 11:50 ` [PATCH 3/3] perf script: Provide additional sample information on generic events Joseph Schuchart
2014-07-18 4:23 ` tip-bot for Joseph Schuchart [this message]
2014-07-09 14:16 ` Joseph Schuchart
2014-07-09 7:40 ` Joseph Schuchart
2014-07-09 8:16 ` Namhyung Kim
2014-06-04 12:07 ` [PATCH 3/3] " Joseph Schuchart
2014-06-04 14:55 ` 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=tip-57608cfd8827a74237d264a197722e2c99f72da4@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=joseph.schuchart@tu-dresden.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@gmail.com \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
--cc=thomas.ilsche@tu-dresden.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.