diff options
Diffstat (limited to 'tools/perf/util/evlist.c')
-rw-r--r-- | tools/perf/util/evlist.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 5fc7bd42c803..b4b54d84e9b0 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -1175,11 +1175,51 @@ void perf_evlist__close(struct perf_evlist *evlist) | |||
1175 | } | 1175 | } |
1176 | } | 1176 | } |
1177 | 1177 | ||
1178 | static int perf_evlist__create_syswide_maps(struct perf_evlist *evlist) | ||
1179 | { | ||
1180 | int err = -ENOMEM; | ||
1181 | |||
1182 | /* | ||
1183 | * Try reading /sys/devices/system/cpu/online to get | ||
1184 | * an all cpus map. | ||
1185 | * | ||
1186 | * FIXME: -ENOMEM is the best we can do here, the cpu_map | ||
1187 | * code needs an overhaul to properly forward the | ||
1188 | * error, and we may not want to do that fallback to a | ||
1189 | * default cpu identity map :-\ | ||
1190 | */ | ||
1191 | evlist->cpus = cpu_map__new(NULL); | ||
1192 | if (evlist->cpus == NULL) | ||
1193 | goto out; | ||
1194 | |||
1195 | evlist->threads = thread_map__new_dummy(); | ||
1196 | if (evlist->threads == NULL) | ||
1197 | goto out_free_cpus; | ||
1198 | |||
1199 | err = 0; | ||
1200 | out: | ||
1201 | return err; | ||
1202 | out_free_cpus: | ||
1203 | cpu_map__delete(evlist->cpus); | ||
1204 | evlist->cpus = NULL; | ||
1205 | goto out; | ||
1206 | } | ||
1207 | |||
1178 | int perf_evlist__open(struct perf_evlist *evlist) | 1208 | int perf_evlist__open(struct perf_evlist *evlist) |
1179 | { | 1209 | { |
1180 | struct perf_evsel *evsel; | 1210 | struct perf_evsel *evsel; |
1181 | int err; | 1211 | int err; |
1182 | 1212 | ||
1213 | /* | ||
1214 | * Default: one fd per CPU, all threads, aka systemwide | ||
1215 | * as sys_perf_event_open(cpu = -1, thread = -1) is EINVAL | ||
1216 | */ | ||
1217 | if (evlist->threads == NULL && evlist->cpus == NULL) { | ||
1218 | err = perf_evlist__create_syswide_maps(evlist); | ||
1219 | if (err < 0) | ||
1220 | goto out_err; | ||
1221 | } | ||
1222 | |||
1183 | perf_evlist__update_id_pos(evlist); | 1223 | perf_evlist__update_id_pos(evlist); |
1184 | 1224 | ||
1185 | evlist__for_each(evlist, evsel) { | 1225 | evlist__for_each(evlist, evsel) { |