perf evlist: Return the first evsel with an invalid filter in apply_filters()

Use of a bad filter currently generates the message:
 Error: failed to set filter with 22 (Invalid argument)

Add the event name to make it clear to which event the filter
failed to apply:
  Error: Failed to set filter "foo" on event sched:sg_lb_stats: 22: Invalid argument

To test it use something like:

 # perf record -e sched:sched_switch -e sched:*fork --filter parent_pid==1 -e sched:*wait* --filter bla usleep 1
  Error: failed to set filter "bla" on event sched:sched_stat_iowait with 22 (Invalid argument)
 #
Based-on-a-patch-by: default avatarDavid Ahern <dsahern@gmail.com>
Acked-by: default avatarDavid Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-d7gq2fjvaecozp9o2i0siifu@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e94eedab
...@@ -161,8 +161,9 @@ static int record__open(struct record *rec) ...@@ -161,8 +161,9 @@ static int record__open(struct record *rec)
} }
} }
if (perf_evlist__apply_filters(evlist)) { if (perf_evlist__apply_filters(evlist, &pos)) {
error("failed to set filter with %d (%s)\n", errno, error("failed to set filter \"%s\" on event %s with %d (%s)\n",
pos->filter, perf_evsel__name(pos), errno,
strerror_r(errno, msg, sizeof(msg))); strerror_r(errno, msg, sizeof(msg)));
rc = -1; rc = -1;
goto out; goto out;
......
...@@ -684,8 +684,9 @@ static int __run_perf_stat(int argc, const char **argv) ...@@ -684,8 +684,9 @@ static int __run_perf_stat(int argc, const char **argv)
unit_width = l; unit_width = l;
} }
if (perf_evlist__apply_filters(evsel_list)) { if (perf_evlist__apply_filters(evsel_list, &counter)) {
error("failed to set filter with %d (%s)\n", errno, error("failed to set filter \"%s\" on event %s with %d (%s)\n",
counter->filter, perf_evsel__name(counter), errno,
strerror_r(errno, msg, sizeof(msg))); strerror_r(errno, msg, sizeof(msg)));
return -1; return -1;
} }
......
...@@ -1050,7 +1050,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target) ...@@ -1050,7 +1050,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
return -1; return -1;
} }
int perf_evlist__apply_filters(struct perf_evlist *evlist) int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **err_evsel)
{ {
struct perf_evsel *evsel; struct perf_evsel *evsel;
int err = 0; int err = 0;
...@@ -1062,8 +1062,10 @@ int perf_evlist__apply_filters(struct perf_evlist *evlist) ...@@ -1062,8 +1062,10 @@ int perf_evlist__apply_filters(struct perf_evlist *evlist)
continue; continue;
err = perf_evsel__set_filter(evsel, ncpus, nthreads, evsel->filter); err = perf_evsel__set_filter(evsel, ncpus, nthreads, evsel->filter);
if (err) if (err) {
*err_evsel = evsel;
break; break;
}
} }
return err; return err;
......
...@@ -152,7 +152,7 @@ static inline void perf_evlist__set_maps(struct perf_evlist *evlist, ...@@ -152,7 +152,7 @@ static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
} }
int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target); int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target);
int perf_evlist__apply_filters(struct perf_evlist *evlist); int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **err_evsel);
void __perf_evlist__set_leader(struct list_head *list); void __perf_evlist__set_leader(struct list_head *list);
void perf_evlist__set_leader(struct perf_evlist *evlist); void perf_evlist__set_leader(struct perf_evlist *evlist);
......
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