aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/evlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/evlist.c')
-rw-r--r--tools/perf/util/evlist.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 3cebc9a8d52e..3c9e77d6b4c2 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1003,6 +1003,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
1003 1003
1004out_delete_threads: 1004out_delete_threads:
1005 thread_map__delete(evlist->threads); 1005 thread_map__delete(evlist->threads);
1006 evlist->threads = NULL;
1006 return -1; 1007 return -1;
1007} 1008}
1008 1009
@@ -1175,11 +1176,51 @@ void perf_evlist__close(struct perf_evlist *evlist)
1175 } 1176 }
1176} 1177}
1177 1178
1179static int perf_evlist__create_syswide_maps(struct perf_evlist *evlist)
1180{
1181 int err = -ENOMEM;
1182
1183 /*
1184 * Try reading /sys/devices/system/cpu/online to get
1185 * an all cpus map.
1186 *
1187 * FIXME: -ENOMEM is the best we can do here, the cpu_map
1188 * code needs an overhaul to properly forward the
1189 * error, and we may not want to do that fallback to a
1190 * default cpu identity map :-\
1191 */
1192 evlist->cpus = cpu_map__new(NULL);
1193 if (evlist->cpus == NULL)
1194 goto out;
1195
1196 evlist->threads = thread_map__new_dummy();
1197 if (evlist->threads == NULL)
1198 goto out_free_cpus;
1199
1200 err = 0;
1201out:
1202 return err;
1203out_free_cpus:
1204 cpu_map__delete(evlist->cpus);
1205 evlist->cpus = NULL;
1206 goto out;
1207}
1208
1178int perf_evlist__open(struct perf_evlist *evlist) 1209int perf_evlist__open(struct perf_evlist *evlist)
1179{ 1210{
1180 struct perf_evsel *evsel; 1211 struct perf_evsel *evsel;
1181 int err; 1212 int err;
1182 1213
1214 /*
1215 * Default: one fd per CPU, all threads, aka systemwide
1216 * as sys_perf_event_open(cpu = -1, thread = -1) is EINVAL
1217 */
1218 if (evlist->threads == NULL && evlist->cpus == NULL) {
1219 err = perf_evlist__create_syswide_maps(evlist);
1220 if (err < 0)
1221 goto out_err;
1222 }
1223
1183 perf_evlist__update_id_pos(evlist); 1224 perf_evlist__update_id_pos(evlist);
1184 1225
1185 evlist__for_each(evlist, evsel) { 1226 evlist__for_each(evlist, evsel) {
@@ -1276,8 +1317,14 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist, struct target *tar
1276 sigaction(SIGUSR1, &act, NULL); 1317 sigaction(SIGUSR1, &act, NULL);
1277 } 1318 }
1278 1319
1279 if (target__none(target)) 1320 if (target__none(target)) {
1321 if (evlist->threads == NULL) {
1322 fprintf(stderr, "FATAL: evlist->threads need to be set at this point (%s:%d).\n",
1323 __func__, __LINE__);
1324 goto out_close_pipes;
1325 }
1280 evlist->threads->map[0] = evlist->workload.pid; 1326 evlist->threads->map[0] = evlist->workload.pid;
1327 }
1281 1328
1282 close(child_ready_pipe[1]); 1329 close(child_ready_pipe[1]);
1283 close(go_pipe[0]); 1330 close(go_pipe[0]);