Skip to contentSkip to conversation

perf tests: Use perf_evlist__strerror_open() to provide hints about max_freq

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Feb 20, 2016 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  6880bbf96930ec6f8b40b5b93f21973f3297672a
Gitweb:     http://git.kernel.org/tip/6880bbf96930ec6f8b40b5b93f21973f3297672a
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Thu, 18 Feb 2016 13:40:57 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 19 Feb 2016 19:12:43 -0300

perf tests: Use perf_evlist__strerror_open() to provide hints about max_freq

Before:

  # perf test -v "code reading" 2>&1 | tail -4
  perf_evlist__open failed
  test child finished with -1
  ---- end ----
  Test object code reading: FAILED!
  #

After:

  # perf test -v "code reading" 2>&1 | tail -7
  perf_evlist__open() failed!
  Error: Invalid argument.
  Hint:  Check /proc/sys/kernel/perf_event_max_sample_rate.
  Hint:  The current value is 1000 and 4000 is being requested.
  test child finished with -1
  ---- end ----
  Test object code reading: FAILED!
  #
---
 tools/perf/tests/code-reading.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/perf/tests/code-reading.c +7 -1
index 313a48c..f84339c 100644
@@ -559,7 +559,13 @@ static int do_test_code_reading(bool try_kcore)
 				evlist = NULL;
 				continue;
 			}
-			pr_debug("perf_evlist__open failed\n");
+
+			if (verbose) {
+				char errbuf[512];
+				perf_evlist__strerror_open(evlist, errno, errbuf, sizeof(errbuf));
+				pr_debug("perf_evlist__open() failed!\n%s\n", errbuf);
+			}
+
 			goto out_put;
 		}
 		break;