From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753290AbcDSI5g (ORCPT ); Tue, 19 Apr 2016 04:57:36 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34014 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752991AbcDSI4O (ORCPT ); Tue, 19 Apr 2016 04:56:14 -0400 From: Chris Phlipot To: acme@kernel.org, adrian.hunter@intel.com, mingo@redhat.com, peterz@infradead.org Cc: linux-kernel@vger.kernel.org, Chris Phlipot Subject: [PATCH 4/5] perf script: add option to control callchain export from python Date: Tue, 19 Apr 2016 01:56:03 -0700 Message-Id: <1461056164-14914-4-git-send-email-cphlipot0@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1461056164-14914-1-git-send-email-cphlipot0@gmail.com> References: <1461056164-14914-1-git-send-email-cphlipot0@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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