Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1400575
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 12/17] perf tools: Record fd into perf_mmap |
| Date | 2016-05-13 10:00 +0200 |
| Message-ID | <rygaT-7tc-43@gated-at.bofh.it> (permalink) |
| References | <rygaR-7tc-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Add a fd field into perf_mmap so perf can track fd from mmap.
This feature will be used for toggling overwrite ring buffers.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
tools/perf/util/evlist.c | 15 +++++++++++++--
tools/perf/util/evlist.h | 1 +
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index dc2e509..4295d7e 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -943,6 +943,7 @@ static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
if (evlist->mmap[idx].base != NULL) {
munmap(evlist->mmap[idx].base, evlist->mmap_len);
evlist->mmap[idx].base = NULL;
+ evlist->mmap[idx].fd = -1;
atomic_set(&evlist->mmap[idx].refcnt, 0);
}
auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap);
@@ -973,7 +974,7 @@ void perf_evlist__munmap(struct perf_evlist *evlist)
static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
{
- int total_mmaps;
+ int total_mmaps, i;
evlist->nr_mmaps = cpu_map__nr(evlist->cpus);
if (cpu_map__empty(evlist->cpus))
@@ -984,7 +985,12 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
return -EINVAL;
evlist->mmap = zalloc(total_mmaps * sizeof(struct perf_mmap));
- return evlist->mmap != NULL ? 0 : -ENOMEM;
+ if (!evlist->mmap)
+ return -ENOMEM;
+
+ for (i = 0; i < total_mmaps; i++)
+ evlist->mmap[i].fd = -1;
+ return 0;
}
struct mmap_params {
@@ -1004,6 +1010,10 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
if (!perf_evlist__channel_check(evlist, channel, RDONLY))
prot |= PROT_WRITE;
+ if (evlist->mmap[idx].fd >= 0) {
+ pr_err("idx %d already mapped\n", idx);
+ return -1;
+ }
/*
* The last one will be done at perf_evlist__mmap_consume(), so that we
* make sure we don't prevent tools from consuming every last event in
@@ -1028,6 +1038,7 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
evlist->mmap[idx].base = NULL;
return -1;
}
+ evlist->mmap[idx].fd = fd;
if (auxtrace_mmap__mmap(&evlist->mmap[idx].auxtrace_mmap,
&mp->auxtrace_mp, evlist->mmap[idx].base, fd))
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index bdd8e98..ee17449 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -35,6 +35,7 @@ enum perf_evlist_mmap_flag {
struct perf_mmap {
void *base;
int mask;
+ int fd;
atomic_t refcnt;
u64 prev;
struct auxtrace_mmap auxtrace_mmap;
--
1.8.3.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/17] perf tools: Support overwritable ring buffer Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
[PATCH 15/17] perf record: Read from backward ring buffer Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
[PATCH 01/17] perf tools: Extract __perf_evlist__mmap_read() Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
Re: [PATCH 01/17] perf tools: Extract __perf_evlist__mmap_read() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-13 15:10 +0200
[PATCH 09/17] perf tools: Detect avalibility of write_backward Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
Re: [PATCH 09/17] perf tools: Detect avalibility of write_backward Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-13 15:10 +0200
Re: [PATCH 09/17] perf tools: Detect avalibility of write_backward "Wangnan (F)" <wangnan0@huawei.com> - 2016-05-20 17:40 +0200
Re: [PATCH 09/17] perf tools: Detect avalibility of write_backward Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-20 17:40 +0200
[PATCH 05/17] perf record: Prevent reading invalid data in record__mmap_read Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
[PATCH 17/17] perf tools: Don't warn about out of order event if write_backward is used Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
[PATCH 11/17] perf tools: Set write_backward attribut bit for overwrite events Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
[PATCH 04/17] perf tools: Operate multiple channels Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
[PATCH 08/17] perf record: Don't poll on overwrite channel Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
Re: [PATCH 08/17] perf record: Don't poll on overwrite channel Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-13 15:20 +0200
Re: [PATCH 08/17] perf record: Don't poll on overwrite channel "Wangnan (F)" <wangnan0@huawei.com> - 2016-05-16 05:20 +0200
[PATCH 16/17] perf record: Toggle overwrite ring buffer for reading Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
[PATCH 10/17] perf tools: Enable overwrite settings Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
Re: [PATCH 10/17] perf tools: Enable overwrite settings Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-16 15:40 +0200
[PATCH 07/17] perf record: Don't read from and poll overwrite channel Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
[PATCH 12/17] perf tools: Record fd into perf_mmap Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
[PATCH 13/17] perf tools: Add API to pause a channel Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:00 +0200
[PATCH 14/17] perf record: Rename variable to make code clear Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:10 +0200
[PATCH 02/17] perf tools: Add evlist channel helpers Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:10 +0200
Re: [PATCH 02/17] perf tools: Add evlist channel helpers Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-13 15:10 +0200
Re: [PATCH 02/17] perf tools: Add evlist channel helpers "Wangnan (F)" <wangnan0@huawei.com> - 2016-05-18 05:40 +0200
Re: [PATCH 02/17] perf tools: Add evlist channel helpers Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> - 2016-05-18 15:30 +0200
[PATCH 03/17] perf tools: Automatically add new channel according to evlist Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:20 +0200
[PATCH 06/17] perf tools: Squash overwrite setting into channel Wang Nan <wangnan0@huawei.com> - 2016-05-13 10:20 +0200
csiph-web