perf top: Allow asking for the maximum allowed sample rate
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 1 Mar 2018 17:25:56 +0000 (14:25 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 5 Mar 2018 12:58:44 +0000 (09:58 -0300)
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@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-hz04f296zccknnb5at06a6q0@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-top.txt
tools/perf/builtin-top.c

index 8a32cc77bead37463b8d2517bf3d9a5c42ce8673..a039407d63b80d7dff62c188be47fd607971e2bc 100644 (file)
@@ -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::
index 35ac016fcb988997437230103987aaa59415e70a..bb4f9fafd11d8304491af1fa7effe807428e5111 100644 (file)
@@ -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,