Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1263301
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 12/25] perf stat report: Process cpu/threads maps |
| Date | 2015-11-05 16:00 +0100 |
| Message-ID | <qrub7-81X-7@gated-at.bofh.it> (permalink) |
| References | <qru1r-7Yg-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Adding processing of cpu/threads maps. Configuring session's
evlist with these maps.
Tested-by: Kan Liang <kan.liang@intel.com>
Link: http://lkml.kernel.org/n/tip-f2bo5wm0cw76zc5qsjm4pztx@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.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 e921ad542846..858c6837a1e3 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -135,6 +135,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;
@@ -1501,6 +1504,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_data(&event->cpu_map.data);
+ if (!cpus)
+ return -ENOMEM;
+
+ stat->cpus = cpus;
+ return set_maps(stat);
+}
+
static const char * const report_usage[] = {
"perf stat report [<options>]",
NULL,
@@ -1509,6 +1569,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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCHv6 00/25] perf stat: Add scripting support Jiri Olsa <jolsa@kernel.org> - 2015-11-05 15:50 +0100
[PATCH 15/25] perf stat report: Process stat and stat round events Jiri Olsa <jolsa@kernel.org> - 2015-11-05 15:50 +0100
[PATCH 14/25] perf stat report: Add support to initialize aggr_map from file Jiri Olsa <jolsa@kernel.org> - 2015-11-05 15:50 +0100
[PATCH 24/25] perf script: Add python support for stat events Jiri Olsa <jolsa@kernel.org> - 2015-11-05 15:50 +0100
[PATCH 11/25] perf stat report: Add report command Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[PATCH 16/25] perf stat report: Process event update events Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[PATCH 08/25] perf stat record: Write stat round events on record Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[PATCH 12/25] perf stat report: Process cpu/threads maps Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[PATCH 20/25] perf script: Process stat config event Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[PATCH 01/25] perf stat: Make stat options global Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[tip:perf/urgent] perf stat: Make stat options global tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-11-08 08:40 +0100
[PATCH 03/25] perf stat record: Initialize record features Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
[PATCH 18/25] perf stat report: Allow to override aggr_mode Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
csiph-web