Commit 23a2f3ab authored by Lin Ming's avatar Lin Ming Committed by Arnaldo Carvalho de Melo

perf tools: Pass whole attr to event selectors

Since commit 69aad6f1(perf tools: Introduce event selectors), only
perf_event_attr::type and ::config are passed to event selector, which
makes perf tool not work correctly.

For example, PEBS does not work because perf_event_attr::precise_ip is
not passed to the syscall.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <1294369869.20563.19.camel@minggr.sh.intel.com>
Signed-off-by: default avatarLin Ming <ming.m.lin@intel.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 6b01f2c4
...@@ -683,8 +683,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) ...@@ -683,8 +683,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
nr_counters = ARRAY_SIZE(default_attrs); nr_counters = ARRAY_SIZE(default_attrs);
for (c = 0; c < ARRAY_SIZE(default_attrs); ++c) { for (c = 0; c < ARRAY_SIZE(default_attrs); ++c) {
pos = perf_evsel__new(default_attrs[c].type, pos = perf_evsel__new(&default_attrs[c],
default_attrs[c].config,
nr_counters); nr_counters);
if (pos == NULL) if (pos == NULL)
goto out; goto out;
......
...@@ -264,6 +264,7 @@ static int test__open_syscall_event(void) ...@@ -264,6 +264,7 @@ static int test__open_syscall_event(void)
int err = -1, fd; int err = -1, fd;
struct thread_map *threads; struct thread_map *threads;
struct perf_evsel *evsel; struct perf_evsel *evsel;
struct perf_event_attr attr;
unsigned int nr_open_calls = 111, i; unsigned int nr_open_calls = 111, i;
int id = trace_event__id("sys_enter_open"); int id = trace_event__id("sys_enter_open");
...@@ -278,7 +279,10 @@ static int test__open_syscall_event(void) ...@@ -278,7 +279,10 @@ static int test__open_syscall_event(void)
return -1; return -1;
} }
evsel = perf_evsel__new(PERF_TYPE_TRACEPOINT, id, 0); memset(&attr, 0, sizeof(attr));
attr.type = PERF_TYPE_TRACEPOINT;
attr.config = id;
evsel = perf_evsel__new(&attr, 0);
if (evsel == NULL) { if (evsel == NULL) {
pr_debug("perf_evsel__new\n"); pr_debug("perf_evsel__new\n");
goto out_thread_map_delete; goto out_thread_map_delete;
......
...@@ -6,14 +6,13 @@ ...@@ -6,14 +6,13 @@
#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
struct perf_evsel *perf_evsel__new(u32 type, u64 config, int idx) struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx)
{ {
struct perf_evsel *evsel = zalloc(sizeof(*evsel)); struct perf_evsel *evsel = zalloc(sizeof(*evsel));
if (evsel != NULL) { if (evsel != NULL) {
evsel->idx = idx; evsel->idx = idx;
evsel->attr.type = type; evsel->attr = *attr;
evsel->attr.config = config;
INIT_LIST_HEAD(&evsel->node); INIT_LIST_HEAD(&evsel->node);
} }
......
...@@ -37,7 +37,7 @@ struct perf_evsel { ...@@ -37,7 +37,7 @@ struct perf_evsel {
struct cpu_map; struct cpu_map;
struct thread_map; struct thread_map;
struct perf_evsel *perf_evsel__new(u32 type, u64 config, int idx); struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx);
void perf_evsel__delete(struct perf_evsel *evsel); void perf_evsel__delete(struct perf_evsel *evsel);
int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
......
...@@ -823,7 +823,7 @@ int parse_events(const struct option *opt __used, const char *str, int unset __u ...@@ -823,7 +823,7 @@ int parse_events(const struct option *opt __used, const char *str, int unset __u
if (ret != EVT_HANDLED_ALL) { if (ret != EVT_HANDLED_ALL) {
struct perf_evsel *evsel; struct perf_evsel *evsel;
evsel = perf_evsel__new(attr.type, attr.config, evsel = perf_evsel__new(&attr,
nr_counters); nr_counters);
if (evsel == NULL) if (evsel == NULL)
return -1; return -1;
...@@ -1013,8 +1013,15 @@ void print_events(void) ...@@ -1013,8 +1013,15 @@ void print_events(void)
int perf_evsel_list__create_default(void) int perf_evsel_list__create_default(void)
{ {
struct perf_evsel *evsel = perf_evsel__new(PERF_TYPE_HARDWARE, struct perf_evsel *evsel;
PERF_COUNT_HW_CPU_CYCLES, 0); struct perf_event_attr attr;
memset(&attr, 0, sizeof(attr));
attr.type = PERF_TYPE_HARDWARE;
attr.config = PERF_COUNT_HW_CPU_CYCLES;
evsel = perf_evsel__new(&attr, 0);
if (evsel == NULL) if (evsel == NULL)
return -ENOMEM; return -ENOMEM;
......
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