diff options
author | David Ahern <dsahern@gmail.com> | 2013-11-12 09:46:54 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-11-12 14:31:53 -0500 |
commit | 9639837e95db90d056f4683c911717921519320e (patch) | |
tree | 98eb5457302a6bf58155c5de0fe76b3987314faf /tools | |
parent | 8973504be70b2986a2081eeff7d9a4210dec295d (diff) |
perf evlist: Round mmap pages to power 2 - v2
Currently perf requires the -m / --mmap_pages option to be a power of 2.
To be more user friendly perf should automatically round this up to the
next power of 2.
Currently:
$ perf record -m 3 -a -- sleep 1
--mmap_pages/-m value must be a power of two.sleep: Terminated
With patch:
$ perf record -m 3 -a -- sleep 1
rounding mmap pages size to 16384 (4 pages)
...
v2: Add bytes units to rounding message per Ingo's request. Other
suggestions (e.g., prefixing INFO) should be addressed by wrapping
pr_info to catch all instances.
Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1384267617-3446-3-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/evlist.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 3960560f873a..fb4727d3df85 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -710,7 +710,6 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str, | |||
710 | { | 710 | { |
711 | unsigned int *mmap_pages = opt->value; | 711 | unsigned int *mmap_pages = opt->value; |
712 | unsigned long pages, val; | 712 | unsigned long pages, val; |
713 | size_t size; | ||
714 | static struct parse_tag tags[] = { | 713 | static struct parse_tag tags[] = { |
715 | { .tag = 'B', .mult = 1 }, | 714 | { .tag = 'B', .mult = 1 }, |
716 | { .tag = 'K', .mult = 1 << 10 }, | 715 | { .tag = 'K', .mult = 1 << 10 }, |
@@ -726,11 +725,6 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str, | |||
726 | if (val != (unsigned long) -1) { | 725 | if (val != (unsigned long) -1) { |
727 | /* we got file size value */ | 726 | /* we got file size value */ |
728 | pages = PERF_ALIGN(val, page_size) / page_size; | 727 | pages = PERF_ALIGN(val, page_size) / page_size; |
729 | if (pages < (1UL << 31) && !is_power_of_2(pages)) { | ||
730 | pages = next_pow2(pages); | ||
731 | pr_info("rounding mmap pages size to %lu (%lu pages)\n", | ||
732 | pages * page_size, pages); | ||
733 | } | ||
734 | } else { | 728 | } else { |
735 | /* we got pages count value */ | 729 | /* we got pages count value */ |
736 | char *eptr; | 730 | char *eptr; |
@@ -741,14 +735,14 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str, | |||
741 | } | 735 | } |
742 | } | 736 | } |
743 | 737 | ||
744 | if (pages > UINT_MAX || pages > SIZE_MAX / page_size) { | 738 | if (pages < (1UL << 31) && !is_power_of_2(pages)) { |
745 | pr_err("--mmap_pages/-m value too big\n"); | 739 | pages = next_pow2(pages); |
746 | return -1; | 740 | pr_info("rounding mmap pages size to %lu bytes (%lu pages)\n", |
741 | pages * page_size, pages); | ||
747 | } | 742 | } |
748 | 743 | ||
749 | size = perf_evlist__mmap_size(pages); | 744 | if (pages > UINT_MAX || pages > SIZE_MAX / page_size) { |
750 | if (!size) { | 745 | pr_err("--mmap_pages/-m value too big\n"); |
751 | pr_err("--mmap_pages/-m value must be a power of two."); | ||
752 | return -1; | 746 | return -1; |
753 | } | 747 | } |
754 | 748 | ||