|
@@ -128,7 +128,7 @@ int __perf_evsel__read(struct perf_evsel *evsel,
|
|
}
|
|
}
|
|
|
|
|
|
static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
|
|
static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
|
|
- struct thread_map *threads)
|
|
|
|
|
|
+ struct thread_map *threads, bool group)
|
|
{
|
|
{
|
|
int cpu, thread;
|
|
int cpu, thread;
|
|
|
|
|
|
@@ -137,12 +137,18 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
for (cpu = 0; cpu < cpus->nr; cpu++) {
|
|
for (cpu = 0; cpu < cpus->nr; cpu++) {
|
|
|
|
+ int group_fd = -1;
|
|
|
|
+
|
|
for (thread = 0; thread < threads->nr; thread++) {
|
|
for (thread = 0; thread < threads->nr; thread++) {
|
|
FD(evsel, cpu, thread) = sys_perf_event_open(&evsel->attr,
|
|
FD(evsel, cpu, thread) = sys_perf_event_open(&evsel->attr,
|
|
threads->map[thread],
|
|
threads->map[thread],
|
|
- cpus->map[cpu], -1, 0);
|
|
|
|
|
|
+ cpus->map[cpu],
|
|
|
|
+ group_fd, 0);
|
|
if (FD(evsel, cpu, thread) < 0)
|
|
if (FD(evsel, cpu, thread) < 0)
|
|
goto out_close;
|
|
goto out_close;
|
|
|
|
+
|
|
|
|
+ if (group && group_fd == -1)
|
|
|
|
+ group_fd = FD(evsel, cpu, thread);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -175,10 +181,9 @@ static struct {
|
|
.threads = { -1, },
|
|
.threads = { -1, },
|
|
};
|
|
};
|
|
|
|
|
|
-int perf_evsel__open(struct perf_evsel *evsel,
|
|
|
|
- struct cpu_map *cpus, struct thread_map *threads)
|
|
|
|
|
|
+int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
|
|
|
|
+ struct thread_map *threads, bool group)
|
|
{
|
|
{
|
|
-
|
|
|
|
if (cpus == NULL) {
|
|
if (cpus == NULL) {
|
|
/* Work around old compiler warnings about strict aliasing */
|
|
/* Work around old compiler warnings about strict aliasing */
|
|
cpus = &empty_cpu_map.map;
|
|
cpus = &empty_cpu_map.map;
|
|
@@ -187,15 +192,17 @@ int perf_evsel__open(struct perf_evsel *evsel,
|
|
if (threads == NULL)
|
|
if (threads == NULL)
|
|
threads = &empty_thread_map.map;
|
|
threads = &empty_thread_map.map;
|
|
|
|
|
|
- return __perf_evsel__open(evsel, cpus, threads);
|
|
|
|
|
|
+ return __perf_evsel__open(evsel, cpus, threads, group);
|
|
}
|
|
}
|
|
|
|
|
|
-int perf_evsel__open_per_cpu(struct perf_evsel *evsel, struct cpu_map *cpus)
|
|
|
|
|
|
+int perf_evsel__open_per_cpu(struct perf_evsel *evsel,
|
|
|
|
+ struct cpu_map *cpus, bool group)
|
|
{
|
|
{
|
|
- return __perf_evsel__open(evsel, cpus, &empty_thread_map.map);
|
|
|
|
|
|
+ return __perf_evsel__open(evsel, cpus, &empty_thread_map.map, group);
|
|
}
|
|
}
|
|
|
|
|
|
-int perf_evsel__open_per_thread(struct perf_evsel *evsel, struct thread_map *threads)
|
|
|
|
|
|
+int perf_evsel__open_per_thread(struct perf_evsel *evsel,
|
|
|
|
+ struct thread_map *threads, bool group)
|
|
{
|
|
{
|
|
- return __perf_evsel__open(evsel, &empty_cpu_map.map, threads);
|
|
|
|
|
|
+ return __perf_evsel__open(evsel, &empty_cpu_map.map, threads, group);
|
|
}
|
|
}
|