linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wang Nan <wangnan0@huawei.com>
To: <acme@kernel.org>
Cc: <lizefan@huawei.com>, <linux-kernel@vger.kernel.org>,
	<pi3orama@163.com>, Wang Nan <wangnan0@huawei.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	He Kuang <hekuang@huawei.com>, Jiri Olsa <jolsa@kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Nilay Vaish <nilayvaish@gmail.com>
Subject: [PATCH v16 07/15] perf tools: Introduce backward_mmap array for evlist
Date: Thu, 14 Jul 2016 08:34:39 +0000	[thread overview]
Message-ID: <1468485287-33422-8-git-send-email-wangnan0@huawei.com> (raw)
In-Reply-To: <1468485287-33422-1-git-send-email-wangnan0@huawei.com>

Add backward_mmap to evlist, free it together with normal mmap.

Improve perf_evlist__pick_pc(), search backward_mmap if evlist->mmap is
not available.

This patch doesn't make alloc this array. It will be allocated
conditionally in following commits.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: pi3orama@163.com
---
 tools/perf/builtin-record.c | 10 +++++++---
 tools/perf/util/evlist.c    | 12 ++++++++----
 tools/perf/util/evlist.h    |  1 +
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index d15517e..dbcb223 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -509,7 +509,7 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli
 	if (!evlist)
 		return 0;
 
-	maps = evlist->mmap;
+	maps = backward ? evlist->backward_mmap : evlist->mmap;
 	if (!maps)
 		return 0;
 
@@ -696,8 +696,12 @@ perf_event__synth_time_conv(const struct perf_event_mmap_page *pc __maybe_unused
 static const struct perf_event_mmap_page *
 perf_evlist__pick_pc(struct perf_evlist *evlist)
 {
-	if (evlist && evlist->mmap && evlist->mmap[0].base)
-		return evlist->mmap[0].base;
+	if (evlist) {
+		if (evlist->mmap && evlist->mmap[0].base)
+			return evlist->mmap[0].base;
+		if (evlist->backward_mmap && evlist->backward_mmap[0].base)
+			return evlist->backward_mmap[0].base;
+	}
 	return NULL;
 }
 
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 54ae0a0..24927e1 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -123,6 +123,7 @@ static void perf_evlist__purge(struct perf_evlist *evlist)
 void perf_evlist__exit(struct perf_evlist *evlist)
 {
 	zfree(&evlist->mmap);
+	zfree(&evlist->backward_mmap);
 	fdarray__exit(&evlist->pollfd);
 }
 
@@ -973,17 +974,20 @@ static void perf_evlist__munmap_nofree(struct perf_evlist *evlist)
 {
 	int i;
 
-	if (evlist->mmap == NULL)
-		return;
+	if (evlist->mmap)
+		for (i = 0; i < evlist->nr_mmaps; i++)
+			perf_mmap__munmap(&evlist->mmap[i]);
 
-	for (i = 0; i < evlist->nr_mmaps; i++)
-		perf_mmap__munmap(&evlist->mmap[i]);
+	if (evlist->backward_mmap)
+		for (i = 0; i < evlist->nr_mmaps; i++)
+			perf_mmap__munmap(&evlist->backward_mmap[i]);
 }
 
 void perf_evlist__munmap(struct perf_evlist *evlist)
 {
 	perf_evlist__munmap_nofree(evlist);
 	zfree(&evlist->mmap);
+	zfree(&evlist->backward_mmap);
 }
 
 static struct perf_mmap *perf_evlist__alloc_mmap(struct perf_evlist *evlist)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 9e680c6..07a1ad0 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -61,6 +61,7 @@ struct perf_evlist {
 	} workload;
 	struct fdarray	 pollfd;
 	struct perf_mmap *mmap;
+	struct perf_mmap *backward_mmap;
 	struct thread_map *threads;
 	struct cpu_map	  *cpus;
 	struct perf_evsel *selected;
-- 
1.8.3.4

  parent reply	other threads:[~2016-07-14  8:37 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-14  8:34 [PATCH v16 00/15] perf tools: Support overwritable ring buffer Wang Nan
2016-07-14  8:34 ` [PATCH v16 01/15] perf tools: Drop redundant evsel->overwrite indicator Wang Nan
2016-07-16 20:45   ` [tip:perf/core] perf evlist: " tip-bot for Arnaldo Carvalho de Melo
2016-07-14  8:34 ` [PATCH v16 02/15] tools lib fd array: Allow associating a pointer cookie with each entry Wang Nan
2016-07-16 20:46   ` [tip:perf/core] " tip-bot for Wang Nan
2016-07-14  8:34 ` [PATCH v16 03/15] perf tools: Update perf evlist mmap related APIs and helpers Wang Nan
2016-07-16 20:46   ` [tip:perf/core] perf evlist: Update " tip-bot for Wang Nan
2016-07-14  8:34 ` [PATCH v16 04/15] perf tools: Decouple record__mmap_read() and evlist Wang Nan
2016-07-16 20:47   ` [tip:perf/core] perf record: " tip-bot for Wang Nan
2016-07-14  8:34 ` [PATCH v16 05/15] perf tools: Record mmap cookie into fdarray private field Wang Nan
2016-07-15 14:59   ` Jiri Olsa
2016-07-16 20:47   ` [tip:perf/core] perf evlist: " tip-bot for Wang Nan
2016-07-14  8:34 ` [PATCH v16 06/15] perf tools: Extract common code in mmap failure processing Wang Nan
2016-07-16 20:48   ` [tip:perf/core] perf evlist: " tip-bot for Wang Nan
2016-07-14  8:34 ` Wang Nan [this message]
2016-07-16 20:48   ` [tip:perf/core] perf evlist: Introduce backward_mmap array for evlist tip-bot for Wang Nan
2016-07-14  8:34 ` [PATCH v16 08/15] perf tools: Map backward events to backward_mmap Wang Nan
2016-07-16 20:48   ` [tip:perf/core] perf evlist: " tip-bot for Wang Nan
2016-07-14  8:34 ` [PATCH v16 09/15] perf tools: Drop evlist->backward Wang Nan
2016-07-16 20:49   ` [tip:perf/core] perf evlist: " tip-bot for Wang Nan
2016-07-14  8:34 ` [PATCH v16 10/15] perf tools: Setup backward mmap state machine Wang Nan
2016-07-16 20:49   ` [tip:perf/core] perf evlist: " tip-bot for Wang Nan
2016-07-14  8:34 ` [PATCH v16 11/15] perf record: Read from overwritable ring buffer Wang Nan
2016-07-16 20:50   ` [tip:perf/core] " tip-bot for Wang Nan
2016-07-14  8:34 ` [PATCH v16 12/15] perf tools: Make perf_evlist__{pause,resume} internal helpers Wang Nan
2016-07-16 20:50   ` [tip:perf/core] perf evlist: Make {pause,resume} " tip-bot for Wang Nan
2016-07-14  8:34 ` [PATCH v16 13/15] perf tools: Enable overwrite settings Wang Nan
2016-07-16 20:50   ` [tip:perf/core] " tip-bot for Wang Nan
2016-07-14  8:34 ` [PATCH v16 14/15] perf tools: Don't warn about out of order event if write_backward is used Wang Nan
2016-07-15 14:59   ` Jiri Olsa
2016-07-16 20:51   ` [tip:perf/core] perf session: " tip-bot for Wang Nan
2016-07-14  8:34 ` [PATCH v16 15/15] perf tools: Add --tail-synthesize option Wang Nan
2016-07-16 20:51   ` [tip:perf/core] perf record: " tip-bot for Wang Nan
2016-07-15 15:00 ` [PATCH v16 00/15] perf tools: Support overwritable ring buffer Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468485287-33422-8-git-send-email-wangnan0@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=hekuang@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=mhiramat@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=nilayvaish@gmail.com \
    --cc=pi3orama@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).