lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 19 Apr 2016 01:56:03 -0700
From:	Chris Phlipot <cphlipot0@...il.com>
To:	acme@...nel.org, adrian.hunter@...el.com, mingo@...hat.com,
	peterz@...radead.org
Cc:	linux-kernel@...r.kernel.org, Chris Phlipot <cphlipot0@...il.com>
Subject: [PATCH 4/5] perf script: add option to control callchain export from python

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@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ