Commit 5d8bb1ec authored by Mathieu Poirier's avatar Mathieu Poirier Committed by Arnaldo Carvalho de Melo

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: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 859442bd
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "util/evlist.h" #include "util/evlist.h"
#include "util/evsel.h" #include "util/evsel.h"
#include "util/debug.h" #include "util/debug.h"
#include "util/drv_configs.h"
#include "util/session.h" #include "util/session.h"
#include "util/tool.h" #include "util/tool.h"
#include "util/symbol.h" #include "util/symbol.h"
...@@ -383,6 +384,7 @@ static int record__open(struct record *rec) ...@@ -383,6 +384,7 @@ static int record__open(struct record *rec)
struct perf_evlist *evlist = rec->evlist; struct perf_evlist *evlist = rec->evlist;
struct perf_session *session = rec->session; struct perf_session *session = rec->session;
struct record_opts *opts = &rec->opts; struct record_opts *opts = &rec->opts;
struct perf_evsel_config_term *err_term;
int rc = 0; int rc = 0;
perf_evlist__config(evlist, opts, &callchain_param); perf_evlist__config(evlist, opts, &callchain_param);
...@@ -412,6 +414,14 @@ static int record__open(struct record *rec) ...@@ -412,6 +414,14 @@ static int record__open(struct record *rec)
goto out; goto out;
} }
if (perf_evlist__apply_drv_configs(evlist, &pos, &err_term)) {
error("failed to set config \"%s\" on event %s with %d (%s)\n",
err_term->val.drv_cfg, perf_evsel__name(pos), errno,
str_error_r(errno, msg, sizeof(msg)));
rc = -1;
goto out;
}
rc = record__mmap(rec); rc = record__mmap(rec);
if (rc) if (rc)
goto out; goto out;
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "util/evlist.h" #include "util/evlist.h"
#include "util/evsel.h" #include "util/evsel.h"
#include "util/debug.h" #include "util/debug.h"
#include "util/drv_configs.h"
#include "util/color.h" #include "util/color.h"
#include "util/stat.h" #include "util/stat.h"
#include "util/header.h" #include "util/header.h"
...@@ -540,6 +541,7 @@ static int __run_perf_stat(int argc, const char **argv) ...@@ -540,6 +541,7 @@ static int __run_perf_stat(int argc, const char **argv)
int status = 0; int status = 0;
const bool forks = (argc > 0); const bool forks = (argc > 0);
bool is_pipe = STAT_RECORD ? perf_stat.file.is_pipe : false; bool is_pipe = STAT_RECORD ? perf_stat.file.is_pipe : false;
struct perf_evsel_config_term *err_term;
if (interval) { if (interval) {
ts.tv_sec = interval / USEC_PER_MSEC; ts.tv_sec = interval / USEC_PER_MSEC;
...@@ -611,6 +613,13 @@ static int __run_perf_stat(int argc, const char **argv) ...@@ -611,6 +613,13 @@ static int __run_perf_stat(int argc, const char **argv)
return -1; return -1;
} }
if (perf_evlist__apply_drv_configs(evsel_list, &counter, &err_term)) {
error("failed to set config \"%s\" on event %s with %d (%s)\n",
err_term->val.drv_cfg, perf_evsel__name(counter), errno,
str_error_r(errno, msg, sizeof(msg)));
return -1;
}
if (STAT_RECORD) { if (STAT_RECORD) {
int err, fd = perf_data_file__fd(&perf_stat.file); int err, fd = perf_data_file__fd(&perf_stat.file);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "util/annotate.h" #include "util/annotate.h"
#include "util/config.h" #include "util/config.h"
#include "util/color.h" #include "util/color.h"
#include "util/drv_configs.h"
#include "util/evlist.h" #include "util/evlist.h"
#include "util/evsel.h" #include "util/evsel.h"
#include "util/machine.h" #include "util/machine.h"
...@@ -913,6 +914,10 @@ static int callchain_param__setup_sample_type(struct callchain_param *callchain) ...@@ -913,6 +914,10 @@ static int callchain_param__setup_sample_type(struct callchain_param *callchain)
static int __cmd_top(struct perf_top *top) static int __cmd_top(struct perf_top *top)
{ {
char msg[512];
struct perf_evsel *pos;
struct perf_evsel_config_term *err_term;
struct perf_evlist *evlist = top->evlist;
struct record_opts *opts = &top->record_opts; struct record_opts *opts = &top->record_opts;
pthread_t thread; pthread_t thread;
int ret; int ret;
...@@ -947,6 +952,14 @@ static int __cmd_top(struct perf_top *top) ...@@ -947,6 +952,14 @@ static int __cmd_top(struct perf_top *top)
if (ret) if (ret)
goto out_delete; goto out_delete;
ret = perf_evlist__apply_drv_configs(evlist, &pos, &err_term);
if (ret) {
error("failed to set config \"%s\" on event %s with %d (%s)\n",
err_term->val.drv_cfg, perf_evsel__name(pos), errno,
str_error_r(errno, msg, sizeof(msg)));
goto out_delete;
}
top->session->evlist = top->evlist; top->session->evlist = top->evlist;
perf_session__set_id_hdr_size(top->session); perf_session__set_id_hdr_size(top->session);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment