aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-01-03 14:49:48 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-01-03 21:23:55 -0500
commit60d567e2d9187379d642f6aba7c8a52b3fd5d261 (patch)
tree7d6bd6f6805ff68f4fab3c0e08b7139cc5206b7d /tools/perf/builtin-top.c
parent48290609c0d265f5dac0fca6fd4e3c5732542f67 (diff)
perf tools: Refactor cpumap to hold nr and the map
So that later, we can pass the cpu_map instance instead of (nr_cpus, cpu_map) for things like perf_evsel__open and friends. 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> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 27b9c14a0a07..0e426665716d 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -71,7 +71,7 @@ static int target_tid = -1;
71static pid_t *all_tids = NULL; 71static pid_t *all_tids = NULL;
72static int thread_num = 0; 72static int thread_num = 0;
73static bool inherit = false; 73static bool inherit = false;
74static int nr_cpus = 0; 74static struct cpu_map *cpus;
75static int realtime_prio = 0; 75static int realtime_prio = 0;
76static bool group = false; 76static bool group = false;
77static unsigned int page_size; 77static unsigned int page_size;
@@ -564,12 +564,12 @@ static void print_sym_table(void)
564 printf(" (all"); 564 printf(" (all");
565 565
566 if (cpu_list) 566 if (cpu_list)
567 printf(", CPU%s: %s)\n", nr_cpus > 1 ? "s" : "", cpu_list); 567 printf(", CPU%s: %s)\n", cpus->nr > 1 ? "s" : "", cpu_list);
568 else { 568 else {
569 if (target_tid != -1) 569 if (target_tid != -1)
570 printf(")\n"); 570 printf(")\n");
571 else 571 else
572 printf(", %d CPU%s)\n", nr_cpus, nr_cpus > 1 ? "s" : ""); 572 printf(", %d CPU%s)\n", cpus->nr, cpus->nr > 1 ? "s" : "");
573 } 573 }
574 574
575 printf("%-*.*s\n", win_width, win_width, graph_dotted_line); 575 printf("%-*.*s\n", win_width, win_width, graph_dotted_line);
@@ -1197,7 +1197,7 @@ static void perf_session__mmap_read(struct perf_session *self)
1197 struct perf_evsel *counter; 1197 struct perf_evsel *counter;
1198 int i, thread_index; 1198 int i, thread_index;
1199 1199
1200 for (i = 0; i < nr_cpus; i++) { 1200 for (i = 0; i < cpus->nr; i++) {
1201 list_for_each_entry(counter, &evsel_list, node) { 1201 list_for_each_entry(counter, &evsel_list, node) {
1202 for (thread_index = 0; 1202 for (thread_index = 0;
1203 thread_index < thread_num; 1203 thread_index < thread_num;
@@ -1221,7 +1221,7 @@ static void start_counter(int i, struct perf_evsel *evsel)
1221 int thread_index; 1221 int thread_index;
1222 1222
1223 if (target_tid == -1) 1223 if (target_tid == -1)
1224 cpu = cpumap[i]; 1224 cpu = cpus->map[i];
1225 1225
1226 attr = &evsel->attr; 1226 attr = &evsel->attr;
1227 1227
@@ -1310,7 +1310,7 @@ static int __cmd_top(void)
1310 else 1310 else
1311 event__synthesize_threads(event__process, session); 1311 event__synthesize_threads(event__process, session);
1312 1312
1313 for (i = 0; i < nr_cpus; i++) { 1313 for (i = 0; i < cpus->nr; i++) {
1314 group_fd = -1; 1314 group_fd = -1;
1315 list_for_each_entry(counter, &evsel_list, node) 1315 list_for_each_entry(counter, &evsel_list, node)
1316 start_counter(i, counter); 1316 start_counter(i, counter);
@@ -1460,16 +1460,16 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1460 } 1460 }
1461 1461
1462 if (target_tid != -1) 1462 if (target_tid != -1)
1463 nr_cpus = 1; 1463 cpus = cpu_map__dummy_new();
1464 else 1464 else
1465 nr_cpus = read_cpu_map(cpu_list); 1465 cpus = cpu_map__new(cpu_list);
1466 1466
1467 if (nr_cpus < 1) 1467 if (cpus == NULL)
1468 usage_with_options(top_usage, options); 1468 usage_with_options(top_usage, options);
1469 1469
1470 list_for_each_entry(pos, &evsel_list, node) { 1470 list_for_each_entry(pos, &evsel_list, node) {
1471 if (perf_evsel__alloc_mmap_per_thread(pos, nr_cpus, thread_num) < 0 || 1471 if (perf_evsel__alloc_mmap_per_thread(pos, cpus->nr, thread_num) < 0 ||
1472 perf_evsel__alloc_fd(pos, nr_cpus, thread_num) < 0) 1472 perf_evsel__alloc_fd(pos, cpus->nr, thread_num) < 0)
1473 goto out_free_fd; 1473 goto out_free_fd;
1474 /* 1474 /*
1475 * Fill in the ones not specifically initialized via -c: 1475 * Fill in the ones not specifically initialized via -c: