aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-record.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-01-11 19:30:02 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-01-22 16:56:28 -0500
commit5c581041cf97aa7980b442de81ddea8273d6dcde (patch)
treeceb2f13de102215d151adf7aaab975bd0db6076b /tools/perf/builtin-record.c
parent361c99a661a78ed22264649440e87fe4fe8da1f2 (diff)
perf evlist: Adopt the pollfd array
Allocating just the space needed for nr_cpus * nr_threads * nr_evsels, not the MAX_NR_CPUS and counters. LKML-Reference: <new-submission> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r--tools/perf/builtin-record.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 252ace873d32..1614d89b4765 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -72,9 +72,6 @@ static struct perf_evlist *evsel_list;
72static long samples = 0; 72static long samples = 0;
73static u64 bytes_written = 0; 73static u64 bytes_written = 0;
74 74
75static struct pollfd *event_array;
76
77static int nr_poll = 0;
78static int nr_cpu = 0; 75static int nr_cpu = 0;
79 76
80static int file_new = 1; 77static int file_new = 1;
@@ -432,9 +429,9 @@ try_again:
432 exit(-1); 429 exit(-1);
433 } 430 }
434 431
435 event_array[nr_poll].fd = FD(evsel, nr_cpu, thread_index); 432 evlist->pollfd[evlist->nr_fds].fd = FD(evsel, nr_cpu, thread_index);
436 event_array[nr_poll].events = POLLIN; 433 evlist->pollfd[evlist->nr_fds].events = POLLIN;
437 nr_poll++; 434 evlist->nr_fds++;
438 } 435 }
439 436
440 if (filter != NULL) { 437 if (filter != NULL) {
@@ -793,7 +790,7 @@ static int __cmd_record(int argc, const char **argv)
793 if (hits == samples) { 790 if (hits == samples) {
794 if (done) 791 if (done)
795 break; 792 break;
796 err = poll(event_array, nr_poll, -1); 793 err = poll(evsel_list->pollfd, evsel_list->nr_fds, -1);
797 waking++; 794 waking++;
798 } 795 }
799 796
@@ -948,9 +945,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
948 if (perf_header__push_event(pos->attr.config, event_name(pos))) 945 if (perf_header__push_event(pos->attr.config, event_name(pos)))
949 goto out_free_fd; 946 goto out_free_fd;
950 } 947 }
951 event_array = malloc((sizeof(struct pollfd) * MAX_NR_CPUS * 948
952 MAX_COUNTERS * threads->nr)); 949 if (perf_evlist__alloc_pollfd(evsel_list, cpus->nr, threads->nr) < 0)
953 if (!event_array)
954 goto out_free_fd; 950 goto out_free_fd;
955 951
956 if (user_interval != ULLONG_MAX) 952 if (user_interval != ULLONG_MAX)
@@ -968,13 +964,11 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
968 } else { 964 } else {
969 fprintf(stderr, "frequency and count are zero, aborting\n"); 965 fprintf(stderr, "frequency and count are zero, aborting\n");
970 err = -EINVAL; 966 err = -EINVAL;
971 goto out_free_event_array; 967 goto out_free_fd;
972 } 968 }
973 969
974 err = __cmd_record(argc, argv); 970 err = __cmd_record(argc, argv);
975 971
976out_free_event_array:
977 free(event_array);
978out_free_fd: 972out_free_fd:
979 thread_map__delete(threads); 973 thread_map__delete(threads);
980 threads = NULL; 974 threads = NULL;