diff options
-rw-r--r-- | tools/perf/util/evsel.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index e44be528c09f..c95267e63c5b 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -66,6 +66,9 @@ int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, | |||
66 | if (FD(evsel, cpu, thread) < 0) | 66 | if (FD(evsel, cpu, thread) < 0) |
67 | return -EINVAL; | 67 | return -EINVAL; |
68 | 68 | ||
69 | if (evsel->counts == NULL && perf_evsel__alloc_counts(evsel, cpu + 1) < 0) | ||
70 | return -ENOMEM; | ||
71 | |||
69 | if (readn(FD(evsel, cpu, thread), &count, nv * sizeof(u64)) < 0) | 72 | if (readn(FD(evsel, cpu, thread), &count, nv * sizeof(u64)) < 0) |
70 | return -errno; | 73 | return -errno; |
71 | 74 | ||
@@ -129,6 +132,9 @@ int perf_evsel__open_per_cpu(struct perf_evsel *evsel, struct cpu_map *cpus) | |||
129 | { | 132 | { |
130 | int cpu; | 133 | int cpu; |
131 | 134 | ||
135 | if (evsel->fd == NULL && perf_evsel__alloc_fd(evsel, cpus->nr, 1) < 0) | ||
136 | return -1; | ||
137 | |||
132 | for (cpu = 0; cpu < cpus->nr; cpu++) { | 138 | for (cpu = 0; cpu < cpus->nr; cpu++) { |
133 | FD(evsel, cpu, 0) = sys_perf_event_open(&evsel->attr, -1, | 139 | FD(evsel, cpu, 0) = sys_perf_event_open(&evsel->attr, -1, |
134 | cpus->map[cpu], -1, 0); | 140 | cpus->map[cpu], -1, 0); |
@@ -150,6 +156,9 @@ int perf_evsel__open_per_thread(struct perf_evsel *evsel, struct thread_map *thr | |||
150 | { | 156 | { |
151 | int thread; | 157 | int thread; |
152 | 158 | ||
159 | if (evsel->fd == NULL && perf_evsel__alloc_fd(evsel, 1, threads->nr)) | ||
160 | return -1; | ||
161 | |||
153 | for (thread = 0; thread < threads->nr; thread++) { | 162 | for (thread = 0; thread < threads->nr; thread++) { |
154 | FD(evsel, 0, thread) = sys_perf_event_open(&evsel->attr, | 163 | FD(evsel, 0, thread) = sys_perf_event_open(&evsel->attr, |
155 | threads->map[thread], -1, -1, 0); | 164 | threads->map[thread], -1, -1, 0); |