aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2014-10-10 14:55:15 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-10-14 16:32:53 -0400
commit4112eb1899c0e711b2ab1491f51215359cf94d74 (patch)
tree652b1c4f26dd1238daa911d9ee331e68fd13da28 /tools
parent1aaf63b1ee912abd7675681f9d6ffaaf2ffc0451 (diff)
perf evlist: Default to syswide target when no thread/cpu maps set
If all a tool wants is to do system wide event monitoring, there is no more the need to setup thread_map and cpu_map objects, just call perf_evlist__open() and it will do create one fd per CPU monitoring all threads. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jean Pihet <jean.pihet@linaro.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-poovolkigu72brx4783uq4cf@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/evlist.c40
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
1178static 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;
1200out:
1201 return err;
1202out_free_cpus:
1203 cpu_map__delete(evlist->cpus);
1204 evlist->cpus = NULL;
1205 goto out;
1206}
1207
1178int perf_evlist__open(struct perf_evlist *evlist) 1208int 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) {