提交 cb21686b 编写于 作者: W Wang Nan 提交者: Arnaldo Carvalho de Melo

perf record: Prepare reading from multiple evlists in record__mmap_read_all()

Following commits introduce new evlists to record. This patch adjusts
record__mmap_read_all() and record__mmap_read(): converting original
record__mmap_read_all() to record__mmap_read_evlist(), read from one
evlist; makes record__mmap_read() reading from specific evlist.
record__mmap_read_all() will be improved to read from multiple evlists.
Signed-off-by: NWang Nan <wangnan0@huawei.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: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1467023052-146749-3-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 cda57a8c
...@@ -132,9 +132,9 @@ rb_find_range(struct perf_evlist *evlist, ...@@ -132,9 +132,9 @@ rb_find_range(struct perf_evlist *evlist,
return backward_rb_find_range(data, mask, head, start, end); return backward_rb_find_range(data, mask, head, start, end);
} }
static int record__mmap_read(struct record *rec, int idx) static int record__mmap_read(struct record *rec, struct perf_evlist *evlist, int idx)
{ {
struct perf_mmap *md = &rec->evlist->mmap[idx]; struct perf_mmap *md = &evlist->mmap[idx];
u64 head = perf_mmap__read_head(md); u64 head = perf_mmap__read_head(md);
u64 old = md->prev; u64 old = md->prev;
u64 end = head, start = old; u64 end = head, start = old;
...@@ -143,7 +143,7 @@ static int record__mmap_read(struct record *rec, int idx) ...@@ -143,7 +143,7 @@ static int record__mmap_read(struct record *rec, int idx)
void *buf; void *buf;
int rc = 0; int rc = 0;
if (rb_find_range(rec->evlist, data, md->mask, head, if (rb_find_range(evlist, data, md->mask, head,
old, &start, &end)) old, &start, &end))
return -1; return -1;
...@@ -157,7 +157,7 @@ static int record__mmap_read(struct record *rec, int idx) ...@@ -157,7 +157,7 @@ static int record__mmap_read(struct record *rec, int idx)
WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n"); WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n");
md->prev = head; md->prev = head;
perf_evlist__mmap_consume(rec->evlist, idx); perf_evlist__mmap_consume(evlist, idx);
return 0; return 0;
} }
...@@ -182,7 +182,7 @@ static int record__mmap_read(struct record *rec, int idx) ...@@ -182,7 +182,7 @@ static int record__mmap_read(struct record *rec, int idx)
} }
md->prev = head; md->prev = head;
perf_evlist__mmap_consume(rec->evlist, idx); perf_evlist__mmap_consume(evlist, idx);
out: out:
return rc; return rc;
} }
...@@ -498,17 +498,20 @@ static struct perf_event_header finished_round_event = { ...@@ -498,17 +498,20 @@ static struct perf_event_header finished_round_event = {
.type = PERF_RECORD_FINISHED_ROUND, .type = PERF_RECORD_FINISHED_ROUND,
}; };
static int record__mmap_read_all(struct record *rec) static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evlist)
{ {
u64 bytes_written = rec->bytes_written; u64 bytes_written = rec->bytes_written;
int i; int i;
int rc = 0; int rc = 0;
for (i = 0; i < rec->evlist->nr_mmaps; i++) { if (!evlist)
struct auxtrace_mmap *mm = &rec->evlist->mmap[i].auxtrace_mmap; return 0;
for (i = 0; i < evlist->nr_mmaps; i++) {
struct auxtrace_mmap *mm = &evlist->mmap[i].auxtrace_mmap;
if (rec->evlist->mmap[i].base) { if (evlist->mmap[i].base) {
if (record__mmap_read(rec, i) != 0) { if (record__mmap_read(rec, evlist, i) != 0) {
rc = -1; rc = -1;
goto out; goto out;
} }
...@@ -532,6 +535,17 @@ static int record__mmap_read_all(struct record *rec) ...@@ -532,6 +535,17 @@ static int record__mmap_read_all(struct record *rec)
return rc; return rc;
} }
static int record__mmap_read_all(struct record *rec)
{
int err;
err = record__mmap_read_evlist(rec, rec->evlist);
if (err)
return err;
return err;
}
static void record__init_features(struct record *rec) static void record__init_features(struct record *rec)
{ {
struct perf_session *session = rec->session; struct perf_session *session = rec->session;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册