aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-12-03 04:06:42 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-12-07 16:12:58 -0500
commit3e27c92081131738fa4d7dd71673aa6e8c24866d (patch)
tree559c5bf5d76d3d71bc5316a7e6e7c9fc74d87109
parente98a4cbb01e0ba1110eba5166a425b3eab9b2244 (diff)
perf evlist: Factor perf_evlist__(enable|disable) functions
Use perf_evsel__(enable|disable) functions in perf_evlist__(enable|disable) functions in order to centralize ioctl enable/disable calls. This way we eliminate 2 places calling directly ioctl. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1449133606-14429-4-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/evlist.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d1392194a9a9..d1b6c206bb93 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -336,20 +336,12 @@ static int perf_evlist__nr_threads(struct perf_evlist *evlist,
336 336
337void perf_evlist__disable(struct perf_evlist *evlist) 337void perf_evlist__disable(struct perf_evlist *evlist)
338{ 338{
339 int cpu, thread;
340 struct perf_evsel *pos; 339 struct perf_evsel *pos;
341 int nr_cpus = cpu_map__nr(evlist->cpus);
342 int nr_threads;
343 340
344 for (cpu = 0; cpu < nr_cpus; cpu++) { 341 evlist__for_each(evlist, pos) {
345 evlist__for_each(evlist, pos) { 342 if (!perf_evsel__is_group_leader(pos) || !pos->fd)
346 if (!perf_evsel__is_group_leader(pos) || !pos->fd) 343 continue;
347 continue; 344 perf_evsel__disable(pos);
348 nr_threads = perf_evlist__nr_threads(evlist, pos);
349 for (thread = 0; thread < nr_threads; thread++)
350 ioctl(FD(pos, cpu, thread),
351 PERF_EVENT_IOC_DISABLE, 0);
352 }
353 } 345 }
354 346
355 evlist->enabled = false; 347 evlist->enabled = false;
@@ -357,20 +349,12 @@ void perf_evlist__disable(struct perf_evlist *evlist)
357 349
358void perf_evlist__enable(struct perf_evlist *evlist) 350void perf_evlist__enable(struct perf_evlist *evlist)
359{ 351{
360 int cpu, thread;
361 struct perf_evsel *pos; 352 struct perf_evsel *pos;
362 int nr_cpus = cpu_map__nr(evlist->cpus);
363 int nr_threads;
364 353
365 for (cpu = 0; cpu < nr_cpus; cpu++) { 354 evlist__for_each(evlist, pos) {
366 evlist__for_each(evlist, pos) { 355 if (!perf_evsel__is_group_leader(pos) || !pos->fd)
367 if (!perf_evsel__is_group_leader(pos) || !pos->fd) 356 continue;
368 continue; 357 perf_evsel__enable(pos);
369 nr_threads = perf_evlist__nr_threads(evlist, pos);
370 for (thread = 0; thread < nr_threads; thread++)
371 ioctl(FD(pos, cpu, thread),
372 PERF_EVENT_IOC_ENABLE, 0);
373 }
374 } 358 }
375 359
376 evlist->enabled = true; 360 evlist->enabled = true;