mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Phlipot <cphlipot0@gmail.com>
To: acme@kernel.org, adrian.hunter@intel.com, mingo@redhat.com,
	peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, Chris Phlipot <cphlipot0@gmail.com>
Subject: [PATCH 4/5] perf script: add option to control callchain export from python
Date: Tue, 19 Apr 2016 01:56:03 -0700	[thread overview]
Message-ID: <1461056164-14914-4-git-send-email-cphlipot0@gmail.com> (raw)
In-Reply-To: <1461056164-14914-1-git-send-email-cphlipot0@gmail.com>

resolving the callchain for every sample can be very expensive.

This commit introduces a new option "perf_db_export_callchains"
which will be enabled when it is set to True from within the python
script.

Signed-off-by: Chris Phlipot <cphlipot0@gmail.com>
---
 tools/perf/util/db-export.c                        |  2 +-
 tools/perf/util/db-export.h                        |  1 +
 .../util/scripting-engines/trace-event-python.c    | 22 +++++++++++++++++++++-
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index 69c9a9d..3bd8247 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -330,7 +330,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
 		goto out_put;
 
 	dbe->call_path_last_seen_db_id = 0;
-	if(dbe->crp) {
+	if(dbe->crp && dbe->export_callchains) {
 		thread_stack__process_callchain(thread, comm, evsel,
 						al->machine, sample,
 						PERF_MAX_STACK_DEPTH, dbe->crp);
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index 40e3b07..b75fea9 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -77,6 +77,7 @@ struct db_export {
 	u64 call_path_last_seen_db_id; /* last db_id seen(exported or not) */
 	u64 call_return_last_db_id;
 	struct list_head deferred;
+	bool export_callchains;
 };
 
 int db_export__init(struct db_export *dbe);
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index ca3f9c6..2e67b35 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -1008,8 +1008,10 @@ error:
 static void set_table_handlers(struct tables *tables)
 {
 	const char *perf_db_export_mode = "perf_db_export_mode";
+	const char *perf_db_export_callchains = "perf_db_export_callchains";
 	const char *perf_db_export_calls = "perf_db_export_calls";
-	PyObject *db_export_mode, *db_export_calls;
+	PyObject *db_export_mode, *db_export_callchains, *db_export_calls;
+	bool export_callchains = false;
 	bool export_calls = false;
 	int ret;
 
@@ -1028,6 +1030,16 @@ static void set_table_handlers(struct tables *tables)
 		return;
 
 	tables->dbe.crp = NULL;
+
+	db_export_callchains = PyDict_GetItemString(main_dict,
+						    perf_db_export_callchains);
+	if (db_export_callchains) {
+		ret = PyObject_IsTrue(db_export_callchains);
+		if (ret == -1)
+			handler_call_die(perf_db_export_callchains);
+		export_callchains = !!ret;
+	}
+
 	db_export_calls = PyDict_GetItemString(main_dict, perf_db_export_calls);
 	if (db_export_calls) {
 		ret = PyObject_IsTrue(db_export_calls);
@@ -1043,9 +1055,17 @@ static void set_table_handlers(struct tables *tables)
 						   &tables->dbe);
 		if (!tables->dbe.crp)
 			Py_FatalError("failed to create calls processor");
+	} else if (export_callchains) {
+		tables->dbe.crp =
+			call_return_processor__new(python_process_call_path,
+						   NULL,
+						   &tables->dbe);
+		if (!tables->dbe.crp)
+			Py_FatalError("failed to create calls processor");
 	}
 
 	tables->db_export_mode = true;
+	tables->dbe.export_callchains = export_callchains;
 	/*
 	 * Reserve per symbol space for symbol->db_id via symbol__priv()
 	 */
-- 
2.7.4

  parent reply	other threads:[~2016-04-19  8:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-19  8:56 [PATCH 1/5] perf tools: fix incorrect ordering of callchain entries Chris Phlipot
2016-04-19  8:56 ` [PATCH 2/5] perf script: extend db-export api to include callchains for samples Chris Phlipot
2016-04-22  7:56   ` Adrian Hunter
2016-04-23  4:41     ` Chris Phlipot
2016-04-28  8:36       ` Chris Phlipot
2016-04-19  8:56 ` [PATCH 3/5] perf script: fix postgresql ubuntu install instructions Chris Phlipot
2016-04-19 13:41   ` Arnaldo Carvalho de Melo
2016-04-23 13:03   ` [tip:perf/core] perf script: Fix " tip-bot for Chris Phlipot
2016-04-19  8:56 ` Chris Phlipot [this message]
2016-04-19  8:56 ` [PATCH 5/5] perf script: Update export-to-postgresql to support callchains Chris Phlipot
2016-04-22  7:55 ` [PATCH 1/5] perf tools: fix incorrect ordering of callchain entries Adrian Hunter
2016-04-22  7:59   ` Adrian Hunter
2016-04-23  3:35     ` Chris Phlipot

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=1461056164-14914-4-git-send-email-cphlipot0@gmail.com \
    --to=cphlipot0@gmail.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.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

Powered by JetHome