|
@@ -29,6 +29,7 @@ static struct {
|
|
bool sample_id_all;
|
|
bool sample_id_all;
|
|
bool exclude_guest;
|
|
bool exclude_guest;
|
|
bool mmap2;
|
|
bool mmap2;
|
|
|
|
+ bool cloexec;
|
|
} perf_missing_features;
|
|
} perf_missing_features;
|
|
|
|
|
|
#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
|
|
#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
|
|
@@ -994,7 +995,7 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
|
|
struct thread_map *threads)
|
|
struct thread_map *threads)
|
|
{
|
|
{
|
|
int cpu, thread;
|
|
int cpu, thread;
|
|
- unsigned long flags = 0;
|
|
|
|
|
|
+ unsigned long flags = PERF_FLAG_FD_CLOEXEC;
|
|
int pid = -1, err;
|
|
int pid = -1, err;
|
|
enum { NO_CHANGE, SET_TO_MAX, INCREASED_MAX } set_rlimit = NO_CHANGE;
|
|
enum { NO_CHANGE, SET_TO_MAX, INCREASED_MAX } set_rlimit = NO_CHANGE;
|
|
|
|
|
|
@@ -1003,11 +1004,13 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
if (evsel->cgrp) {
|
|
if (evsel->cgrp) {
|
|
- flags = PERF_FLAG_PID_CGROUP;
|
|
|
|
|
|
+ flags |= PERF_FLAG_PID_CGROUP;
|
|
pid = evsel->cgrp->fd;
|
|
pid = evsel->cgrp->fd;
|
|
}
|
|
}
|
|
|
|
|
|
fallback_missing_features:
|
|
fallback_missing_features:
|
|
|
|
+ if (perf_missing_features.cloexec)
|
|
|
|
+ flags &= ~(unsigned long)PERF_FLAG_FD_CLOEXEC;
|
|
if (perf_missing_features.mmap2)
|
|
if (perf_missing_features.mmap2)
|
|
evsel->attr.mmap2 = 0;
|
|
evsel->attr.mmap2 = 0;
|
|
if (perf_missing_features.exclude_guest)
|
|
if (perf_missing_features.exclude_guest)
|
|
@@ -1076,7 +1079,10 @@ try_fallback:
|
|
if (err != -EINVAL || cpu > 0 || thread > 0)
|
|
if (err != -EINVAL || cpu > 0 || thread > 0)
|
|
goto out_close;
|
|
goto out_close;
|
|
|
|
|
|
- if (!perf_missing_features.mmap2 && evsel->attr.mmap2) {
|
|
|
|
|
|
+ if (!perf_missing_features.cloexec && (flags & PERF_FLAG_FD_CLOEXEC)) {
|
|
|
|
+ perf_missing_features.cloexec = true;
|
|
|
|
+ goto fallback_missing_features;
|
|
|
|
+ } else if (!perf_missing_features.mmap2 && evsel->attr.mmap2) {
|
|
perf_missing_features.mmap2 = true;
|
|
perf_missing_features.mmap2 = true;
|
|
goto fallback_missing_features;
|
|
goto fallback_missing_features;
|
|
} else if (!perf_missing_features.exclude_guest &&
|
|
} else if (!perf_missing_features.exclude_guest &&
|