diff options
author | Namhyung Kim <namhyung@kernel.org> | 2016-01-07 06:41:53 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-01-08 11:15:46 -0500 |
commit | 14cbfbeb76540cc0c53fbb0ba34b3a4900ebe40f (patch) | |
tree | 51bc19a46a576c64d784b6c0713eee59c8f73de3 /tools/perf | |
parent | fc284be9d88528dd2a28d5471e40a6acde6c3036 (diff) |
perf report: Show random usage tip on the help line
Currently perf report only shows a help message "For a higher level
overview, try: perf report --sort comm,dso" unconditionally (even if
the sort keys were used). Add more help tips and show randomly.
Load tips from ${prefix}/share/doc/perf-tip/tips.txt file.
$ perf report | tail
0.10% swapper [kernel.vmlinux] [k] irq_exit
0.09% swapper [kernel.vmlinux] [k] flush_smp_call_function_queue
0.08% swapper [kernel.vmlinux] [k] native_write_msr_safe
0.03% swapper [kernel.vmlinux] [k] group_sched_in
0.01% perf [kernel.vmlinux] [k] native_write_msr_safe
#
# (Tip: Search options using a keyword: perf report -h <keyword>)
#
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1452166913-27046-1-git-send-email-namhyung@kernel.org
[ Renamed it to perf_tip() and the parameter dirname to dirpath to fix the build on older distros ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/Build | 1 | ||||
-rw-r--r-- | tools/perf/Documentation/tips.txt | 14 | ||||
-rw-r--r-- | tools/perf/Makefile.perf | 3 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 2 | ||||
-rw-r--r-- | tools/perf/config/Makefile | 6 | ||||
-rw-r--r-- | tools/perf/perf.c | 4 | ||||
-rw-r--r-- | tools/perf/util/util.c | 27 | ||||
-rw-r--r-- | tools/perf/util/util.h | 2 |
8 files changed, 58 insertions, 1 deletions
diff --git a/tools/perf/Build b/tools/perf/Build index 00c4b8c3d8ca..6b67e6f4179f 100644 --- a/tools/perf/Build +++ b/tools/perf/Build | |||
@@ -41,6 +41,7 @@ CFLAGS_perf.o += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))" \ | |||
41 | -DPREFIX="BUILD_STR($(prefix_SQ))" \ | 41 | -DPREFIX="BUILD_STR($(prefix_SQ))" \ |
42 | -include $(OUTPUT)PERF-VERSION-FILE | 42 | -include $(OUTPUT)PERF-VERSION-FILE |
43 | CFLAGS_builtin-trace.o += -DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))" | 43 | CFLAGS_builtin-trace.o += -DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))" |
44 | CFLAGS_builtin-report.o += -DTIPDIR="BUILD_STR($(tipdir_SQ))" | ||
44 | 45 | ||
45 | libperf-y += util/ | 46 | libperf-y += util/ |
46 | libperf-y += arch/ | 47 | libperf-y += arch/ |
diff --git a/tools/perf/Documentation/tips.txt b/tools/perf/Documentation/tips.txt new file mode 100644 index 000000000000..a1c10e360db5 --- /dev/null +++ b/tools/perf/Documentation/tips.txt | |||
@@ -0,0 +1,14 @@ | |||
1 | For a higher level overview, try: perf report --sort comm,dso | ||
2 | Sample related events with: perf record -e '{cycles,instructions}:S' | ||
3 | Compare performance results with: perf diff [<old file> <new file>] | ||
4 | Boolean options have negative forms, e.g.: perf report --no-children | ||
5 | Customize output of perf script with: perf script -F event,ip,sym | ||
6 | Generate a script for your data: perf script -g <lang> | ||
7 | Save output of perf stat using: perf stat record <target workload> | ||
8 | Create an archive with symtabs to analyse on other machine: perf archive | ||
9 | Search options using a keyword: perf report -h <keyword> | ||
10 | Use parent filter to see specific call path: perf report -p <regex> | ||
11 | List events using substring match: perf list <keyword> | ||
12 | To see list of saved events and attributes: perf evlist -v | ||
13 | Use --symfs <dir> if your symbol files are in non-standard locations | ||
14 | To see callchains in a more compact form: perf report -g folded | ||
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 1025ea79b90b..0a22407e1d7d 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf | |||
@@ -567,6 +567,9 @@ endif | |||
567 | $(call QUIET_INSTALL, perf_completion-script) \ | 567 | $(call QUIET_INSTALL, perf_completion-script) \ |
568 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \ | 568 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \ |
569 | $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf' | 569 | $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf' |
570 | $(call QUIET_INSTALL, perf-tip) \ | ||
571 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \ | ||
572 | $(INSTALL) Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)' | ||
570 | 573 | ||
571 | install-tests: all install-gtk | 574 | install-tests: all install-gtk |
572 | $(call QUIET_INSTALL, tests) \ | 575 | $(call QUIET_INSTALL, tests) \ |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index f10c663af996..d5a42ee12529 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -433,7 +433,7 @@ static int report__browse_hists(struct report *rep) | |||
433 | int ret; | 433 | int ret; |
434 | struct perf_session *session = rep->session; | 434 | struct perf_session *session = rep->session; |
435 | struct perf_evlist *evlist = session->evlist; | 435 | struct perf_evlist *evlist = session->evlist; |
436 | const char *help = "For a higher level overview, try: perf report --sort comm,dso"; | 436 | const char *help = perf_tip(TIPDIR); |
437 | 437 | ||
438 | switch (use_browser) { | 438 | switch (use_browser) { |
439 | case 1: | 439 | case 1: |
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 18b2f96d0941..254d06e39bea 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile | |||
@@ -691,6 +691,7 @@ sharedir = $(prefix)/share | |||
691 | template_dir = share/perf-core/templates | 691 | template_dir = share/perf-core/templates |
692 | STRACE_GROUPS_DIR = share/perf-core/strace/groups | 692 | STRACE_GROUPS_DIR = share/perf-core/strace/groups |
693 | htmldir = share/doc/perf-doc | 693 | htmldir = share/doc/perf-doc |
694 | tipdir = share/doc/perf-tip | ||
694 | ifeq ($(prefix),/usr) | 695 | ifeq ($(prefix),/usr) |
695 | sysconfdir = /etc | 696 | sysconfdir = /etc |
696 | ETC_PERFCONFIG = $(sysconfdir)/perfconfig | 697 | ETC_PERFCONFIG = $(sysconfdir)/perfconfig |
@@ -717,6 +718,7 @@ infodir_SQ = $(subst ','\'',$(infodir)) | |||
717 | perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) | 718 | perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) |
718 | template_dir_SQ = $(subst ','\'',$(template_dir)) | 719 | template_dir_SQ = $(subst ','\'',$(template_dir)) |
719 | htmldir_SQ = $(subst ','\'',$(htmldir)) | 720 | htmldir_SQ = $(subst ','\'',$(htmldir)) |
721 | tipdir_SQ = $(subst ','\'',$(tipdir)) | ||
720 | prefix_SQ = $(subst ','\'',$(prefix)) | 722 | prefix_SQ = $(subst ','\'',$(prefix)) |
721 | sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) | 723 | sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) |
722 | libdir_SQ = $(subst ','\'',$(libdir)) | 724 | libdir_SQ = $(subst ','\'',$(libdir)) |
@@ -724,12 +726,15 @@ libdir_SQ = $(subst ','\'',$(libdir)) | |||
724 | ifneq ($(filter /%,$(firstword $(perfexecdir))),) | 726 | ifneq ($(filter /%,$(firstword $(perfexecdir))),) |
725 | perfexec_instdir = $(perfexecdir) | 727 | perfexec_instdir = $(perfexecdir) |
726 | STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR) | 728 | STRACE_GROUPS_INSTDIR = $(STRACE_GROUPS_DIR) |
729 | tip_instdir = $(tipdir) | ||
727 | else | 730 | else |
728 | perfexec_instdir = $(prefix)/$(perfexecdir) | 731 | perfexec_instdir = $(prefix)/$(perfexecdir) |
729 | STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR) | 732 | STRACE_GROUPS_INSTDIR = $(prefix)/$(STRACE_GROUPS_DIR) |
733 | tip_instdir = $(prefix)/$(tipdir) | ||
730 | endif | 734 | endif |
731 | perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) | 735 | perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) |
732 | STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR)) | 736 | STRACE_GROUPS_INSTDIR_SQ = $(subst ','\'',$(STRACE_GROUPS_INSTDIR)) |
737 | tip_instdir_SQ = $(subst ','\'',$(tip_instdir)) | ||
733 | 738 | ||
734 | # If we install to $(HOME) we keep the traceevent default: | 739 | # If we install to $(HOME) we keep the traceevent default: |
735 | # $(HOME)/.traceevent/plugins | 740 | # $(HOME)/.traceevent/plugins |
@@ -770,6 +775,7 @@ $(call detected_var,ETC_PERFCONFIG_SQ) | |||
770 | $(call detected_var,STRACE_GROUPS_DIR_SQ) | 775 | $(call detected_var,STRACE_GROUPS_DIR_SQ) |
771 | $(call detected_var,prefix_SQ) | 776 | $(call detected_var,prefix_SQ) |
772 | $(call detected_var,perfexecdir_SQ) | 777 | $(call detected_var,perfexecdir_SQ) |
778 | $(call detected_var,tipdir_SQ) | ||
773 | $(call detected_var,LIBDIR) | 779 | $(call detected_var,LIBDIR) |
774 | $(call detected_var,GTK_CFLAGS) | 780 | $(call detected_var,GTK_CFLAGS) |
775 | $(call detected_var,PERL_EMBED_CCOPTS) | 781 | $(call detected_var,PERL_EMBED_CCOPTS) |
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index cb1d2499c45c..a929618b8eb6 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -19,6 +19,8 @@ | |||
19 | #include "util/debug.h" | 19 | #include "util/debug.h" |
20 | #include <api/fs/tracing_path.h> | 20 | #include <api/fs/tracing_path.h> |
21 | #include <pthread.h> | 21 | #include <pthread.h> |
22 | #include <stdlib.h> | ||
23 | #include <time.h> | ||
22 | 24 | ||
23 | const char perf_usage_string[] = | 25 | const char perf_usage_string[] = |
24 | "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]"; | 26 | "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]"; |
@@ -542,6 +544,8 @@ int main(int argc, const char **argv) | |||
542 | if (!cmd) | 544 | if (!cmd) |
543 | cmd = "perf-help"; | 545 | cmd = "perf-help"; |
544 | 546 | ||
547 | srandom(time(NULL)); | ||
548 | |||
545 | /* get debugfs/tracefs mount point from /proc/mounts */ | 549 | /* get debugfs/tracefs mount point from /proc/mounts */ |
546 | tracing_path_mount(); | 550 | tracing_path_mount(); |
547 | 551 | ||
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index aff0cfd83662..88b8f8d21f58 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -16,6 +16,8 @@ | |||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <unistd.h> | 17 | #include <unistd.h> |
18 | #include "callchain.h" | 18 | #include "callchain.h" |
19 | #include "strlist.h" | ||
20 | #include <subcmd/exec-cmd.h> | ||
19 | 21 | ||
20 | struct callchain_param callchain_param = { | 22 | struct callchain_param callchain_param = { |
21 | .mode = CHAIN_GRAPH_ABS, | 23 | .mode = CHAIN_GRAPH_ABS, |
@@ -663,3 +665,28 @@ fetch_kernel_version(unsigned int *puint, char *str, | |||
663 | *puint = (version << 16) + (patchlevel << 8) + sublevel; | 665 | *puint = (version << 16) + (patchlevel << 8) + sublevel; |
664 | return 0; | 666 | return 0; |
665 | } | 667 | } |
668 | |||
669 | const char *perf_tip(const char *dirpath) | ||
670 | { | ||
671 | struct strlist *tips; | ||
672 | struct str_node *node; | ||
673 | char *tip = NULL; | ||
674 | struct strlist_config conf = { | ||
675 | .dirname = system_path(dirpath) , | ||
676 | }; | ||
677 | |||
678 | tips = strlist__new("tips.txt", &conf); | ||
679 | if (tips == NULL || strlist__nr_entries(tips) == 1) { | ||
680 | tip = (char *)"Cannot find tips.txt file"; | ||
681 | goto out; | ||
682 | } | ||
683 | |||
684 | node = strlist__entry(tips, random() % strlist__nr_entries(tips)); | ||
685 | if (asprintf(&tip, "Tip: %s", node->s) < 0) | ||
686 | tip = (char *)"Tip: get more memory! ;-)"; | ||
687 | |||
688 | out: | ||
689 | strlist__delete(tips); | ||
690 | |||
691 | return tip; | ||
692 | } | ||
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 4b519c59bdc3..fe915e616f9b 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -342,4 +342,6 @@ int fetch_kernel_version(unsigned int *puint, | |||
342 | #define KVER_FMT "%d.%d.%d" | 342 | #define KVER_FMT "%d.%d.%d" |
343 | #define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) | 343 | #define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) |
344 | 344 | ||
345 | const char *perf_tip(const char *dirpath); | ||
346 | |||
345 | #endif /* GIT_COMPAT_UTIL_H */ | 347 | #endif /* GIT_COMPAT_UTIL_H */ |