From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E248DC43381 for ; Tue, 5 Mar 2019 14:48:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B79102087C for ; Tue, 5 Mar 2019 14:48:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbfCEOsQ (ORCPT ); Tue, 5 Mar 2019 09:48:16 -0500 Received: from mga07.intel.com ([134.134.136.100]:28781 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728074AbfCEOsP (ORCPT ); Tue, 5 Mar 2019 09:48:15 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2019 06:48:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,444,1544515200"; d="scan'208";a="121150033" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.137]) by orsmga006.jf.intel.com with ESMTP; 05 Mar 2019 06:48:14 -0800 Received: by tassilo.localdomain (Postfix, from userid 1000) id 672EF301BCA; Tue, 5 Mar 2019 06:48:14 -0800 (PST) From: Andi Kleen To: acme@kernel.org Cc: jolsa@kernel.org, namhyung@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen Subject: [PATCH v4 05/15] perf tools report: Parse time quantum Date: Tue, 5 Mar 2019 06:47:48 -0800 Message-Id: <20190305144758.12397-6-andi@firstfloor.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305144758.12397-1-andi@firstfloor.org> References: <20190305144758.12397-1-andi@firstfloor.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen Many workloads change over time. perf report currently aggregates the whole time range reported in perf.data. This patch adds an option for a time quantum to quantisize the perf.data over time. This just adds the option, will be used in follow on patches for a time sort key. Signed-off-by: Andi Kleen --- v2: Move time_quantum to symbol_conf. check for zero time quantum v3: Document s unit --- tools/perf/Documentation/perf-report.txt | 4 +++ tools/perf/builtin-report.c | 41 ++++++++++++++++++++++++ tools/perf/util/symbol.c | 1 + tools/perf/util/symbol_conf.h | 1 + 4 files changed, 47 insertions(+) diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index 51dbc519dbce..9ec1702bccdd 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -497,6 +497,10 @@ include::itrace.txt[] The period/hits keywords set the base the percentage is computed on - the samples period or the number of samples (hits). +--time-quantum:: + Configure time quantum for time sort key. Default 100ms. + Accepts s, us, ms, ns units. + include::callchain-overhead-calculation.txt[] SEE ALSO diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 09180e559ad6..c19952072a3a 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -47,6 +47,7 @@ #include #include #include +#include "sane_ctype.h" #include #include #include @@ -926,6 +927,43 @@ report_parse_callchain_opt(const struct option *opt, const char *arg, int unset) return parse_callchain_report_opt(arg); } +static int +parse_time_quantum(const struct option *opt, const char *arg, + int unset __maybe_unused) +{ + unsigned long *time_q = opt->value; + char *end; + + *time_q = strtoul(arg, &end, 0); + if (end == arg) + goto parse_err; + if (*time_q == 0) { + pr_err("time quantum cannot be 0"); + return -1; + } + while (isspace(*end)) + end++; + if (*end == 0) + return 0; + if (!strcmp(end, "s")) { + *time_q *= 1000000000; + return 0; + } + if (!strcmp(end, "ms")) { + *time_q *= 1000000; + return 0; + } + if (!strcmp(end, "us")) { + *time_q *= 1000; + return 0; + } + if (!strcmp(end, "ns")) + return 0; +parse_err: + pr_err("Cannot parse time quantum `%s'\n", arg); + return -1; +} + int report_parse_ignore_callees_opt(const struct option *opt __maybe_unused, const char *arg, int unset __maybe_unused) @@ -1148,6 +1186,9 @@ int cmd_report(int argc, const char **argv) "Set percent type local/global-period/hits", annotate_parse_percent_type), OPT_BOOLEAN(0, "ns", &symbol_conf.nanosecs, "Show times in nanosecs"), + OPT_CALLBACK(0, "time-quantum", &symbol_conf.time_quantum, "time (ms|us|ns|s)", + "Set time quantum for time sort key (default 100ms)", + parse_time_quantum), OPT_END() }; struct perf_data data = { diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index eb873ea1c405..0f80743a1c25 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -45,6 +45,7 @@ struct symbol_conf symbol_conf = { .demangle = true, .demangle_kernel = false, .cumulate_callchain = true, + .time_quantum = 100000000, /* 100ms */ .show_hist_headers = true, .symfs = "", .event_group = true, diff --git a/tools/perf/util/symbol_conf.h b/tools/perf/util/symbol_conf.h index 095a297c8b47..a5684a71b78e 100644 --- a/tools/perf/util/symbol_conf.h +++ b/tools/perf/util/symbol_conf.h @@ -56,6 +56,7 @@ struct symbol_conf { *sym_list_str, *col_width_list_str, *bt_stop_list_str; + unsigned long time_quantum; struct strlist *dso_list, *comm_list, *sym_list, -- 2.20.1