diff options
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r-- | tools/perf/builtin-record.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 79f99dba5be0..5f3127e7a615 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -49,6 +49,7 @@ static int inherit_stat = 0; | |||
49 | static int no_samples = 0; | 49 | static int no_samples = 0; |
50 | static int sample_address = 0; | 50 | static int sample_address = 0; |
51 | static int multiplex = 0; | 51 | static int multiplex = 0; |
52 | static int multiplex_fd = -1; | ||
52 | 53 | ||
53 | static long samples; | 54 | static long samples; |
54 | static struct timeval last_read; | 55 | static struct timeval last_read; |
@@ -471,23 +472,29 @@ try_again: | |||
471 | */ | 472 | */ |
472 | if (group && group_fd == -1) | 473 | if (group && group_fd == -1) |
473 | group_fd = fd[nr_cpu][counter]; | 474 | group_fd = fd[nr_cpu][counter]; |
475 | if (multiplex && multiplex_fd == -1) | ||
476 | multiplex_fd = fd[nr_cpu][counter]; | ||
474 | 477 | ||
475 | event_array[nr_poll].fd = fd[nr_cpu][counter]; | 478 | if (multiplex && fd[nr_cpu][counter] != multiplex_fd) { |
476 | event_array[nr_poll].events = POLLIN; | 479 | int ret; |
477 | nr_poll++; | ||
478 | |||
479 | mmap_array[nr_cpu][counter].counter = counter; | ||
480 | mmap_array[nr_cpu][counter].prev = 0; | ||
481 | mmap_array[nr_cpu][counter].mask = mmap_pages*page_size - 1; | ||
482 | mmap_array[nr_cpu][counter].base = mmap(NULL, (mmap_pages+1)*page_size, | ||
483 | PROT_READ|PROT_WRITE, MAP_SHARED, fd[nr_cpu][counter], 0); | ||
484 | if (mmap_array[nr_cpu][counter].base == MAP_FAILED) { | ||
485 | error("failed to mmap with %d (%s)\n", errno, strerror(errno)); | ||
486 | exit(-1); | ||
487 | } | ||
488 | 480 | ||
489 | if (multiplex && fd[nr_cpu][counter] != group_fd) | 481 | ret = ioctl(fd[nr_cpu][counter], PERF_COUNTER_IOC_SET_OUTPUT, multiplex_fd); |
490 | ioctl(fd[nr_cpu][counter], PERF_COUNTER_IOC_SET_OUTPUT, group_fd); | 482 | assert(ret != -1); |
483 | } else { | ||
484 | event_array[nr_poll].fd = fd[nr_cpu][counter]; | ||
485 | event_array[nr_poll].events = POLLIN; | ||
486 | nr_poll++; | ||
487 | |||
488 | mmap_array[nr_cpu][counter].counter = counter; | ||
489 | mmap_array[nr_cpu][counter].prev = 0; | ||
490 | mmap_array[nr_cpu][counter].mask = mmap_pages*page_size - 1; | ||
491 | mmap_array[nr_cpu][counter].base = mmap(NULL, (mmap_pages+1)*page_size, | ||
492 | PROT_READ|PROT_WRITE, MAP_SHARED, fd[nr_cpu][counter], 0); | ||
493 | if (mmap_array[nr_cpu][counter].base == MAP_FAILED) { | ||
494 | error("failed to mmap with %d (%s)\n", errno, strerror(errno)); | ||
495 | exit(-1); | ||
496 | } | ||
497 | } | ||
491 | 498 | ||
492 | ioctl(fd[nr_cpu][counter], PERF_COUNTER_IOC_ENABLE); | 499 | ioctl(fd[nr_cpu][counter], PERF_COUNTER_IOC_ENABLE); |
493 | } | 500 | } |
@@ -618,8 +625,10 @@ static int __cmd_record(int argc, const char **argv) | |||
618 | int hits = samples; | 625 | int hits = samples; |
619 | 626 | ||
620 | for (i = 0; i < nr_cpu; i++) { | 627 | for (i = 0; i < nr_cpu; i++) { |
621 | for (counter = 0; counter < nr_counters; counter++) | 628 | for (counter = 0; counter < nr_counters; counter++) { |
622 | mmap_read(&mmap_array[i][counter]); | 629 | if (mmap_array[i][counter].base) |
630 | mmap_read(&mmap_array[i][counter]); | ||
631 | } | ||
623 | } | 632 | } |
624 | 633 | ||
625 | if (hits == samples) { | 634 | if (hits == samples) { |