lkml.org 
[lkml]   [2013]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v0 44/71] perf record: Extend -m option for Instruction Tracing mmap pages
Date
From: Adrian Hunter <adrian.hunter@intel.com>

Extend the -m option so that the number
of mmap pages for Instruction Tracing
can be specified.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/Documentation/perf-record.txt | 2 ++
tools/perf/builtin-record.c | 49 ++++++++++++++++++++++++++++++--
tools/perf/util/evlist.c | 16 +++++++----
tools/perf/util/evlist.h | 2 ++
4 files changed, 60 insertions(+), 9 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index c407897..bb01df7 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -92,6 +92,8 @@ OPTIONS
Number of mmap data pages (must be a power of two) or size
specification with appended unit character - B/K/M/G. The
size is rounded up to have nearest pages power of two value.
+ Also, by adding a comma, the number of mmap pages for Instruction
+ Tracing can be specified.

-g::
Enables call-graph (stack chain/backtrace) recording.
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 4613f55..344603f 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -828,6 +828,49 @@ int record_callchain_opt(const struct option *opt,
return 0;
}

+static int perf_record__parse_mmap_pages(const struct option *opt,
+ const char *str,
+ int unset __maybe_unused)
+{
+ struct perf_record_opts *opts = opt->value;
+ char *s, *p;
+ unsigned int mmap_pages;
+ int ret;
+
+ if (!str)
+ return -EINVAL;
+
+ s = strdup(str);
+ if (!s)
+ return -ENOMEM;
+
+ p = strchr(s, ',');
+ if (p)
+ *p = '\0';
+
+ if (*s) {
+ ret = __perf_evlist__parse_mmap_pages(&mmap_pages, s, true);
+ if (ret)
+ goto out_free;
+ opts->mmap_pages = mmap_pages;
+ }
+
+ if (!p) {
+ ret = 0;
+ goto out_free;
+ }
+
+ ret = __perf_evlist__parse_mmap_pages(&mmap_pages, p + 1, false);
+ if (ret)
+ goto out_free;
+
+ opts->itrace_mmap_pages = mmap_pages;
+
+out_free:
+ free(s);
+ return ret;
+}
+
static const char * const record_usage[] = {
"perf record [<options>] [<command>]",
"perf record [<options>] -- <command> [<options>]",
@@ -899,9 +942,9 @@ const struct option record_options[] = {
&record.opts.no_inherit_set,
"child tasks do not inherit counters"),
OPT_UINTEGER('F', "freq", &record.opts.user_freq, "profile at this frequency"),
- OPT_CALLBACK('m', "mmap-pages", &record.opts.mmap_pages, "pages",
- "number of mmap data pages",
- perf_evlist__parse_mmap_pages),
+ OPT_CALLBACK('m', "mmap-pages", &record.opts, "pages[,pages]",
+ "number of mmap data pages and instruction tracing mmap pages",
+ perf_record__parse_mmap_pages),
OPT_BOOLEAN(0, "group", &record.opts.group,
"put the counters into a counter group"),
OPT_CALLBACK_NOOPT('g', NULL, &record.opts,
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index c720c6c..dbb1898 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -843,7 +843,7 @@ static size_t perf_evlist__mmap_size(unsigned long pages)
}

static long parse_pages_arg(const char *str, unsigned long min,
- unsigned long max)
+ unsigned long max, bool po2)
{
unsigned long pages, val;
static struct parse_tag tags[] = {
@@ -871,7 +871,7 @@ static long parse_pages_arg(const char *str, unsigned long min,

if ((pages == 0) && (min == 0)) {
/* leave number of pages at 0 */
- } else if (pages < (1UL << 31) && !is_power_of_2(pages)) {
+ } else if (po2 && pages < (1UL << 31) && !is_power_of_2(pages)) {
/* round pages up to next power of 2 */
pages = next_pow2(pages);
pr_info("rounding mmap pages size to %lu bytes (%lu pages)\n",
@@ -884,17 +884,15 @@ static long parse_pages_arg(const char *str, unsigned long min,
return pages;
}

-int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
- int unset __maybe_unused)
+int __perf_evlist__parse_mmap_pages(unsigned int *mmap_pages, const char *str, bool po2)
{
- unsigned int *mmap_pages = opt->value;
unsigned long max = UINT_MAX;
long pages;

if (max < SIZE_MAX / page_size)
max = SIZE_MAX / page_size;

- pages = parse_pages_arg(str, 1, max);
+ pages = parse_pages_arg(str, 1, max, po2);
if (pages < 0) {
pr_err("Invalid argument for --mmap_pages/-m\n");
return -1;
@@ -904,6 +902,12 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
return 0;
}

+int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
+ int unset __maybe_unused)
+{
+ return __perf_evlist__parse_mmap_pages(opt->value, str, true);
+}
+
/**
* perf_evlist__mmap_ex - Create mmaps to receive events.
* @evlist: list of events
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 7f56fdc..c5ef575 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -109,6 +109,8 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist,
bool want_signal);
int perf_evlist__start_workload(struct perf_evlist *evlist);

+int __perf_evlist__parse_mmap_pages(unsigned int *mmap_pages, const char *str,
+ bool po2);
int perf_evlist__parse_mmap_pages(const struct option *opt,
const char *str,
int unset);
--
1.8.5.1


\
 
 \ /
  Last update: 2013-12-11 14:21    [W:0.567 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site