From: Andi Kleen <andi@firstfloor.org>
To: acme@kernel.org
Cc: jolsa@kernel.org, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH v5 05/15] perf tools report: Parse time quantum
Date: Fri, 8 Mar 2019 21:56:18 -0800 [thread overview]
Message-ID: <20190309055628.21617-6-andi@firstfloor.org> (raw)
In-Reply-To: <20190309055628.21617-1-andi@firstfloor.org>
From: Andi Kleen <ak@linux.intel.com>
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 <ak@linux.intel.com>
---
v2:
Move time_quantum to symbol_conf. check for zero time quantum
v3:
Document s unit
v4:
Use _NSEC defines
---
tools/perf/Documentation/perf-report.txt | 4 +++
tools/perf/builtin-report.c | 42 ++++++++++++++++++++++++
tools/perf/util/symbol.c | 2 ++
tools/perf/util/symbol_conf.h | 1 +
4 files changed, 49 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..46bd80363c90 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -47,9 +47,11 @@
#include <errno.h>
#include <inttypes.h>
#include <regex.h>
+#include "sane_ctype.h"
#include <signal.h>
#include <linux/bitmap.h>
#include <linux/stringify.h>
+#include <linux/time64.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -926,6 +928,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 *= NSEC_PER_SEC;
+ return 0;
+ }
+ if (!strcmp(end, "ms")) {
+ *time_q *= NSEC_PER_MSEC;
+ return 0;
+ }
+ if (!strcmp(end, "us")) {
+ *time_q *= NSEC_PER_USEC;
+ 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 +1187,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..913d24340d6b 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -29,6 +29,7 @@
#include <elf.h>
#include <limits.h>
#include <symbol/kallsyms.h>
+#include <linux/time64.h>
#include <sys/utsname.h>
static int dso__load_kernel_sym(struct dso *dso, struct map *map);
@@ -45,6 +46,7 @@ struct symbol_conf symbol_conf = {
.demangle = true,
.demangle_kernel = false,
.cumulate_callchain = true,
+ .time_quantum = 100 * NSEC_PER_MSEC, /* 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
next prev parent reply other threads:[~2019-03-09 5:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-09 5:56 Support sample context in perf report Andi Kleen
2019-03-09 5:56 ` [PATCH v5 01/15] perf tools: Add utility function to fetch executable Andi Kleen
2019-03-11 12:32 ` Jiri Olsa
2019-03-09 5:56 ` [PATCH v5 02/15] perf tools script: Support insn output for normal samples Andi Kleen
2019-03-09 5:56 ` [PATCH v5 03/15] perf tools script: Filter COMM/FORK/.. events by CPU Andi Kleen
2019-03-11 12:32 ` Jiri Olsa
2019-03-09 5:56 ` [PATCH v5 04/15] perf tools report: Support nano seconds Andi Kleen
2019-03-09 5:56 ` Andi Kleen [this message]
2019-03-09 5:56 ` [PATCH v5 06/15] perf tools report: Support time sort key Andi Kleen
2019-03-09 5:56 ` [PATCH v5 07/15] perf tools report: Use less for scripts output Andi Kleen
2019-03-22 22:07 ` [tip:perf/urgent] perf " tip-bot for Andi Kleen
2019-03-09 5:56 ` [PATCH v5 08/15] perf tools report: Support running scripts for current time range Andi Kleen
2019-03-09 5:56 ` [PATCH v5 09/15] perf tools report: Support builtin perf script in scripts menu Andi Kleen
2019-03-09 5:56 ` [PATCH v5 10/15] perf tools: Add utility function to print ns time stamps Andi Kleen
2019-03-09 5:56 ` [PATCH v5 11/15] perf tools report: Implement browsing of individual samples Andi Kleen
2019-03-11 12:32 ` Jiri Olsa
2019-03-09 5:56 ` [PATCH v5 12/15] perf tools: Add some new tips describing the new options Andi Kleen
2019-03-09 5:56 ` [PATCH v5 13/15] perf tools report: Add custom scripts to script menu Andi Kleen
2019-03-09 5:56 ` [PATCH v5 14/15] perf tools script: Add array bound checking to list_scripts Andi Kleen
2019-03-09 5:56 ` [PATCH v5 15/15] perf tools ui: Fix ui popup browser for many entries Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190309055628.21617-6-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.