From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754242AbeAGQEc (ORCPT + 1 other); Sun, 7 Jan 2018 11:04:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36064 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754207AbeAGQEa (ORCPT ); Sun, 7 Jan 2018 11:04:30 -0500 From: Jiri Olsa To: Arnaldo Carvalho de Melo , Peter Zijlstra Cc: lkml , Ingo Molnar , Namhyung Kim , David Ahern , Andi Kleen , Alexander Shishkin Subject: [PATCH 11/12] perf report: Add --stat option to display quick data statistics Date: Sun, 7 Jan 2018 17:03:55 +0100 Message-Id: <20180107160356.28203-12-jolsa@kernel.org> In-Reply-To: <20180107160356.28203-1-jolsa@kernel.org> References: <20180107160356.28203-1-jolsa@kernel.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Sun, 07 Jan 2018 16:04:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Adding --stat option to display quick data statistics of event numbers, without any further processing, like the one at the end of the perf report -D command. $ perf report --stat Aggregated stats: TOTAL events: 4566 MMAP events: 113 LOST events: 19 COMM events: 3 FORK events: 400 SAMPLE events: 3315 MMAP2 events: 32 FINISHED_ROUND events: 681 THREAD_MAP events: 1 CPU_MAP events: 1 TIME_CONV events: 1 I found this useful when hunting lost events for another change. Link: http://lkml.kernel.org/n/tip-2guzsg9opn135yj86oothemv@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/Documentation/perf-report.txt | 4 ++++ tools/perf/builtin-report.c | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index ddde2b54af57..b0d70bf4ddfe 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -437,6 +437,10 @@ include::itrace.txt[] will be printed. Each entry is function name or file/line. Enabled by default, disable with --no-inline. +--stat:: + Display overall events statistics without any further processing. + (like the one at the end of the perf report -D command) + include::callchain-overhead-calculation.txt[] SEE ALSO diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 07827cd51480..11d303494b0c 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -60,6 +60,7 @@ struct report { bool show_threads; bool inverted_callchain; bool mem_mode; + bool stat_mode; bool header; bool header_only; bool nonany_branch_mode; @@ -583,6 +584,20 @@ static void report__output_resort(struct report *rep) ui_progress__finish(); } +static void stat_setup(struct report *rep) +{ + memset(&rep->tool, 0, sizeof(rep->tool)); + rep->tool.no_warn = true; +} + +static int stat_print(struct report *rep) +{ + struct perf_session *session = rep->session; + + perf_session__fprintf_nr_events(session, stdout); + return 0; +} + static int __cmd_report(struct report *rep) { int ret; @@ -614,12 +629,18 @@ static int __cmd_report(struct report *rep) return ret; } + if (rep->stat_mode) + stat_setup(rep); + ret = perf_session__process_events(session); if (ret) { ui__error("failed to process sample\n"); return ret; } + if (rep->stat_mode) + return stat_print(rep); + report__warn_kptr_restrict(rep); evlist__for_each_entry(session->evlist, pos) @@ -776,6 +797,7 @@ int cmd_report(int argc, const char **argv) OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"), OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), + OPT_BOOLEAN(0, "stat", &report.stat_mode, "Display event stats"), OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, "file", "vmlinux pathname"), OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, @@ -1037,6 +1059,8 @@ int cmd_report(int argc, const char **argv) report.tool.show_feat_hdr = SHOW_FEAT_HEADER; if (report.show_full_info) report.tool.show_feat_hdr = SHOW_FEAT_HEADER_FULL_INFO; + if (report.stat_mode) + use_browser = 0; if (strcmp(input_name, "-") != 0) setup_browser(true); @@ -1059,7 +1083,7 @@ int cmd_report(int argc, const char **argv) ret = 0; goto error; } - } else if (use_browser == 0 && !quiet) { + } else if (use_browser == 0 && !quiet && !report.stat_mode) { fputs("# To display the perf.data header info, please use --header/--header-only options.\n#\n", stdout); } -- 2.13.6