[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1443622258-17158-33-git-send-email-jolsa@kernel.org>
Date: Wed, 30 Sep 2015 16:10:45 +0200
From: Jiri Olsa <jolsa@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
David Ahern <dsahern@...il.com>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
"Liang, Kan" <kan.liang@...el.com>
Subject: [PATCH 32/45] perf stat report: Process cpu/threads maps
Adding processing of cpu/threads maps. Configuring session's
evlist with these maps.
Link: http://lkml.kernel.org/n/tip-f2bo5wm0cw76zc5qsjm4pztx@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/perf/builtin-stat.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 4861fd639b7e..4ee00803bc96 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -132,6 +132,9 @@ struct perf_stat {
struct perf_session *session;
u64 bytes_written;
struct perf_tool tool;
+ bool maps_allocated;
+ struct cpu_map *cpus;
+ struct thread_map *threads;
};
static struct perf_stat perf_stat;
@@ -1399,6 +1402,63 @@ static int __cmd_record(int argc, const char **argv)
return argc;
}
+static int set_maps(struct perf_stat *stat)
+{
+ if (!stat->cpus || !stat->threads)
+ return 0;
+
+ if (WARN_ONCE(stat->maps_allocated, "stats double allocation\n"))
+ return -EINVAL;
+
+ perf_evlist__set_maps(evsel_list, stat->cpus, stat->threads);
+
+ if (perf_evlist__alloc_stats(evsel_list, true))
+ return -ENOMEM;
+
+ stat->maps_allocated = true;
+ return 0;
+}
+
+static
+int process_thread_map_event(struct perf_tool *tool __maybe_unused,
+ union perf_event *event,
+ struct perf_session *session __maybe_unused)
+{
+ struct perf_stat *stat = container_of(tool, struct perf_stat, tool);
+
+ if (stat->threads) {
+ pr_warning("Extra thread map event, ignoring.\n");
+ return 0;
+ }
+
+ stat->threads = thread_map__new_event(&event->thread_map);
+ if (!stat->threads)
+ return -ENOMEM;
+
+ return set_maps(stat);
+}
+
+static
+int process_cpu_map_event(struct perf_tool *tool __maybe_unused,
+ union perf_event *event,
+ struct perf_session *session __maybe_unused)
+{
+ struct perf_stat *stat = container_of(tool, struct perf_stat, tool);
+ struct cpu_map *cpus;
+
+ if (stat->cpus) {
+ pr_warning("Extra cpu map event, ignoring.\n");
+ return 0;
+ }
+
+ cpus = cpu_map__new_event(&event->cpu_map);
+ if (!cpus)
+ return -ENOMEM;
+
+ stat->cpus = cpus;
+ return set_maps(stat);
+}
+
static const char * const report_usage[] = {
"perf stat report [<options>]",
NULL,
@@ -1407,6 +1467,8 @@ static const char * const report_usage[] = {
static struct perf_stat perf_stat = {
.tool = {
.attr = perf_event__process_attr,
+ .thread_map = process_thread_map_event,
+ .cpu_map = process_cpu_map_event,
},
};
--
2.4.3
--
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