[tip:perf/core] perf top: Allow asking for the maximum allowed sample rate

From: tip-bot for Arnaldo Carvalho de Melo
Date: Tue Mar 06 2018 - 01:45:33 EST


Commit-ID: 7831bf236505bcb2a0a1255e7f3e902a0cb732d6
Gitweb: https://git.kernel.org/tip/7831bf236505bcb2a0a1255e7f3e902a0cb732d6
Author: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
AuthorDate: Thu, 1 Mar 2018 14:25:56 -0300
Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CommitDate: Mon, 5 Mar 2018 09:58:44 -0300

perf top: Allow asking for the maximum allowed sample rate

Add the handy '-F max' shortcut, just introduced to 'perf record', to
reading and using the kernel.perf_event_max_sample_rate value as the
user supplied sampling frequency:

Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Wang Nan <wangnan0@xxxxxxxxxx>
Link: https://lkml.kernel.org/n/tip-hz04f296zccknnb5at06a6q0@xxxxxxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/Documentation/perf-top.txt | 4 +++-
tools/perf/builtin-top.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index 8a32cc77bead..a039407d63b8 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -55,7 +55,9 @@ Default is to monitor all CPUS.

-F <freq>::
--freq=<freq>::
- Profile at this frequency.
+ Profile at this frequency. Use 'max' to use the currently maximum
+ allowed frequency, i.e. the value in the kernel.perf_event_max_sample_rate
+ sysctl.

-i::
--inherit::
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 35ac016fcb98..bb4f9fafd11d 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1307,7 +1307,9 @@ int cmd_top(int argc, const char **argv)
OPT_STRING(0, "sym-annotate", &top.sym_filter, "symbol name",
"symbol to annotate"),
OPT_BOOLEAN('z', "zero", &top.zero, "zero history across updates"),
- OPT_UINTEGER('F', "freq", &opts->user_freq, "profile at this frequency"),
+ OPT_CALLBACK('F', "freq", &top.record_opts, "freq or 'max'",
+ "profile at this frequency",
+ record__parse_freq),
OPT_INTEGER('E', "entries", &top.print_entries,
"display this many functions"),
OPT_BOOLEAN('U', "hide_user_symbols", &top.hide_user_symbols,