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.hun...@intel.com>
Signed-off-by: Namhyung Kim <namhy...@kernel.org>
---
 tools/perf/builtin-record.c |  2 +-
 tools/perf/util/evlist.c    | 13 ++++++++-----
 tools/perf/util/evlist.h    |  2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 7d7ef5a1b0a6..21f7edb23370 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -304,7 +304,7 @@ static int record__open(struct record *rec)
 
        if (perf_evlist__mmap_ex(evlist, opts->mmap_pages, false,
                                 opts->auxtrace_mmap_pages,
-                                opts->auxtrace_snapshot_mode) < 0) {
+                                opts->auxtrace_snapshot_mode, 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 5db249eb4dcd..303249467672 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -863,6 +863,7 @@ static int perf_evlist__alloc_mmap(struct perf_evlist 
*evlist, bool track_mmap)
 
 struct mmap_params {
        int     prot;
+       bool    track;
        size_t  len;
        struct auxtrace_mmap_params auxtrace_mp;
 };
@@ -913,7 +914,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,
@@ -971,7 +972,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);
                }
@@ -1138,6 +1139,7 @@ int perf_evlist__parse_mmap_pages(const struct option 
*opt, const char *str,
  * @overwrite: overwrite older events?
  * @auxtrace_pages - auxtrace map length in pages
  * @auxtrace_overwrite - overwrite older auxtrace data?
+ * @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
@@ -1150,16 +1152,17 @@ int perf_evlist__parse_mmap_pages(const struct option 
*opt, const char *str,
  */
 int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
                         bool overwrite, unsigned int auxtrace_pages,
-                        bool auxtrace_overwrite)
+                        bool auxtrace_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)
@@ -1189,7 +1192,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, 
unsigned int pages,
 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
                      bool overwrite)
 {
-       return perf_evlist__mmap_ex(evlist, pages, overwrite, 0, false);
+       return perf_evlist__mmap_ex(evlist, pages, overwrite, 0, false, false);
 }
 
 int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 335988577c18..27453338a8f5 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -135,7 +135,7 @@ int perf_evlist__parse_mmap_pages(const struct option *opt,
 
 int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
                         bool overwrite, unsigned int auxtrace_pages,
-                        bool auxtrace_overwrite);
+                        bool auxtrace_overwrite, bool use_track_mmap);
 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
                      bool overwrite);
 void perf_evlist__munmap(struct perf_evlist *evlist);
-- 
2.4.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to