Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935094AbbLRJPA (ORCPT ); Fri, 18 Dec 2015 04:15:00 -0500 Received: from terminus.zytor.com ([198.137.202.10]:52551 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934673AbbLRJMX (ORCPT ); Fri, 18 Dec 2015 04:12:23 -0500 Date: Fri, 18 Dec 2015 01:12:07 -0800 From: tip-bot for Jiri Olsa Message-ID: Cc: a.p.zijlstra@chello.nl, jolsa@kernel.org, acme@redhat.com, kan.liang@intel.com, tglx@linutronix.de, namhyung@kernel.org, linux-kernel@vger.kernel.org, mingo@kernel.org, dsahern@gmail.com, hpa@zytor.com Reply-To: namhyung@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com, mingo@kernel.org, dsahern@gmail.com, jolsa@kernel.org, acme@redhat.com, a.p.zijlstra@chello.nl, kan.liang@intel.com In-Reply-To: <1446734469-11352-13-git-send-email-jolsa@kernel.org> References: <1446734469-11352-13-git-send-email-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf stat report: Process cpu/threads maps Git-Commit-ID: 1975d36e14b3314d1d0c7a428946ec0c27fd6e95 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3814 Lines: 128 Commit-ID: 1975d36e14b3314d1d0c7a428946ec0c27fd6e95 Gitweb: http://git.kernel.org/tip/1975d36e14b3314d1d0c7a428946ec0c27fd6e95 Author: Jiri Olsa AuthorDate: Thu, 5 Nov 2015 15:40:56 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 17 Dec 2015 16:21:03 -0300 perf stat report: Process cpu/threads maps Adding processing of cpu/threads maps. Configuring session's evlist with these maps. Reported-by: Kan Liang Signed-off-by: Jiri Olsa Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1446734469-11352-13-git-send-email-jolsa@kernel.org [ s/stat/st/g, s/time/tm/g parameters to fix 'already defined' build error with older distros (e.g. RHEL6.7) ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 66 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index abba49b..0a1cfdd 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; @@ -234,9 +237,9 @@ static int process_synthesized_event(struct perf_tool *tool __maybe_unused, return 0; } -static int write_stat_round_event(u64 time, u64 type) +static int write_stat_round_event(u64 tm, u64 type) { - return perf_event__synthesize_stat_round(NULL, time, type, + return perf_event__synthesize_stat_round(NULL, tm, type, process_synthesized_event, NULL); } @@ -1530,6 +1533,63 @@ static int __cmd_record(int argc, const char **argv) return argc; } +static int set_maps(struct perf_stat *st) +{ + if (!st->cpus || !st->threads) + return 0; + + if (WARN_ONCE(st->maps_allocated, "stats double allocation\n")) + return -EINVAL; + + perf_evlist__set_maps(evsel_list, st->cpus, st->threads); + + if (perf_evlist__alloc_stats(evsel_list, true)) + return -ENOMEM; + + st->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 *st = container_of(tool, struct perf_stat, tool); + + if (st->threads) { + pr_warning("Extra thread map event, ignoring.\n"); + return 0; + } + + st->threads = thread_map__new_event(&event->thread_map); + if (!st->threads) + return -ENOMEM; + + return set_maps(st); +} + +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 *st = container_of(tool, struct perf_stat, tool); + struct cpu_map *cpus; + + if (st->cpus) { + pr_warning("Extra cpu map event, ignoring.\n"); + return 0; + } + + cpus = cpu_map__new_data(&event->cpu_map.data); + if (!cpus) + return -ENOMEM; + + st->cpus = cpus; + return set_maps(st); +} + static const char * const report_usage[] = { "perf stat report []", NULL, @@ -1538,6 +1598,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, }, }; -- 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/