aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorMathieu Poirier <mathieu.poirier@linaro.org>2016-09-16 11:50:03 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-09-22 12:07:36 -0400
commit5d8bb1ec7477e0e53dbd891733682a6583d4398e (patch)
tree868fb6786dfd87daf88189f824d87af0666ccbba /tools/perf
parent859442bd3fcbe326a9c0174c6105c938eb101438 (diff)
perf tools: Add PMU configuration to tools
Now that the required mechanic is there to deal with PMU specific configuration, add the functionality to the tools where events can be selected. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1474041004-13956-7-git-send-email-mathieu.poirier@linaro.org [ Fix the build on XSI-compliant systems, using str_error_r() to make sure we return a string, not an integer ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-record.c10
-rw-r--r--tools/perf/builtin-stat.c9
-rw-r--r--tools/perf/builtin-top.c13
3 files changed, 32 insertions, 0 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 03251c7f14ec..2d0d69be3bf8 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -22,6 +22,7 @@
22#include "util/evlist.h" 22#include "util/evlist.h"
23#include "util/evsel.h" 23#include "util/evsel.h"
24#include "util/debug.h" 24#include "util/debug.h"
25#include "util/drv_configs.h"
25#include "util/session.h" 26#include "util/session.h"
26#include "util/tool.h" 27#include "util/tool.h"
27#include "util/symbol.h" 28#include "util/symbol.h"
@@ -383,6 +384,7 @@ static int record__open(struct record *rec)
383 struct perf_evlist *evlist = rec->evlist; 384 struct perf_evlist *evlist = rec->evlist;
384 struct perf_session *session = rec->session; 385 struct perf_session *session = rec->session;
385 struct record_opts *opts = &rec->opts; 386 struct record_opts *opts = &rec->opts;
387 struct perf_evsel_config_term *err_term;
386 int rc = 0; 388 int rc = 0;
387 389
388 perf_evlist__config(evlist, opts, &callchain_param); 390 perf_evlist__config(evlist, opts, &callchain_param);
@@ -412,6 +414,14 @@ try_again:
412 goto out; 414 goto out;
413 } 415 }
414 416
417 if (perf_evlist__apply_drv_configs(evlist, &pos, &err_term)) {
418 error("failed to set config \"%s\" on event %s with %d (%s)\n",
419 err_term->val.drv_cfg, perf_evsel__name(pos), errno,
420 str_error_r(errno, msg, sizeof(msg)));
421 rc = -1;
422 goto out;
423 }
424
415 rc = record__mmap(rec); 425 rc = record__mmap(rec);
416 if (rc) 426 if (rc)
417 goto out; 427 goto out;
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 90882b1d6a91..688dea7cb08f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -52,6 +52,7 @@
52#include "util/evlist.h" 52#include "util/evlist.h"
53#include "util/evsel.h" 53#include "util/evsel.h"
54#include "util/debug.h" 54#include "util/debug.h"
55#include "util/drv_configs.h"
55#include "util/color.h" 56#include "util/color.h"
56#include "util/stat.h" 57#include "util/stat.h"
57#include "util/header.h" 58#include "util/header.h"
@@ -540,6 +541,7 @@ static int __run_perf_stat(int argc, const char **argv)
540 int status = 0; 541 int status = 0;
541 const bool forks = (argc > 0); 542 const bool forks = (argc > 0);
542 bool is_pipe = STAT_RECORD ? perf_stat.file.is_pipe : false; 543 bool is_pipe = STAT_RECORD ? perf_stat.file.is_pipe : false;
544 struct perf_evsel_config_term *err_term;
543 545
544 if (interval) { 546 if (interval) {
545 ts.tv_sec = interval / USEC_PER_MSEC; 547 ts.tv_sec = interval / USEC_PER_MSEC;
@@ -611,6 +613,13 @@ try_again:
611 return -1; 613 return -1;
612 } 614 }
613 615
616 if (perf_evlist__apply_drv_configs(evsel_list, &counter, &err_term)) {
617 error("failed to set config \"%s\" on event %s with %d (%s)\n",
618 err_term->val.drv_cfg, perf_evsel__name(counter), errno,
619 str_error_r(errno, msg, sizeof(msg)));
620 return -1;
621 }
622
614 if (STAT_RECORD) { 623 if (STAT_RECORD) {
615 int err, fd = perf_data_file__fd(&perf_stat.file); 624 int err, fd = perf_data_file__fd(&perf_stat.file);
616 625
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 400785702566..fe3af9535e85 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -24,6 +24,7 @@
24#include "util/annotate.h" 24#include "util/annotate.h"
25#include "util/config.h" 25#include "util/config.h"
26#include "util/color.h" 26#include "util/color.h"
27#include "util/drv_configs.h"
27#include "util/evlist.h" 28#include "util/evlist.h"
28#include "util/evsel.h" 29#include "util/evsel.h"
29#include "util/machine.h" 30#include "util/machine.h"
@@ -913,6 +914,10 @@ static int callchain_param__setup_sample_type(struct callchain_param *callchain)
913 914
914static int __cmd_top(struct perf_top *top) 915static int __cmd_top(struct perf_top *top)
915{ 916{
917 char msg[512];
918 struct perf_evsel *pos;
919 struct perf_evsel_config_term *err_term;
920 struct perf_evlist *evlist = top->evlist;
916 struct record_opts *opts = &top->record_opts; 921 struct record_opts *opts = &top->record_opts;
917 pthread_t thread; 922 pthread_t thread;
918 int ret; 923 int ret;
@@ -947,6 +952,14 @@ static int __cmd_top(struct perf_top *top)
947 if (ret) 952 if (ret)
948 goto out_delete; 953 goto out_delete;
949 954
955 ret = perf_evlist__apply_drv_configs(evlist, &pos, &err_term);
956 if (ret) {
957 error("failed to set config \"%s\" on event %s with %d (%s)\n",
958 err_term->val.drv_cfg, perf_evsel__name(pos), errno,
959 str_error_r(errno, msg, sizeof(msg)));
960 goto out_delete;
961 }
962
950 top->session->evlist = top->evlist; 963 top->session->evlist = top->evlist;
951 perf_session__set_id_hdr_size(top->session); 964 perf_session__set_id_hdr_size(top->session);
952 965