diff options
Diffstat (limited to 'tools/perf/builtin-record.c')
| -rw-r--r-- | tools/perf/builtin-record.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index a78db3f31b25..92ca5419073b 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
| @@ -29,7 +29,7 @@ | |||
| 29 | #include <sched.h> | 29 | #include <sched.h> |
| 30 | #include <sys/mman.h> | 30 | #include <sys/mman.h> |
| 31 | 31 | ||
| 32 | #ifndef HAVE_ON_EXIT | 32 | #ifndef HAVE_ON_EXIT_SUPPORT |
| 33 | #ifndef ATEXIT_MAX | 33 | #ifndef ATEXIT_MAX |
| 34 | #define ATEXIT_MAX 32 | 34 | #define ATEXIT_MAX 32 |
| 35 | #endif | 35 | #endif |
| @@ -70,7 +70,6 @@ struct perf_record { | |||
| 70 | struct perf_session *session; | 70 | struct perf_session *session; |
| 71 | const char *progname; | 71 | const char *progname; |
| 72 | int output; | 72 | int output; |
| 73 | unsigned int page_size; | ||
| 74 | int realtime_prio; | 73 | int realtime_prio; |
| 75 | bool no_buildid; | 74 | bool no_buildid; |
| 76 | bool no_buildid_cache; | 75 | bool no_buildid_cache; |
| @@ -119,7 +118,7 @@ static int perf_record__mmap_read(struct perf_record *rec, | |||
| 119 | { | 118 | { |
| 120 | unsigned int head = perf_mmap__read_head(md); | 119 | unsigned int head = perf_mmap__read_head(md); |
| 121 | unsigned int old = md->prev; | 120 | unsigned int old = md->prev; |
| 122 | unsigned char *data = md->base + rec->page_size; | 121 | unsigned char *data = md->base + page_size; |
| 123 | unsigned long size; | 122 | unsigned long size; |
| 124 | void *buf; | 123 | void *buf; |
| 125 | int rc = 0; | 124 | int rc = 0; |
| @@ -234,10 +233,6 @@ try_again: | |||
| 234 | "or try again with a smaller value of -m/--mmap_pages.\n" | 233 | "or try again with a smaller value of -m/--mmap_pages.\n" |
| 235 | "(current value: %d)\n", opts->mmap_pages); | 234 | "(current value: %d)\n", opts->mmap_pages); |
| 236 | rc = -errno; | 235 | rc = -errno; |
| 237 | } else if (!is_power_of_2(opts->mmap_pages) && | ||
| 238 | (opts->mmap_pages != UINT_MAX)) { | ||
| 239 | pr_err("--mmap_pages/-m value must be a power of two."); | ||
| 240 | rc = -EINVAL; | ||
| 241 | } else { | 236 | } else { |
| 242 | pr_err("failed to mmap with %d (%s)\n", errno, strerror(errno)); | 237 | pr_err("failed to mmap with %d (%s)\n", errno, strerror(errno)); |
| 243 | rc = -errno; | 238 | rc = -errno; |
| @@ -360,8 +355,6 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) | |||
| 360 | 355 | ||
| 361 | rec->progname = argv[0]; | 356 | rec->progname = argv[0]; |
| 362 | 357 | ||
| 363 | rec->page_size = sysconf(_SC_PAGE_SIZE); | ||
| 364 | |||
| 365 | on_exit(perf_record__sig_exit, rec); | 358 | on_exit(perf_record__sig_exit, rec); |
| 366 | signal(SIGCHLD, sig_handler); | 359 | signal(SIGCHLD, sig_handler); |
| 367 | signal(SIGINT, sig_handler); | 360 | signal(SIGINT, sig_handler); |
| @@ -687,7 +680,7 @@ error: | |||
| 687 | return ret; | 680 | return ret; |
| 688 | } | 681 | } |
| 689 | 682 | ||
| 690 | #ifdef LIBUNWIND_SUPPORT | 683 | #ifdef HAVE_LIBUNWIND_SUPPORT |
| 691 | static int get_stack_size(char *str, unsigned long *_size) | 684 | static int get_stack_size(char *str, unsigned long *_size) |
| 692 | { | 685 | { |
| 693 | char *endptr; | 686 | char *endptr; |
| @@ -713,7 +706,7 @@ static int get_stack_size(char *str, unsigned long *_size) | |||
| 713 | max_size, str); | 706 | max_size, str); |
| 714 | return -1; | 707 | return -1; |
| 715 | } | 708 | } |
| 716 | #endif /* LIBUNWIND_SUPPORT */ | 709 | #endif /* HAVE_LIBUNWIND_SUPPORT */ |
| 717 | 710 | ||
| 718 | int record_parse_callchain_opt(const struct option *opt, | 711 | int record_parse_callchain_opt(const struct option *opt, |
| 719 | const char *arg, int unset) | 712 | const char *arg, int unset) |
| @@ -751,7 +744,7 @@ int record_parse_callchain_opt(const struct option *opt, | |||
| 751 | "needed for -g fp\n"); | 744 | "needed for -g fp\n"); |
| 752 | break; | 745 | break; |
| 753 | 746 | ||
| 754 | #ifdef LIBUNWIND_SUPPORT | 747 | #ifdef HAVE_LIBUNWIND_SUPPORT |
| 755 | /* Dwarf style */ | 748 | /* Dwarf style */ |
| 756 | } else if (!strncmp(name, "dwarf", sizeof("dwarf"))) { | 749 | } else if (!strncmp(name, "dwarf", sizeof("dwarf"))) { |
| 757 | const unsigned long default_stack_dump_size = 8192; | 750 | const unsigned long default_stack_dump_size = 8192; |
| @@ -771,7 +764,7 @@ int record_parse_callchain_opt(const struct option *opt, | |||
| 771 | if (!ret) | 764 | if (!ret) |
| 772 | pr_debug("callchain: stack dump size %d\n", | 765 | pr_debug("callchain: stack dump size %d\n", |
| 773 | opts->stack_dump_size); | 766 | opts->stack_dump_size); |
| 774 | #endif /* LIBUNWIND_SUPPORT */ | 767 | #endif /* HAVE_LIBUNWIND_SUPPORT */ |
| 775 | } else { | 768 | } else { |
| 776 | pr_err("callchain: Unknown -g option " | 769 | pr_err("callchain: Unknown -g option " |
| 777 | "value: %s\n", arg); | 770 | "value: %s\n", arg); |
| @@ -818,7 +811,7 @@ static struct perf_record record = { | |||
| 818 | 811 | ||
| 819 | #define CALLCHAIN_HELP "do call-graph (stack chain/backtrace) recording: " | 812 | #define CALLCHAIN_HELP "do call-graph (stack chain/backtrace) recording: " |
| 820 | 813 | ||
| 821 | #ifdef LIBUNWIND_SUPPORT | 814 | #ifdef HAVE_LIBUNWIND_SUPPORT |
| 822 | const char record_callchain_help[] = CALLCHAIN_HELP "[fp] dwarf"; | 815 | const char record_callchain_help[] = CALLCHAIN_HELP "[fp] dwarf"; |
| 823 | #else | 816 | #else |
| 824 | const char record_callchain_help[] = CALLCHAIN_HELP "[fp]"; | 817 | const char record_callchain_help[] = CALLCHAIN_HELP "[fp]"; |
| @@ -857,8 +850,9 @@ const struct option record_options[] = { | |||
| 857 | OPT_BOOLEAN('i', "no-inherit", &record.opts.no_inherit, | 850 | OPT_BOOLEAN('i', "no-inherit", &record.opts.no_inherit, |
| 858 | "child tasks do not inherit counters"), | 851 | "child tasks do not inherit counters"), |
| 859 | OPT_UINTEGER('F', "freq", &record.opts.user_freq, "profile at this frequency"), | 852 | OPT_UINTEGER('F', "freq", &record.opts.user_freq, "profile at this frequency"), |
| 860 | OPT_UINTEGER('m', "mmap-pages", &record.opts.mmap_pages, | 853 | OPT_CALLBACK('m', "mmap-pages", &record.opts.mmap_pages, "pages", |
| 861 | "number of mmap data pages"), | 854 | "number of mmap data pages", |
| 855 | perf_evlist__parse_mmap_pages), | ||
| 862 | OPT_BOOLEAN(0, "group", &record.opts.group, | 856 | OPT_BOOLEAN(0, "group", &record.opts.group, |
| 863 | "put the counters into a counter group"), | 857 | "put the counters into a counter group"), |
| 864 | OPT_CALLBACK_DEFAULT('g', "call-graph", &record.opts, | 858 | OPT_CALLBACK_DEFAULT('g', "call-graph", &record.opts, |
