lkml.org 
[lkml]   [2015]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 05/38] perf tools: Introduce perf_evlist__mmap_track()
Date
The perf_evlist__mmap_track function creates data mmaps and optionally
tracking mmaps for events. It'll be used for perf record to save events
in a separate files and build an index table. Checking dummy tracking
event in perf_evlist__mmap() alone is not enough as users can specify a
dummy event (like in keep tracking testcase) without the index option.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-record.c | 3 ++-
tools/perf/util/evlist.c | 15 +++++++++------
tools/perf/util/evlist.h | 10 ++++++++--
3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 2bd724763e1d..4568bc4117a1 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -169,7 +169,8 @@ static int record__open(struct record *rec)
goto out;
}

- if (perf_evlist__mmap(evlist, opts->mmap_pages, false) < 0) {
+ if (perf_evlist__mmap_track(evlist, opts->mmap_pages, false,
+ false) < 0) {
if (errno == EPERM) {
pr_err("Permission error mapping pages.\n"
"Consider increasing "
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index ebbec07843a2..d264ba3602b1 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -834,6 +834,7 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist, bool track_mmap)

struct mmap_params {
int prot;
+ bool track;
size_t len;
};

@@ -883,7 +884,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,

fd = FD(evsel, cpu, thread);

- if (perf_evsel__is_dummy_tracking(evsel)) {
+ if (mp->track && perf_evsel__is_dummy_tracking(evsel)) {
struct mmap_params track_mp = {
.prot = mp->prot,
.len = TRACK_MMAP_SIZE,
@@ -936,7 +937,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
thread);
}

- if (perf_evsel__is_dummy_tracking(evsel)) {
+ if (mp->track && perf_evsel__is_dummy_tracking(evsel)) {
/* restore idx as normal idx (positive) */
idx = track_mmap_idx(idx);
}
@@ -1087,10 +1088,11 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
}

/**
- * perf_evlist__mmap - Create mmaps to receive events.
+ * perf_evlist__mmap_track - Create mmaps to receive events.
* @evlist: list of events
* @pages: map length in pages
* @overwrite: overwrite older events?
+ * @use_track_mmap: use another mmaps to track meta events
*
* If @overwrite is %false the user needs to signal event consumption using
* perf_mmap__write_tail(). Using perf_evlist__mmap_read() does this
@@ -1098,17 +1100,18 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
*
* Return: %0 on success, negative error code otherwise.
*/
-int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
- bool overwrite)
+int perf_evlist__mmap_track(struct perf_evlist *evlist, unsigned int pages,
+ bool overwrite, bool use_track_mmap)
{
struct perf_evsel *evsel;
const struct cpu_map *cpus = evlist->cpus;
const struct thread_map *threads = evlist->threads;
struct mmap_params mp = {
.prot = PROT_READ | (overwrite ? 0 : PROT_WRITE),
+ .track = use_track_mmap,
};

- if (evlist->mmap == NULL && perf_evlist__alloc_mmap(evlist, true) < 0)
+ if (evlist->mmap == NULL && perf_evlist__alloc_mmap(evlist, mp.track) < 0)
return -ENOMEM;

if (evlist->pollfd.entries == NULL && perf_evlist__alloc_pollfd(evlist) < 0)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 3bd9747bb9aa..da45074ee500 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -130,10 +130,16 @@ int perf_evlist__parse_mmap_pages(const struct option *opt,
const char *str,
int unset);

-int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
- bool overwrite);
+int perf_evlist__mmap_track(struct perf_evlist *evlist, unsigned int pages,
+ bool overwrite, bool use_track_mmap);
void perf_evlist__munmap(struct perf_evlist *evlist);

+static inline int perf_evlist__mmap(struct perf_evlist *evlist,
+ unsigned int pages, bool overwrite)
+{
+ return perf_evlist__mmap_track(evlist, pages, overwrite, false);
+}
+
void perf_evlist__disable(struct perf_evlist *evlist);
void perf_evlist__enable(struct perf_evlist *evlist);

--
2.2.2


\
 
 \ /
  Last update: 2015-03-03 05:01    [W:0.187 / U:0.956 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site