lkml.org 
[lkml]   [2016]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 4/5] perf script: add option to control callchain export from python
Date
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
\
 
 \ /
  Last update: 2016-04-19 11:21    [W:0.108 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site