@@ -171,6 +171,7 @@ struct record {
bool timestamp_filename;
bool timestamp_boundary;
bool off_cpu;
+ bool dummy_event_added;
const char *filter_action;
struct switch_output switch_output;
unsigned long long samples;
@@ -961,7 +962,7 @@ static int record__config_tracking_events(struct record *rec)
*/
if (opts->target.initial_delay || target__has_cpu(&opts->target) ||
perf_pmus__num_core_pmus() > 1) {
-
+ int evlist_entries_before = evlist->core.nr_entries;
/*
* User space tasks can migrate between CPUs, so when tracing
* selected CPUs, sideband for all CPUs is still needed.
@@ -973,6 +974,8 @@ static int record__config_tracking_events(struct record *rec)
if (!evsel)
return -ENOMEM;
+ rec->dummy_event_added = evlist->core.nr_entries > evlist_entries_before;
+
/*
* Enable the tracking event when the process is forked for
* initial_delay, immediately for system wide.
@@ -1366,6 +1369,7 @@ static int record__open(struct record *rec)
struct perf_session *session = rec->session;
struct record_opts *opts = &rec->opts;
int rc = 0;
+ bool skipped = false;
evlist__for_each_entry(evlist, pos) {
try_again:
@@ -1381,15 +1385,33 @@ static int record__open(struct record *rec)
pos = evlist__reset_weak_group(evlist, pos, true);
goto try_again;
}
- rc = -errno;
evsel__open_strerror(pos, &opts->target, errno, msg, sizeof(msg));
- ui__error("%s\n", msg);
- goto out;
+ ui__error("Failure to open event '%s' on PMU '%s' which will be removed.\n%s\n",
+ evsel__name(pos), evsel__pmu_name(pos), msg);
+ pos->skippable = true;
+ skipped = true;
+ } else {
+ pos->supported = true;
}
-
- pos->supported = true;
}
+ if (skipped) {
+ struct evsel *tmp;
+ int idx = 0;
+
+ evlist__for_each_entry_safe(evlist, tmp, pos) {
+ if (pos->skippable)
+ evlist__remove(evlist, pos);
+ }
+ evlist__for_each_entry(evlist, pos) {
+ pos->core.idx = idx++;
+ }
+ if (idx == 0 || (idx == 1 && rec->dummy_event_added)) {
+ ui__error("Failure to open any events for recording.\n");
+ rc = -1;
+ goto out;
+ }
+ }
if (symbol_conf.kptr_restrict && !evlist__exclude_kernel(evlist)) {
pr_warning(
"WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted,\n"