aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-07-25 10:06:19 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-07-25 10:06:19 -0400
commit4152ab377b55e9d3e5700de00ef799519ead698d (patch)
treef0b01d51b9efe519ecbc9827bf1116de2a2317c3 /tools
parent4f9bae351d299149a84f76cd34bf0150614e8c8e (diff)
perf evlist: Introduce 'disable' method
To remove the last case of access to the FD() macro outside the library. Inspired by a patch by Borislav that moved the FD() macro to util.h, for namespace concerns I rather preferred to constrain it to ev{sel,list}.c. Cc: Borislav Petkov <bp@amd64.org> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> 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-qn893qsstcg366tkucu649qj@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-record.c19
-rw-r--r--tools/perf/util/evlist.c13
-rw-r--r--tools/perf/util/evlist.h2
3 files changed, 17 insertions, 17 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 80dc5b790e47..f6426b496f4a 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -30,8 +30,6 @@
30#include <sched.h> 30#include <sched.h>
31#include <sys/mman.h> 31#include <sys/mman.h>
32 32
33#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
34
35enum write_mode_t { 33enum write_mode_t {
36 WRITE_FORCE, 34 WRITE_FORCE,
37 WRITE_APPEND 35 WRITE_APPEND
@@ -438,7 +436,6 @@ static void mmap_read_all(void)
438 436
439static int __cmd_record(int argc, const char **argv) 437static int __cmd_record(int argc, const char **argv)
440{ 438{
441 int i;
442 struct stat st; 439 struct stat st;
443 int flags; 440 int flags;
444 int err; 441 int err;
@@ -682,7 +679,6 @@ static int __cmd_record(int argc, const char **argv)
682 679
683 for (;;) { 680 for (;;) {
684 int hits = samples; 681 int hits = samples;
685 int thread;
686 682
687 mmap_read_all(); 683 mmap_read_all();
688 684
@@ -693,19 +689,8 @@ static int __cmd_record(int argc, const char **argv)
693 waking++; 689 waking++;
694 } 690 }
695 691
696 if (done) { 692 if (done)
697 for (i = 0; i < evsel_list->cpus->nr; i++) { 693 perf_evlist__disable(evsel_list);
698 struct perf_evsel *pos;
699
700 list_for_each_entry(pos, &evsel_list->entries, node) {
701 for (thread = 0;
702 thread < evsel_list->threads->nr;
703 thread++)
704 ioctl(FD(pos, i, thread),
705 PERF_EVENT_IOC_DISABLE);
706 }
707 }
708 }
709 } 694 }
710 695
711 if (quiet || signr == SIGUSR1) 696 if (quiet || signr == SIGUSR1)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index b021ea9265c3..e03e7bc8205e 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -91,6 +91,19 @@ int perf_evlist__add_default(struct perf_evlist *evlist)
91 return 0; 91 return 0;
92} 92}
93 93
94void perf_evlist__disable(struct perf_evlist *evlist)
95{
96 int cpu, thread;
97 struct perf_evsel *pos;
98
99 for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
100 list_for_each_entry(pos, &evlist->entries, node) {
101 for (thread = 0; thread < evlist->threads->nr; thread++)
102 ioctl(FD(pos, cpu, thread), PERF_EVENT_IOC_DISABLE);
103 }
104 }
105}
106
94int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) 107int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
95{ 108{
96 int nfds = evlist->cpus->nr * evlist->threads->nr * evlist->nr_entries; 109 int nfds = evlist->cpus->nr * evlist->threads->nr * evlist->nr_entries;
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index b2b862374f37..ce85ae9ae57a 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -53,6 +53,8 @@ int perf_evlist__alloc_mmap(struct perf_evlist *evlist);
53int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite); 53int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite);
54void perf_evlist__munmap(struct perf_evlist *evlist); 54void perf_evlist__munmap(struct perf_evlist *evlist);
55 55
56void perf_evlist__disable(struct perf_evlist *evlist);
57
56static inline void perf_evlist__set_maps(struct perf_evlist *evlist, 58static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
57 struct cpu_map *cpus, 59 struct cpu_map *cpus,
58 struct thread_map *threads) 60 struct thread_map *threads)