|
@@ -1599,10 +1599,46 @@ static int __open_attr__fprintf(FILE *fp, const char *name, const char *val,
|
|
|
return fprintf(fp, " %-32s %s\n", name, val);
|
|
|
}
|
|
|
|
|
|
+static void perf_evsel__remove_fd(struct perf_evsel *pos,
|
|
|
+ int nr_cpus, int nr_threads,
|
|
|
+ int thread_idx)
|
|
|
+{
|
|
|
+ for (int cpu = 0; cpu < nr_cpus; cpu++)
|
|
|
+ for (int thread = thread_idx; thread < nr_threads - 1; thread++)
|
|
|
+ FD(pos, cpu, thread) = FD(pos, cpu, thread + 1);
|
|
|
+}
|
|
|
+
|
|
|
+static int update_fds(struct perf_evsel *evsel,
|
|
|
+ int nr_cpus, int cpu_idx,
|
|
|
+ int nr_threads, int thread_idx)
|
|
|
+{
|
|
|
+ struct perf_evsel *pos;
|
|
|
+
|
|
|
+ if (cpu_idx >= nr_cpus || thread_idx >= nr_threads)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ evlist__for_each_entry(evsel->evlist, pos) {
|
|
|
+ nr_cpus = pos != evsel ? nr_cpus : cpu_idx;
|
|
|
+
|
|
|
+ perf_evsel__remove_fd(pos, nr_cpus, nr_threads, thread_idx);
|
|
|
+
|
|
|
+ /*
|
|
|
+ * Since fds for next evsel has not been created,
|
|
|
+ * there is no need to iterate whole event list.
|
|
|
+ */
|
|
|
+ if (pos == evsel)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
static bool ignore_missing_thread(struct perf_evsel *evsel,
|
|
|
+ int nr_cpus, int cpu,
|
|
|
struct thread_map *threads,
|
|
|
int thread, int err)
|
|
|
{
|
|
|
+ pid_t ignore_pid = thread_map__pid(threads, thread);
|
|
|
+
|
|
|
if (!evsel->ignore_missing_thread)
|
|
|
return false;
|
|
|
|
|
@@ -1618,11 +1654,18 @@ static bool ignore_missing_thread(struct perf_evsel *evsel,
|
|
|
if (threads->nr == 1)
|
|
|
return false;
|
|
|
|
|
|
+ /*
|
|
|
+ * We should remove fd for missing_thread first
|
|
|
+ * because thread_map__remove() will decrease threads->nr.
|
|
|
+ */
|
|
|
+ if (update_fds(evsel, nr_cpus, cpu, threads->nr, thread))
|
|
|
+ return false;
|
|
|
+
|
|
|
if (thread_map__remove(threads, thread))
|
|
|
return false;
|
|
|
|
|
|
pr_warning("WARNING: Ignored open failure for pid %d\n",
|
|
|
- thread_map__pid(threads, thread));
|
|
|
+ ignore_pid);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -1727,7 +1770,7 @@ retry_open:
|
|
|
if (fd < 0) {
|
|
|
err = -errno;
|
|
|
|
|
|
- if (ignore_missing_thread(evsel, threads, thread, err)) {
|
|
|
+ if (ignore_missing_thread(evsel, cpus->nr, cpu, threads, thread, err)) {
|
|
|
/*
|
|
|
* We just removed 1 thread, so take a step
|
|
|
* back on thread index and lower the upper
|