public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Adrian Hunter <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, adrian.hunter@intel.com, hpa@zytor.com,
	mingo@kernel.org, linux-kernel@vger.kernel.org, acme@redhat.com,
	jolsa@redhat.com
Subject: [tip:perf/core] perf db-export: Export synth events
Date: Wed, 3 Jul 2019 07:06:59 -0700	[thread overview]
Message-ID: <tip-b9322cab17a1092e2aa7ee2505ecceb0cd5fd685@git.kernel.org> (raw)
In-Reply-To: <20190622093248.581-6-adrian.hunter@intel.com>

Commit-ID:  b9322cab17a1092e2aa7ee2505ecceb0cd5fd685
Gitweb:     https://git.kernel.org/tip/b9322cab17a1092e2aa7ee2505ecceb0cd5fd685
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Sat, 22 Jun 2019 12:32:46 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 25 Jun 2019 08:47:10 -0300

perf db-export: Export synth events

Synthesized events are samples but with architecture-specific data
stored in sample->raw_data. They are identified by attribute type
PERF_TYPE_SYNTH.  Add a function to export them.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190622093248.581-6-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 .../util/scripting-engines/trace-event-python.c    | 46 +++++++++++++++++++++-
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 6acb379b53ec..112bed65232f 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -112,6 +112,7 @@ struct tables {
 	PyObject		*sample_handler;
 	PyObject		*call_path_handler;
 	PyObject		*call_return_handler;
+	PyObject		*synth_handler;
 	bool			db_export_mode;
 };
 
@@ -947,6 +948,12 @@ static int tuple_set_string(PyObject *t, unsigned int pos, const char *s)
 	return PyTuple_SetItem(t, pos, _PyUnicode_FromString(s));
 }
 
+static int tuple_set_bytes(PyObject *t, unsigned int pos, void *bytes,
+			   unsigned int sz)
+{
+	return PyTuple_SetItem(t, pos, _PyBytes_FromStringAndSize(bytes, sz));
+}
+
 static int python_export_evsel(struct db_export *dbe, struct perf_evsel *evsel)
 {
 	struct tables *tables = container_of(dbe, struct tables, dbe);
@@ -1105,8 +1112,8 @@ static int python_export_branch_type(struct db_export *dbe, u32 branch_type,
 	return 0;
 }
 
-static int python_export_sample(struct db_export *dbe,
-				struct export_sample *es)
+static void python_export_sample_table(struct db_export *dbe,
+				       struct export_sample *es)
 {
 	struct tables *tables = container_of(dbe, struct tables, dbe);
 	PyObject *t;
@@ -1141,6 +1148,33 @@ static int python_export_sample(struct db_export *dbe,
 	call_object(tables->sample_handler, t, "sample_table");
 
 	Py_DECREF(t);
+}
+
+static void python_export_synth(struct db_export *dbe, struct export_sample *es)
+{
+	struct tables *tables = container_of(dbe, struct tables, dbe);
+	PyObject *t;
+
+	t = tuple_new(3);
+
+	tuple_set_u64(t, 0, es->db_id);
+	tuple_set_u64(t, 1, es->evsel->attr.config);
+	tuple_set_bytes(t, 2, es->sample->raw_data, es->sample->raw_size);
+
+	call_object(tables->synth_handler, t, "synth_data");
+
+	Py_DECREF(t);
+}
+
+static int python_export_sample(struct db_export *dbe,
+				struct export_sample *es)
+{
+	struct tables *tables = container_of(dbe, struct tables, dbe);
+
+	python_export_sample_table(dbe, es);
+
+	if (es->evsel->attr.type == PERF_TYPE_SYNTH && tables->synth_handler)
+		python_export_synth(dbe, es);
 
 	return 0;
 }
@@ -1477,6 +1511,14 @@ static void set_table_handlers(struct tables *tables)
 	SET_TABLE_HANDLER(sample);
 	SET_TABLE_HANDLER(call_path);
 	SET_TABLE_HANDLER(call_return);
+
+	/*
+	 * Synthesized events are samples but with architecture-specific data
+	 * stored in sample->raw_data. They are exported via
+	 * python_export_sample() and consequently do not need a separate export
+	 * callback.
+	 */
+	tables->synth_handler = get_handler("synth_data");
 }
 
 #if PY_MAJOR_VERSION < 3

  reply	other threads:[~2019-07-03 14:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-22  9:32 [PATCH 0/7] perf intel-pt: CBR improvements Adrian Hunter
2019-06-22  9:32 ` [PATCH 1/7] perf intel-pt: Decoder to output CBR changes immediately Adrian Hunter
2019-07-03 14:04   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-22  9:32 ` [PATCH 2/7] perf intel-pt: Cater for CBR change in PSB+ Adrian Hunter
2019-07-03 14:04   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-22  9:32 ` [PATCH 3/7] perf intel-pt: Add CBR value to decoder state Adrian Hunter
2019-07-03 14:05   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-22  9:32 ` [PATCH 4/7] perf intel-pt: Synthesize CBR events when last seen value changes Adrian Hunter
2019-07-03 14:06   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-22  9:32 ` [PATCH 5/7] perf db-export: Export synth events Adrian Hunter
2019-07-03 14:06   ` tip-bot for Adrian Hunter [this message]
2019-06-22  9:32 ` [PATCH 6/7] perf scripts python: export-to-sqlite.py: Export Intel PT power and ptwrite events Adrian Hunter
2019-07-03 14:07   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-22  9:32 ` [PATCH 7/7] perf scripts python: export-to-postgresql.py: " Adrian Hunter
2019-07-03 14:08   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-24 18:57 ` [PATCH 0/7] perf intel-pt: CBR improvements Arnaldo Carvalho de Melo

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-b9322cab17a1092e2aa7ee2505ecceb0cd5fd685@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox