[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-a4ea0ec4f24a721bea5447a27ad5fbcb89275bae@git.kernel.org>
Date: Sat, 16 Jul 2016 13:47:17 -0700
From: tip-bot for Wang Nan <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, lizefan@...wei.com, acme@...hat.com,
nilayvaish@...il.com, wangnan0@...wei.com, jolsa@...nel.org,
hpa@...or.com, namhyung@...nel.org, mingo@...nel.org,
hekuang@...wei.com, mhiramat@...nel.org, tglx@...utronix.de
Subject: [tip:perf/core] perf record: Decouple record__mmap_read() and
evlist.
Commit-ID: a4ea0ec4f24a721bea5447a27ad5fbcb89275bae
Gitweb: http://git.kernel.org/tip/a4ea0ec4f24a721bea5447a27ad5fbcb89275bae
Author: Wang Nan <wangnan0@...wei.com>
AuthorDate: Thu, 14 Jul 2016 08:34:36 +0000
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Fri, 15 Jul 2016 17:27:46 -0300
perf record: Decouple record__mmap_read() and evlist.
Perf evlist will have multiple mmap arrays. Update record__mmap_read():
it should read from 'struct perf_mmap' directly.
Also, make record__mmap_read() ready to read from backward ring buffer.
Signed-off-by: Wang Nan <wangnan0@...wei.com>
Acked-by: Jiri Olsa <jolsa@...nel.org>
Cc: He Kuang <hekuang@...wei.com>
Cc: Masami Hiramatsu <mhiramat@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Nilay Vaish <nilayvaish@...il.com>
Cc: Zefan Li <lizefan@...wei.com>
Cc: pi3orama@....com
Link: http://lkml.kernel.org/r/1468485287-33422-5-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/builtin-record.c | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index d9f5cc3..d15517e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -119,11 +119,10 @@ backward_rb_find_range(void *buf, int mask, u64 head, u64 *start, u64 *end)
}
static int
-rb_find_range(struct perf_evlist *evlist,
- void *data, int mask, u64 head, u64 old,
- u64 *start, u64 *end)
+rb_find_range(void *data, int mask, u64 head, u64 old,
+ u64 *start, u64 *end, bool backward)
{
- if (!evlist->backward) {
+ if (!backward) {
*start = old;
*end = head;
return 0;
@@ -132,9 +131,10 @@ rb_find_range(struct perf_evlist *evlist,
return backward_rb_find_range(data, mask, head, start, end);
}
-static int record__mmap_read(struct record *rec, struct perf_evlist *evlist, int idx)
+static int
+record__mmap_read(struct record *rec, struct perf_mmap *md,
+ bool overwrite, bool backward)
{
- struct perf_mmap *md = &evlist->mmap[idx];
u64 head = perf_mmap__read_head(md);
u64 old = md->prev;
u64 end = head, start = old;
@@ -143,8 +143,8 @@ static int record__mmap_read(struct record *rec, struct perf_evlist *evlist, int
void *buf;
int rc = 0;
- if (rb_find_range(evlist, data, md->mask, head,
- old, &start, &end))
+ if (rb_find_range(data, md->mask, head,
+ old, &start, &end, backward))
return -1;
if (start == end)
@@ -157,7 +157,7 @@ static int record__mmap_read(struct record *rec, struct perf_evlist *evlist, int
WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n");
md->prev = head;
- perf_evlist__mmap_consume(evlist, idx);
+ perf_mmap__consume(md, overwrite || backward);
return 0;
}
@@ -182,7 +182,7 @@ static int record__mmap_read(struct record *rec, struct perf_evlist *evlist, int
}
md->prev = head;
- perf_evlist__mmap_consume(evlist, idx);
+ perf_mmap__consume(md, overwrite || backward);
out:
return rc;
}
@@ -498,20 +498,27 @@ static struct perf_event_header finished_round_event = {
.type = PERF_RECORD_FINISHED_ROUND,
};
-static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evlist)
+static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evlist,
+ bool backward)
{
u64 bytes_written = rec->bytes_written;
int i;
int rc = 0;
+ struct perf_mmap *maps;
if (!evlist)
return 0;
+ maps = evlist->mmap;
+ if (!maps)
+ return 0;
+
for (i = 0; i < evlist->nr_mmaps; i++) {
- struct auxtrace_mmap *mm = &evlist->mmap[i].auxtrace_mmap;
+ struct auxtrace_mmap *mm = &maps[i].auxtrace_mmap;
- if (evlist->mmap[i].base) {
- if (record__mmap_read(rec, evlist, i) != 0) {
+ if (maps[i].base) {
+ if (record__mmap_read(rec, &maps[i],
+ evlist->overwrite, backward) != 0) {
rc = -1;
goto out;
}
@@ -539,7 +546,7 @@ static int record__mmap_read_all(struct record *rec)
{
int err;
- err = record__mmap_read_evlist(rec, rec->evlist);
+ err = record__mmap_read_evlist(rec, rec->evlist, false);
if (err)
return err;
Powered by blists - more mailing lists