[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1431909055-21442-38-git-send-email-namhyung@kernel.org>
Date: Mon, 18 May 2015 09:30:52 +0900
From: Namhyung Kim <namhyung@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Jiri Olsa <jolsa@...hat.com>,
LKML <linux-kernel@...r.kernel.org>,
David Ahern <dsahern@...il.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Andi Kleen <andi@...stfloor.org>,
Frederic Weisbecker <fweisbec@...il.com>,
Stephane Eranian <eranian@...gle.com>
Subject: [PATCH 37/40] perf report: Add --multi-thread option and config item
The --multi-thread option is to enable parallel processing so user can
force serial processing even for indexed data file. It default to false
for now but users also can changes this by setting "report.multi_thread"
config option in ~/.perfconfig file.
Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
tools/perf/Documentation/perf-report.txt | 2 +
tools/perf/builtin-report.c | 66 +++++++++++++++++++++++++++-----
2 files changed, 59 insertions(+), 9 deletions(-)
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index c33b69f3374f..3917710e2620 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -353,6 +353,8 @@ OPTIONS
To disable decoding entirely, use --no-itrace.
+--multi-thread::
+ Speed up report by parallelizing sample processing using multi-thread.
include::callchain-overhead-calculation.txt[]
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 650d78ad3357..4d08e5f0a7bb 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -53,6 +53,7 @@ struct report {
bool mem_mode;
bool header;
bool header_only;
+ bool multi_thread;
int max_stack;
struct perf_read_values show_threads_values;
const char *pretty_printing_style;
@@ -84,6 +85,10 @@ static int report__config(const char *var, const char *value, void *cb)
rep->queue_size = perf_config_u64(var, value);
return 0;
}
+ if (!strcmp(var, "report.multi-thread")) {
+ rep->multi_thread = perf_config_bool(var, value);
+ return 0;
+ }
return perf_default_config(var, value, cb);
}
@@ -130,17 +135,18 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
return err;
}
-static int process_sample_event(struct perf_tool *tool,
- union perf_event *event,
- struct perf_sample *sample,
- struct perf_evsel *evsel,
- struct machine *machine)
+static int __process_sample_event(struct perf_tool *tool __maybe_unused,
+ union perf_event *event,
+ struct perf_sample *sample,
+ struct perf_evsel *evsel,
+ struct machine *machine,
+ struct hists *hists,
+ struct report *rep)
{
- struct report *rep = container_of(tool, struct report, tool);
struct addr_location al;
struct hist_entry_iter iter = {
.evsel = evsel,
- .hists = evsel__hists(evsel),
+ .hists = hists,
.sample = sample,
.hide_unresolved = rep->hide_unresolved,
.add_entry_cb = hist_iter__report_callback,
@@ -179,6 +185,31 @@ static int process_sample_event(struct perf_tool *tool,
return ret;
}
+static int process_sample_event(struct perf_tool *tool,
+ union perf_event *event,
+ struct perf_sample *sample,
+ struct perf_evsel *evsel,
+ struct machine *machine)
+{
+ struct report *rep = container_of(tool, struct report, tool);
+
+ return __process_sample_event(tool, event, sample, evsel, machine,
+ evsel__hists(evsel), rep);
+}
+
+static int process_sample_event_mt(struct perf_tool *tool,
+ union perf_event *event,
+ struct perf_sample *sample,
+ struct perf_evsel *evsel,
+ struct machine *machine)
+{
+ struct perf_tool_mt *mt = container_of(tool, struct perf_tool_mt, tool);
+ struct report *rep = mt->priv;
+
+ return __process_sample_event(tool, event, sample, evsel, machine,
+ &mt->hists[evsel->idx], rep);
+}
+
static int process_read_event(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample __maybe_unused,
@@ -489,7 +520,12 @@ static int __cmd_report(struct report *rep)
if (ret)
return ret;
- ret = perf_session__process_events(session);
+ if (rep->multi_thread) {
+ rep->tool.sample = process_sample_event_mt;
+ ret = perf_session__process_events_mt(session, rep);
+ } else {
+ ret = perf_session__process_events(session);
+ }
if (ret)
return ret;
@@ -512,7 +548,12 @@ static int __cmd_report(struct report *rep)
}
}
- report__collapse_hists(rep);
+ /*
+ * For multi-thread report, it already calls hists__mt_resort()
+ * so no need to collapse here.
+ */
+ if (!rep->multi_thread)
+ report__collapse_hists(rep);
if (session_done())
return 0;
@@ -731,6 +772,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
"Instruction Tracing options",
itrace_parse_synth_opts),
+ OPT_BOOLEAN(0, "multi-thread", &report.multi_thread,
+ "Speed up sample processing using multi-thead"),
OPT_END()
};
struct perf_data_file file = {
@@ -777,6 +820,11 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
session->itrace_synth_opts = &itrace_synth_opts;
+ if (report.multi_thread && !perf_has_index) {
+ pr_debug("fallback to single thread for normal data file.\n");
+ report.multi_thread = false;
+ }
+
report.session = session;
has_br_stack = perf_header__has_feat(&session->header,
--
2.4.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists