linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] perf tools: Add more usage tips
@ 2016-01-09 10:16 Namhyung Kim
  2016-01-09 10:16 ` [PATCH 2/4] perf tools: Add file_only config option to strlist Namhyung Kim
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Namhyung Kim @ 2016-01-09 10:16 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern,
	Andi Kleen, Wang Nan, Brendan Gregg

Thanks to Andi Kleen for providing useful tips.

Suggested-by: Andi Kleen <andi@firstfloor.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/tips.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tools/perf/Documentation/tips.txt b/tools/perf/Documentation/tips.txt
index a1c10e360db5..2319ff7fa53b 100644
--- a/tools/perf/Documentation/tips.txt
+++ b/tools/perf/Documentation/tips.txt
@@ -12,3 +12,18 @@ List events using substring match: perf list <keyword>
 To see list of saved events and attributes: perf evlist -v
 Use --symfs <dir> if your symbol files are in non-standard locations
 To see callchains in a more compact form: perf report -g folded
+Show individual samples with: perf script
+Limit to show entries above 5% only: perf report --percent-limit 5
+Profiling branch (mis)predictions with: perf record -b / perf report
+Treat branches as callchains: perf report --branch-history
+To count events in every 1000 msec: perf stat -I 1000
+Print event counts in CSV format with: perf stat -x
+If you have debuginfo enabled, try: perf report -s sym,srcline
+For memory address profiling, try: perf mem record / perf mem report
+For tracepoint events, try: perf report -s trace_fields
+To record callchains for each sample: perf record -g
+To record every process run by an user: perf record -u <user>
+Skip collecing build-id when recording: perf record -B
+To change sampling frequency to 100 Hz: perf record -F 100
+See assembly instructions with percentage: perf annotate <symbol>
+If you prefer Intel style assembly, try: perf annotate -M intel
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/4] perf tools: Add file_only config option to strlist
  2016-01-09 10:16 [PATCH 1/4] perf tools: Add more usage tips Namhyung Kim
@ 2016-01-09 10:16 ` Namhyung Kim
  2016-01-13  9:42   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  2016-01-09 10:16 ` [PATCH 3/4] perf tools: Set and pass DOCDIR to builtin-report.c Namhyung Kim
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 17+ messages in thread
From: Namhyung Kim @ 2016-01-09 10:16 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern,
	Andi Kleen, Wang Nan

If strlist_config.dirname is present, the strlist__new() tries to load
stirngs from dirname/list file first but if it failes it falls back to
add 'list' as string.  But sometimes it's not desired so adds new
file_only field to prevent it.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/strlist.c | 8 ++++++++
 tools/perf/util/strlist.h | 4 +++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c
index bdf98f6f27bb..0d3dfcb919b4 100644
--- a/tools/perf/util/strlist.c
+++ b/tools/perf/util/strlist.c
@@ -126,6 +126,11 @@ static int strlist__parse_list_entry(struct strlist *slist, const char *s,
 			err = strlist__load(slist, subst);
 			goto out;
 		}
+
+		if (slist->file_only) {
+			err = -ENOENT;
+			goto out;
+		}
 	}
 
 	err = strlist__add(slist, s);
@@ -157,11 +162,13 @@ struct strlist *strlist__new(const char *list, const struct strlist_config *conf
 
 	if (slist != NULL) {
 		bool dupstr = true;
+		bool file_only = false;
 		const char *dirname = NULL;
 
 		if (config) {
 			dupstr = !config->dont_dupstr;
 			dirname = config->dirname;
+			file_only = config->file_only;
 		}
 
 		rblist__init(&slist->rblist);
@@ -170,6 +177,7 @@ struct strlist *strlist__new(const char *list, const struct strlist_config *conf
 		slist->rblist.node_delete = strlist__node_delete;
 
 		slist->dupstr	 = dupstr;
+		slist->file_only = file_only;
 
 		if (list && strlist__parse_list(slist, list, dirname) != 0)
 			goto out_error;
diff --git a/tools/perf/util/strlist.h b/tools/perf/util/strlist.h
index 297565aa7535..93e2c58b40cc 100644
--- a/tools/perf/util/strlist.h
+++ b/tools/perf/util/strlist.h
@@ -13,11 +13,13 @@ struct str_node {
 
 struct strlist {
 	struct rblist rblist;
-	bool	       dupstr;
+	bool	      dupstr;
+	bool	      file_only;
 };
 
 struct strlist_config {
 	bool dont_dupstr;
+	bool file_only;
 	const char *dirname;
 };
 
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/4] perf tools: Set and pass DOCDIR to builtin-report.c
  2016-01-09 10:16 [PATCH 1/4] perf tools: Add more usage tips Namhyung Kim
  2016-01-09 10:16 ` [PATCH 2/4] perf tools: Add file_only config option to strlist Namhyung Kim
@ 2016-01-09 10:16 ` Namhyung Kim
  2016-01-13  9:42   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  2016-01-09 10:16 ` [PATCH 4/4] perf tools: Fallback to srcdir/Documentation/tips.txt Namhyung Kim
  2016-01-10  3:38 ` [PATCH 1/4] perf tools: Add more usage tips Andi Kleen
  3 siblings, 1 reply; 17+ messages in thread
From: Namhyung Kim @ 2016-01-09 10:16 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern,
	Andi Kleen, Wang Nan

It'll be used to locate perf document directory to find tips.txt in case
it's not installed on the system.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Build           | 1 +
 tools/perf/config/Makefile | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/tools/perf/Build b/tools/perf/Build
index 6b67e6f4179f..a43fae7f439a 100644
--- a/tools/perf/Build
+++ b/tools/perf/Build
@@ -42,6 +42,7 @@ CFLAGS_perf.o              += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))"	\
 			      -include $(OUTPUT)PERF-VERSION-FILE
 CFLAGS_builtin-trace.o	   += -DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))"
 CFLAGS_builtin-report.o	   += -DTIPDIR="BUILD_STR($(tipdir_SQ))"
+CFLAGS_builtin-report.o	   += -DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)"
 
 libperf-y += util/
 libperf-y += arch/
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 254d06e39bea..39d642d18c4e 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -692,6 +692,7 @@ template_dir = share/perf-core/templates
 STRACE_GROUPS_DIR = share/perf-core/strace/groups
 htmldir = share/doc/perf-doc
 tipdir = share/doc/perf-tip
+srcdir = $(srctree)/tools/perf
 ifeq ($(prefix),/usr)
 sysconfdir = /etc
 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
@@ -722,6 +723,7 @@ tipdir_SQ = $(subst ','\'',$(tipdir))
 prefix_SQ = $(subst ','\'',$(prefix))
 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
 libdir_SQ = $(subst ','\'',$(libdir))
+srcdir_SQ = $(subst ','\'',$(srcdir))
 
 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
 perfexec_instdir = $(perfexecdir)
@@ -776,6 +778,7 @@ $(call detected_var,STRACE_GROUPS_DIR_SQ)
 $(call detected_var,prefix_SQ)
 $(call detected_var,perfexecdir_SQ)
 $(call detected_var,tipdir_SQ)
+$(call detected_var,srcdir_SQ)
 $(call detected_var,LIBDIR)
 $(call detected_var,GTK_CFLAGS)
 $(call detected_var,PERL_EMBED_CCOPTS)
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/4] perf tools: Fallback to srcdir/Documentation/tips.txt
  2016-01-09 10:16 [PATCH 1/4] perf tools: Add more usage tips Namhyung Kim
  2016-01-09 10:16 ` [PATCH 2/4] perf tools: Add file_only config option to strlist Namhyung Kim
  2016-01-09 10:16 ` [PATCH 3/4] perf tools: Set and pass DOCDIR to builtin-report.c Namhyung Kim
@ 2016-01-09 10:16 ` Namhyung Kim
  2016-01-11  9:18   ` Jiri Olsa
                     ` (2 more replies)
  2016-01-10  3:38 ` [PATCH 1/4] perf tools: Add more usage tips Andi Kleen
  3 siblings, 3 replies; 17+ messages in thread
From: Namhyung Kim @ 2016-01-09 10:16 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern,
	Andi Kleen, Wang Nan

Some people don't install perf, but just use compiled version in the
source.  Fallback to lookup the source directory for those poor guys. :)

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-report.c | 10 +++++++++-
 tools/perf/util/util.c      | 11 ++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d5a42ee12529..2bf537f190a0 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -28,6 +28,7 @@
 #include "util/tool.h"
 
 #include <subcmd/parse-options.h>
+#include <subcmd/exec-cmd.h>
 #include "util/parse-events.h"
 
 #include "util/thread.h"
@@ -433,7 +434,14 @@ static int report__browse_hists(struct report *rep)
 	int ret;
 	struct perf_session *session = rep->session;
 	struct perf_evlist *evlist = session->evlist;
-	const char *help = perf_tip(TIPDIR);
+	const char *help = perf_tip(system_path(TIPDIR));
+
+	if (help == NULL) {
+		/* fallback for people who don't install perf ;-) */
+		help = perf_tip(DOCDIR);
+		if (help == NULL)
+			help = "Cannot load tips.txt file, please install perf!";
+	}
 
 	switch (use_browser) {
 	case 1:
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 88b8f8d21f58..92e8543dadf9 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -17,7 +17,6 @@
 #include <unistd.h>
 #include "callchain.h"
 #include "strlist.h"
-#include <subcmd/exec-cmd.h>
 
 struct callchain_param	callchain_param = {
 	.mode	= CHAIN_GRAPH_ABS,
@@ -672,14 +671,16 @@ const char *perf_tip(const char *dirpath)
 	struct str_node *node;
 	char *tip = NULL;
 	struct strlist_config conf = {
-		.dirname = system_path(dirpath) ,
+		.dirname = dirpath,
+		.file_only = true,
 	};
 
 	tips = strlist__new("tips.txt", &conf);
-	if (tips == NULL || strlist__nr_entries(tips) == 1) {
-		tip = (char *)"Cannot find tips.txt file";
+	if (tips == NULL)
+		return "Tip: get more memory! ;-p";
+
+	if (strlist__nr_entries(tips) == 0)
 		goto out;
-	}
 
 	node = strlist__entry(tips, random() % strlist__nr_entries(tips));
 	if (asprintf(&tip, "Tip: %s", node->s) < 0)
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] perf tools: Add more usage tips
  2016-01-09 10:16 [PATCH 1/4] perf tools: Add more usage tips Namhyung Kim
                   ` (2 preceding siblings ...)
  2016-01-09 10:16 ` [PATCH 4/4] perf tools: Fallback to srcdir/Documentation/tips.txt Namhyung Kim
@ 2016-01-10  3:38 ` Andi Kleen
  2016-01-11 10:35   ` [PATCH v2 " Namhyung Kim
  3 siblings, 1 reply; 17+ messages in thread
From: Andi Kleen @ 2016-01-10  3:38 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa,
	LKML, David Ahern, Andi Kleen, Wang Nan, Brendan Gregg

> +Show individual samples with: perf script
> +Limit to show entries above 5% only: perf report --percent-limit 5
> +Profiling branch (mis)predictions with: perf record -b / perf report
> +Treat branches as callchains: perf report --branch-history
> +To count events in every 1000 msec: perf stat -I 1000
> +Print event counts in CSV format with: perf stat -x

Should be -x, 

-Andi

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] perf tools: Fallback to srcdir/Documentation/tips.txt
  2016-01-09 10:16 ` [PATCH 4/4] perf tools: Fallback to srcdir/Documentation/tips.txt Namhyung Kim
@ 2016-01-11  9:18   ` Jiri Olsa
  2016-01-12 15:34     ` Arnaldo Carvalho de Melo
  2016-01-12 15:22   ` Arnaldo Carvalho de Melo
  2016-01-13  9:43   ` [tip:perf/urgent] perf tools: Fallback to srcdir/Documentation/ tips.txt tip-bot for Namhyung Kim
  2 siblings, 1 reply; 17+ messages in thread
From: Jiri Olsa @ 2016-01-11  9:18 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa,
	LKML, David Ahern, Andi Kleen, Wang Nan

On Sat, Jan 09, 2016 at 07:16:29PM +0900, Namhyung Kim wrote:
> Some people don't install perf, but just use compiled version in the
> source.  Fallback to lookup the source directory for those poor guys. :)
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/builtin-report.c | 10 +++++++++-
>  tools/perf/util/util.c      | 11 ++++++-----
>  2 files changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index d5a42ee12529..2bf537f190a0 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -28,6 +28,7 @@
>  #include "util/tool.h"
>  
>  #include <subcmd/parse-options.h>
> +#include <subcmd/exec-cmd.h>
>  #include "util/parse-events.h"
>  
>  #include "util/thread.h"
> @@ -433,7 +434,14 @@ static int report__browse_hists(struct report *rep)
>  	int ret;
>  	struct perf_session *session = rep->session;
>  	struct perf_evlist *evlist = session->evlist;
> -	const char *help = perf_tip(TIPDIR);
> +	const char *help = perf_tip(system_path(TIPDIR));
> +
> +	if (help == NULL) {
> +		/* fallback for people who don't install perf ;-) */
> +		help = perf_tip(DOCDIR);
> +		if (help == NULL)
> +			help = "Cannot load tips.txt file, please install perf!";
> +	}

hum, I can't get this one.. seems like perf_tip does
not retun NULL if there's no tip.txt file

jirka

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 1/4] perf tools: Add more usage tips
  2016-01-10  3:38 ` [PATCH 1/4] perf tools: Add more usage tips Andi Kleen
@ 2016-01-11 10:35   ` Namhyung Kim
  2016-01-11 10:53     ` [PATCH 5/4] perf ui/tui: Print helpline message as is Namhyung Kim
  2016-01-13  9:41     ` [tip:perf/urgent] perf tools: Add more usage tips tip-bot for Namhyung Kim
  0 siblings, 2 replies; 17+ messages in thread
From: Namhyung Kim @ 2016-01-11 10:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Andi Kleen
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern,
	Wang Nan, Brendan Gregg

Thanks to Andi Kleen for providing useful tips.

Suggested-by: Andi Kleen <andi@firstfloor.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/tips.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tools/perf/Documentation/tips.txt b/tools/perf/Documentation/tips.txt
index a1c10e360db5..e0ce9573b79b 100644
--- a/tools/perf/Documentation/tips.txt
+++ b/tools/perf/Documentation/tips.txt
@@ -12,3 +12,18 @@ List events using substring match: perf list <keyword>
 To see list of saved events and attributes: perf evlist -v
 Use --symfs <dir> if your symbol files are in non-standard locations
 To see callchains in a more compact form: perf report -g folded
+Show individual samples with: perf script
+Limit to show entries above 5% only: perf report --percent-limit 5
+Profiling branch (mis)predictions with: perf record -b / perf report
+Treat branches as callchains: perf report --branch-history
+To count events in every 1000 msec: perf stat -I 1000
+Print event counts in CSV format with: perf stat -x,
+If you have debuginfo enabled, try: perf report -s sym,srcline
+For memory address profiling, try: perf mem record / perf mem report
+For tracepoint events, try: perf report -s trace_fields
+To record callchains for each sample: perf record -g
+To record every process run by an user: perf record -u <user>
+Skip collecing build-id when recording: perf record -B
+To change sampling frequency to 100 Hz: perf record -F 100
+See assembly instructions with percentage: perf annotate <symbol>
+If you prefer Intel style assembly, try: perf annotate -M intel
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 5/4] perf ui/tui: Print helpline message as is
  2016-01-11 10:35   ` [PATCH v2 " Namhyung Kim
@ 2016-01-11 10:53     ` Namhyung Kim
  2016-01-12 15:23       ` Arnaldo Carvalho de Melo
  2016-01-13  9:42       ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  2016-01-13  9:41     ` [tip:perf/urgent] perf tools: Add more usage tips tip-bot for Namhyung Kim
  1 sibling, 2 replies; 17+ messages in thread
From: Namhyung Kim @ 2016-01-11 10:53 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern,
	Andi Kleen, Wang Nan

When a tip message contains a percent sign, it was treated printf format
specifier so broken string was printed like below.

  Tip: Limit to show entries above 577nly: perf report --percent-limit 5
                                   ^^^

As ui_browser__show receives format string, pass additional "%s" so that
the help (tip) message can be printed as is.

  Tip: Limit to show entries above 5% only: perf report --percent-limit 5

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/browsers/hists.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 901d481e6cea..08c09ad755d2 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -480,7 +480,7 @@ static int hist_browser__run(struct hist_browser *browser, const char *help)
 
 	hists__browser_title(browser->hists, hbt, title, sizeof(title));
 
-	if (ui_browser__show(&browser->b, title, help) < 0)
+	if (ui_browser__show(&browser->b, title, "%s", help) < 0)
 		return -1;
 
 	while (1) {
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] perf tools: Fallback to srcdir/Documentation/tips.txt
  2016-01-09 10:16 ` [PATCH 4/4] perf tools: Fallback to srcdir/Documentation/tips.txt Namhyung Kim
  2016-01-11  9:18   ` Jiri Olsa
@ 2016-01-12 15:22   ` Arnaldo Carvalho de Melo
  2016-01-13  9:43   ` [tip:perf/urgent] perf tools: Fallback to srcdir/Documentation/ tips.txt tip-bot for Namhyung Kim
  2 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-01-12 15:22 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern,
	Andi Kleen, Wang Nan

Em Sat, Jan 09, 2016 at 07:16:29PM +0900, Namhyung Kim escreveu:
> Some people don't install perf, but just use compiled version in the
> source.  Fallback to lookup the source directory for those poor guys. :)
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

So, after applying this I tried:

  $ rm -f ~/share/doc/perf-tip/tips.txt

  To make it fallback and:

  $ perf report --stdio | tail -3
  #
  # (Tip: get more memory! ;-p)
  #
  $ 

Doesn't work, looking at what it is trying to find:

  # perf trace --no-inherit -e access perf report --stdio
     0.090 ( 0.010 ms): access(filename: /etc/ld.so.preload, mode: R                          ) = -1 ENOENT No such file or directory
     2.013 ( 0.014 ms): access(filename: /home/acme/etc/perfconfig, mode: R                   ) = -1 ENOENT No such file or directory
     2.045 ( 0.004 ms): access(filename: /home/acme/etc/perfconfig, mode: R                   ) = -1 ENOENT No such file or directory
     2.076 ( 0.005 ms): access(filename: /home/acme/etc/perfconfig, mode: R                   ) = -1 ENOENT No such file or directory
     2.239 ( 0.006 ms): access(filename: /usr/bin/pager, mode: X                              ) = -1 ENOENT No such file or directory
     2.244 ( 0.004 ms): access(filename: /usr/bin/less, mode: X                               ) = 0
    16.969 ( 0.018 ms): access(filename: /home/acme/share/doc/perf-tip/tips.txt               ) = -1 ENOENT No such file or directory
  # To display the perf.data header info, please use --header/--header-only options.
  # 
  #
  # Total Lost Samples: 0
  #
  # Samples: 5  of event 'cycles:pp'
  # Event count (approx.): 24954605
  #
  # Overhead  Command  Shared Object     Symbol                   
  # ........  .......  ................  .........................
  #
    99.68%  usleep   [kernel.vmlinux]  [k] vma_rb_erase         
     0.32%  perf     [kernel.vmlinux]  [k] nmi_cpu_backtrace    
     0.00%  perf     [kernel.vmlinux]  [k] native_write_msr_safe

  #
  # (Tip: get more memory! ;-p)
  #
  #


Also you're not just fallbacking, you did this other unrelated change, no?

-     const char *help = perf_tip(TIPDIR);
+     const char *help = perf_tip(system_path(TIPDIR));


Investigating...

> ---
>  tools/perf/builtin-report.c | 10 +++++++++-
>  tools/perf/util/util.c      | 11 ++++++-----
>  2 files changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index d5a42ee12529..2bf537f190a0 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -28,6 +28,7 @@
>  #include "util/tool.h"
>  
>  #include <subcmd/parse-options.h>
> +#include <subcmd/exec-cmd.h>
>  #include "util/parse-events.h"
>  
>  #include "util/thread.h"
> @@ -433,7 +434,14 @@ static int report__browse_hists(struct report *rep)
>  	int ret;
>  	struct perf_session *session = rep->session;
>  	struct perf_evlist *evlist = session->evlist;
> -	const char *help = perf_tip(TIPDIR);
> +	const char *help = perf_tip(system_path(TIPDIR));
> +
> +	if (help == NULL) {
> +		/* fallback for people who don't install perf ;-) */
> +		help = perf_tip(DOCDIR);
> +		if (help == NULL)
> +			help = "Cannot load tips.txt file, please install perf!";
> +	}
>  
>  	switch (use_browser) {
>  	case 1:
> diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
> index 88b8f8d21f58..92e8543dadf9 100644
> --- a/tools/perf/util/util.c
> +++ b/tools/perf/util/util.c
> @@ -17,7 +17,6 @@
>  #include <unistd.h>
>  #include "callchain.h"
>  #include "strlist.h"
> -#include <subcmd/exec-cmd.h>
>  
>  struct callchain_param	callchain_param = {
>  	.mode	= CHAIN_GRAPH_ABS,
> @@ -672,14 +671,16 @@ const char *perf_tip(const char *dirpath)
>  	struct str_node *node;
>  	char *tip = NULL;
>  	struct strlist_config conf = {
> -		.dirname = system_path(dirpath) ,
> +		.dirname = dirpath,
> +		.file_only = true,
>  	};
>  
>  	tips = strlist__new("tips.txt", &conf);
> -	if (tips == NULL || strlist__nr_entries(tips) == 1) {
> -		tip = (char *)"Cannot find tips.txt file";
> +	if (tips == NULL)
> +		return "Tip: get more memory! ;-p";
> +
> +	if (strlist__nr_entries(tips) == 0)
>  		goto out;
> -	}
>  
>  	node = strlist__entry(tips, random() % strlist__nr_entries(tips));
>  	if (asprintf(&tip, "Tip: %s", node->s) < 0)
> -- 
> 2.6.4

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/4] perf ui/tui: Print helpline message as is
  2016-01-11 10:53     ` [PATCH 5/4] perf ui/tui: Print helpline message as is Namhyung Kim
@ 2016-01-12 15:23       ` Arnaldo Carvalho de Melo
  2016-01-13  9:42       ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  1 sibling, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-01-12 15:23 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern,
	Andi Kleen, Wang Nan

Em Mon, Jan 11, 2016 at 07:53:14PM +0900, Namhyung Kim escreveu:
> When a tip message contains a percent sign, it was treated printf format
> specifier so broken string was printed like below.
> 
>   Tip: Limit to show entries above 577nly: perf report --percent-limit 5
>                                    ^^^
> 
> As ui_browser__show receives format string, pass additional "%s" so that
> the help (tip) message can be printed as is.
> 
>   Tip: Limit to show entries above 5% only: perf report --percent-limit 5

Applied.
 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/ui/browsers/hists.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index 901d481e6cea..08c09ad755d2 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -480,7 +480,7 @@ static int hist_browser__run(struct hist_browser *browser, const char *help)
>  
>  	hists__browser_title(browser->hists, hbt, title, sizeof(title));
>  
> -	if (ui_browser__show(&browser->b, title, help) < 0)
> +	if (ui_browser__show(&browser->b, title, "%s", help) < 0)
>  		return -1;
>  
>  	while (1) {
> -- 
> 2.6.4

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] perf tools: Fallback to srcdir/Documentation/tips.txt
  2016-01-11  9:18   ` Jiri Olsa
@ 2016-01-12 15:34     ` Arnaldo Carvalho de Melo
  2016-01-12 15:39       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-01-12 15:34 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Namhyung Kim, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML,
	David Ahern, Andi Kleen, Wang Nan

Em Mon, Jan 11, 2016 at 10:18:20AM +0100, Jiri Olsa escreveu:
> On Sat, Jan 09, 2016 at 07:16:29PM +0900, Namhyung Kim wrote:
> > Some people don't install perf, but just use compiled version in the
> > source.  Fallback to lookup the source directory for those poor guys. :)
> > 
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> >  tools/perf/builtin-report.c | 10 +++++++++-
> >  tools/perf/util/util.c      | 11 ++++++-----
> >  2 files changed, 15 insertions(+), 6 deletions(-)
> > 
> > diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> > index d5a42ee12529..2bf537f190a0 100644
> > --- a/tools/perf/builtin-report.c
> > +++ b/tools/perf/builtin-report.c
> > @@ -28,6 +28,7 @@
> >  #include "util/tool.h"
> >  
> >  #include <subcmd/parse-options.h>
> > +#include <subcmd/exec-cmd.h>
> >  #include "util/parse-events.h"
> >  
> >  #include "util/thread.h"
> > @@ -433,7 +434,14 @@ static int report__browse_hists(struct report *rep)
> >  	int ret;
> >  	struct perf_session *session = rep->session;
> >  	struct perf_evlist *evlist = session->evlist;
> > -	const char *help = perf_tip(TIPDIR);
> > +	const char *help = perf_tip(system_path(TIPDIR));
> > +
> > +	if (help == NULL) {
> > +		/* fallback for people who don't install perf ;-) */
> > +		help = perf_tip(DOCDIR);
> > +		if (help == NULL)
> > +			help = "Cannot load tips.txt file, please install perf!";
> > +	}
> 
> hum, I can't get this one.. seems like perf_tip does
> not retun NULL if there's no tip.txt file

Neither me, fixing it up, this fallback will never take place.

- Arnaldo

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] perf tools: Fallback to srcdir/Documentation/tips.txt
  2016-01-12 15:34     ` Arnaldo Carvalho de Melo
@ 2016-01-12 15:39       ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-01-12 15:39 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Namhyung Kim, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML,
	David Ahern, Andi Kleen, Wang Nan

Em Tue, Jan 12, 2016 at 12:34:35PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Jan 11, 2016 at 10:18:20AM +0100, Jiri Olsa escreveu:
> > On Sat, Jan 09, 2016 at 07:16:29PM +0900, Namhyung Kim wrote:
> > > +		help = perf_tip(DOCDIR);
> > > +		if (help == NULL)
> > > +			help = "Cannot load tips.txt file, please install perf!";
> > > +	}
> > 
> > hum, I can't get this one.. seems like perf_tip does
> > not retun NULL if there's no tip.txt file
> 
> Neither me, fixing it up, this fallback will never take place.

With this patch on top, it works:

[root@felicio ~]# perf trace --no-inherit -e access perf report --stdio
     0.094 ( 0.017 ms): access(filename: /etc/ld.so.preload, mode: R                          ) = -1 ENOENT No such file or directory
     1.940 ( 0.008 ms): access(filename: /home/acme/etc/perfconfig, mode: R                   ) = -1 ENOENT No such file or directory
     1.979 ( 0.004 ms): access(filename: /home/acme/etc/perfconfig, mode: R                   ) = -1 ENOENT No such file or directory
     2.000 ( 0.004 ms): access(filename: /home/acme/etc/perfconfig, mode: R                   ) = -1 ENOENT No such file or directory
     2.177 ( 0.006 ms): access(filename: /usr/bin/pager, mode: X                              ) = -1 ENOENT No such file or directory
     2.189 ( 0.011 ms): access(filename: /usr/bin/less, mode: X                               ) = 0
    17.250 ( 0.018 ms): access(filename: /home/acme/share/doc/perf-tip/tips.txt               ) = -1 ENOENT No such file or directory
    17.259 ( 0.006 ms): access(filename: /home/acme/git/linux/tools/perf/Documentation/tips.txt) = 0
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 5  of event 'cycles:pp'
# Event count (approx.): 24954605
#
# Overhead  Command  Shared Object     Symbol                   
# ........  .......  ................  .........................
#
    99.68%  usleep   [kernel.vmlinux]  [k] vma_rb_erase         
     0.32%  perf     [kernel.vmlinux]  [k] nmi_cpu_backtrace    
     0.00%  perf     [kernel.vmlinux]  [k] native_write_msr_safe


#
# (Tip: To see callchains in a more compact form: perf report -g folded)
#
[root@felicio ~]#

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [tip:perf/urgent] perf tools: Add more usage tips
  2016-01-11 10:35   ` [PATCH v2 " Namhyung Kim
  2016-01-11 10:53     ` [PATCH 5/4] perf ui/tui: Print helpline message as is Namhyung Kim
@ 2016-01-13  9:41     ` tip-bot for Namhyung Kim
  1 sibling, 0 replies; 17+ messages in thread
From: tip-bot for Namhyung Kim @ 2016-01-13  9:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: andi, linux-kernel, wangnan0, acme, hpa, peterz, dsahern, tglx,
	brendan.d.gregg, mingo, namhyung, jolsa

Commit-ID:  09f1985404aa99b9d1ad435fcb0dabd20d4ed498
Gitweb:     http://git.kernel.org/tip/09f1985404aa99b9d1ad435fcb0dabd20d4ed498
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Mon, 11 Jan 2016 19:35:10 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 12 Jan 2016 12:42:07 -0300

perf tools: Add more usage tips

Thanks to Andi Kleen for providing useful tips.

Suggested-by: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1452508510-28316-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/tips.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tools/perf/Documentation/tips.txt b/tools/perf/Documentation/tips.txt
index a1c10e3..e0ce957 100644
--- a/tools/perf/Documentation/tips.txt
+++ b/tools/perf/Documentation/tips.txt
@@ -12,3 +12,18 @@ List events using substring match: perf list <keyword>
 To see list of saved events and attributes: perf evlist -v
 Use --symfs <dir> if your symbol files are in non-standard locations
 To see callchains in a more compact form: perf report -g folded
+Show individual samples with: perf script
+Limit to show entries above 5% only: perf report --percent-limit 5
+Profiling branch (mis)predictions with: perf record -b / perf report
+Treat branches as callchains: perf report --branch-history
+To count events in every 1000 msec: perf stat -I 1000
+Print event counts in CSV format with: perf stat -x,
+If you have debuginfo enabled, try: perf report -s sym,srcline
+For memory address profiling, try: perf mem record / perf mem report
+For tracepoint events, try: perf report -s trace_fields
+To record callchains for each sample: perf record -g
+To record every process run by an user: perf record -u <user>
+Skip collecing build-id when recording: perf record -B
+To change sampling frequency to 100 Hz: perf record -F 100
+See assembly instructions with percentage: perf annotate <symbol>
+If you prefer Intel style assembly, try: perf annotate -M intel

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [tip:perf/urgent] perf tools: Add file_only config option to strlist
  2016-01-09 10:16 ` [PATCH 2/4] perf tools: Add file_only config option to strlist Namhyung Kim
@ 2016-01-13  9:42   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 17+ messages in thread
From: tip-bot for Namhyung Kim @ 2016-01-13  9:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, dsahern, peterz, wangnan0, mingo, linux-kernel, tglx,
	namhyung, hpa, andi, jolsa

Commit-ID:  dd8232bc9d13b729d92590b55befd14e49f81eca
Gitweb:     http://git.kernel.org/tip/dd8232bc9d13b729d92590b55befd14e49f81eca
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Sat, 9 Jan 2016 19:16:27 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 12 Jan 2016 12:42:07 -0300

perf tools: Add file_only config option to strlist

If strlist_config.dirname is present, the strlist__new() tries to load
stirngs from dirname/list file first but if it failes it falls back to
add 'list' as string.  But sometimes it's not desired so adds new
file_only field to prevent it.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1452334589-8782-2-git-send-email-namhyung@kernel.org
[ Add documentation for strlist_config::file_only, in the struct definition */
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/strlist.c | 8 ++++++++
 tools/perf/util/strlist.h | 9 ++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c
index bdf98f6..0d3dfcb 100644
--- a/tools/perf/util/strlist.c
+++ b/tools/perf/util/strlist.c
@@ -126,6 +126,11 @@ static int strlist__parse_list_entry(struct strlist *slist, const char *s,
 			err = strlist__load(slist, subst);
 			goto out;
 		}
+
+		if (slist->file_only) {
+			err = -ENOENT;
+			goto out;
+		}
 	}
 
 	err = strlist__add(slist, s);
@@ -157,11 +162,13 @@ struct strlist *strlist__new(const char *list, const struct strlist_config *conf
 
 	if (slist != NULL) {
 		bool dupstr = true;
+		bool file_only = false;
 		const char *dirname = NULL;
 
 		if (config) {
 			dupstr = !config->dont_dupstr;
 			dirname = config->dirname;
+			file_only = config->file_only;
 		}
 
 		rblist__init(&slist->rblist);
@@ -170,6 +177,7 @@ struct strlist *strlist__new(const char *list, const struct strlist_config *conf
 		slist->rblist.node_delete = strlist__node_delete;
 
 		slist->dupstr	 = dupstr;
+		slist->file_only = file_only;
 
 		if (list && strlist__parse_list(slist, list, dirname) != 0)
 			goto out_error;
diff --git a/tools/perf/util/strlist.h b/tools/perf/util/strlist.h
index 297565a..ca99002 100644
--- a/tools/perf/util/strlist.h
+++ b/tools/perf/util/strlist.h
@@ -13,11 +13,18 @@ struct str_node {
 
 struct strlist {
 	struct rblist rblist;
-	bool	       dupstr;
+	bool	      dupstr;
+	bool	      file_only;
 };
 
+/*
+ * @file_only: When dirname is present, only consider entries as filenames,
+ *             that should not be added to the list if dirname/entry is not
+ *             found
+ */
 struct strlist_config {
 	bool dont_dupstr;
+	bool file_only;
 	const char *dirname;
 };
 

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [tip:perf/urgent] perf tools: Set and pass DOCDIR to builtin-report.c
  2016-01-09 10:16 ` [PATCH 3/4] perf tools: Set and pass DOCDIR to builtin-report.c Namhyung Kim
@ 2016-01-13  9:42   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 17+ messages in thread
From: tip-bot for Namhyung Kim @ 2016-01-13  9:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, acme, wangnan0, tglx, andi, hpa, dsahern, namhyung,
	mingo, linux-kernel, jolsa

Commit-ID:  84cfac7f05e110e803a45d99cff0ba0949cc8d58
Gitweb:     http://git.kernel.org/tip/84cfac7f05e110e803a45d99cff0ba0949cc8d58
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Sat, 9 Jan 2016 19:16:28 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 12 Jan 2016 12:42:07 -0300

perf tools: Set and pass DOCDIR to builtin-report.c

It'll be used to locate perf document directory to find tips.txt in case
it's not installed on the system.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1452334589-8782-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Build           | 1 +
 tools/perf/config/Makefile | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/tools/perf/Build b/tools/perf/Build
index 6b67e6f..a43fae7 100644
--- a/tools/perf/Build
+++ b/tools/perf/Build
@@ -42,6 +42,7 @@ CFLAGS_perf.o              += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))"	\
 			      -include $(OUTPUT)PERF-VERSION-FILE
 CFLAGS_builtin-trace.o	   += -DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))"
 CFLAGS_builtin-report.o	   += -DTIPDIR="BUILD_STR($(tipdir_SQ))"
+CFLAGS_builtin-report.o	   += -DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)"
 
 libperf-y += util/
 libperf-y += arch/
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 7545ba60..e5959c1 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -692,6 +692,7 @@ template_dir = share/perf-core/templates
 STRACE_GROUPS_DIR = share/perf-core/strace/groups
 htmldir = share/doc/perf-doc
 tipdir = share/doc/perf-tip
+srcdir = $(srctree)/tools/perf
 ifeq ($(prefix),/usr)
 sysconfdir = /etc
 ETC_PERFCONFIG = $(sysconfdir)/perfconfig
@@ -722,6 +723,7 @@ tipdir_SQ = $(subst ','\'',$(tipdir))
 prefix_SQ = $(subst ','\'',$(prefix))
 sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
 libdir_SQ = $(subst ','\'',$(libdir))
+srcdir_SQ = $(subst ','\'',$(srcdir))
 
 ifneq ($(filter /%,$(firstword $(perfexecdir))),)
 perfexec_instdir = $(perfexecdir)
@@ -776,6 +778,7 @@ $(call detected_var,STRACE_GROUPS_DIR_SQ)
 $(call detected_var,prefix_SQ)
 $(call detected_var,perfexecdir_SQ)
 $(call detected_var,tipdir_SQ)
+$(call detected_var,srcdir_SQ)
 $(call detected_var,LIBDIR)
 $(call detected_var,GTK_CFLAGS)
 $(call detected_var,PERL_EMBED_CCOPTS)

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [tip:perf/urgent] perf ui/tui: Print helpline message as is
  2016-01-11 10:53     ` [PATCH 5/4] perf ui/tui: Print helpline message as is Namhyung Kim
  2016-01-12 15:23       ` Arnaldo Carvalho de Melo
@ 2016-01-13  9:42       ` tip-bot for Namhyung Kim
  1 sibling, 0 replies; 17+ messages in thread
From: tip-bot for Namhyung Kim @ 2016-01-13  9:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: dsahern, mingo, tglx, hpa, andi, jolsa, wangnan0, peterz,
	linux-kernel, namhyung, acme

Commit-ID:  090cff3eae8f02395009972d01b5dfdb95bcc327
Gitweb:     http://git.kernel.org/tip/090cff3eae8f02395009972d01b5dfdb95bcc327
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Mon, 11 Jan 2016 19:53:14 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 12 Jan 2016 12:42:08 -0300

perf ui/tui: Print helpline message as is

When a tip message contains a percent sign, it was treated printf format
specifier so broken string was printed like below.

  Tip: Limit to show entries above 577nly: perf report --percent-limit 5
                                   ^^^

As ui_browser__show receives format string, pass additional "%s" so that
the help (tip) message can be printed as is.

  Tip: Limit to show entries above 5% only: perf report --percent-limit 5

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1452509594-13616-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 901d481..08c09ad 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -480,7 +480,7 @@ static int hist_browser__run(struct hist_browser *browser, const char *help)
 
 	hists__browser_title(browser->hists, hbt, title, sizeof(title));
 
-	if (ui_browser__show(&browser->b, title, help) < 0)
+	if (ui_browser__show(&browser->b, title, "%s", help) < 0)
 		return -1;
 
 	while (1) {

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [tip:perf/urgent] perf tools: Fallback to srcdir/Documentation/ tips.txt
  2016-01-09 10:16 ` [PATCH 4/4] perf tools: Fallback to srcdir/Documentation/tips.txt Namhyung Kim
  2016-01-11  9:18   ` Jiri Olsa
  2016-01-12 15:22   ` Arnaldo Carvalho de Melo
@ 2016-01-13  9:43   ` tip-bot for Namhyung Kim
  2 siblings, 0 replies; 17+ messages in thread
From: tip-bot for Namhyung Kim @ 2016-01-13  9:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, andi, jolsa, hpa, linux-kernel, namhyung, acme, mingo,
	wangnan0, dsahern, peterz

Commit-ID:  34b7b0f95d41d2351a080e774d71085171db90e6
Gitweb:     http://git.kernel.org/tip/34b7b0f95d41d2351a080e774d71085171db90e6
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Sat, 9 Jan 2016 19:16:29 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 12 Jan 2016 12:42:08 -0300

perf tools: Fallback to srcdir/Documentation/tips.txt

Some people don't install perf, but just use compiled version in the
source.  Fallback to lookup the source directory for those poor guys. :)

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1452334589-8782-4-git-send-email-namhyung@kernel.org
[ Make perf_tip() return NULL for ENOENT, making the fallback to really take place ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-report.c | 10 +++++++++-
 tools/perf/util/util.c      | 11 ++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d5a42ee..2bf537f 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -28,6 +28,7 @@
 #include "util/tool.h"
 
 #include <subcmd/parse-options.h>
+#include <subcmd/exec-cmd.h>
 #include "util/parse-events.h"
 
 #include "util/thread.h"
@@ -433,7 +434,14 @@ static int report__browse_hists(struct report *rep)
 	int ret;
 	struct perf_session *session = rep->session;
 	struct perf_evlist *evlist = session->evlist;
-	const char *help = perf_tip(TIPDIR);
+	const char *help = perf_tip(system_path(TIPDIR));
+
+	if (help == NULL) {
+		/* fallback for people who don't install perf ;-) */
+		help = perf_tip(DOCDIR);
+		if (help == NULL)
+			help = "Cannot load tips.txt file, please install perf!";
+	}
 
 	switch (use_browser) {
 	case 1:
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 88b8f8d..ead9509 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -17,7 +17,6 @@
 #include <unistd.h>
 #include "callchain.h"
 #include "strlist.h"
-#include <subcmd/exec-cmd.h>
 
 struct callchain_param	callchain_param = {
 	.mode	= CHAIN_GRAPH_ABS,
@@ -672,14 +671,16 @@ const char *perf_tip(const char *dirpath)
 	struct str_node *node;
 	char *tip = NULL;
 	struct strlist_config conf = {
-		.dirname = system_path(dirpath) ,
+		.dirname = dirpath,
+		.file_only = true,
 	};
 
 	tips = strlist__new("tips.txt", &conf);
-	if (tips == NULL || strlist__nr_entries(tips) == 1) {
-		tip = (char *)"Cannot find tips.txt file";
+	if (tips == NULL)
+		return errno == ENOENT ? NULL : "Tip: get more memory! ;-p";
+
+	if (strlist__nr_entries(tips) == 0)
 		goto out;
-	}
 
 	node = strlist__entry(tips, random() % strlist__nr_entries(tips));
 	if (asprintf(&tip, "Tip: %s", node->s) < 0)

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-01-13  9:43 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-09 10:16 [PATCH 1/4] perf tools: Add more usage tips Namhyung Kim
2016-01-09 10:16 ` [PATCH 2/4] perf tools: Add file_only config option to strlist Namhyung Kim
2016-01-13  9:42   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
2016-01-09 10:16 ` [PATCH 3/4] perf tools: Set and pass DOCDIR to builtin-report.c Namhyung Kim
2016-01-13  9:42   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
2016-01-09 10:16 ` [PATCH 4/4] perf tools: Fallback to srcdir/Documentation/tips.txt Namhyung Kim
2016-01-11  9:18   ` Jiri Olsa
2016-01-12 15:34     ` Arnaldo Carvalho de Melo
2016-01-12 15:39       ` Arnaldo Carvalho de Melo
2016-01-12 15:22   ` Arnaldo Carvalho de Melo
2016-01-13  9:43   ` [tip:perf/urgent] perf tools: Fallback to srcdir/Documentation/ tips.txt tip-bot for Namhyung Kim
2016-01-10  3:38 ` [PATCH 1/4] perf tools: Add more usage tips Andi Kleen
2016-01-11 10:35   ` [PATCH v2 " Namhyung Kim
2016-01-11 10:53     ` [PATCH 5/4] perf ui/tui: Print helpline message as is Namhyung Kim
2016-01-12 15:23       ` Arnaldo Carvalho de Melo
2016-01-13  9:42       ` [tip:perf/urgent] " tip-bot for Namhyung Kim
2016-01-13  9:41     ` [tip:perf/urgent] perf tools: Add more usage tips tip-bot for Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).