Commit d4c6fb36 authored by Wang Nan's avatar Wang Nan Committed by Arnaldo Carvalho de Melo

perf evsel: Record fd into perf_mmap

Add a fd field into struct perf_mmap so that perf can track the mmap fd.

This feature will be used for toggling overwrite ring buffers.
Signed-off-by: default avatarWang 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: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1463762315-155689-3-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarHe Kuang <hekuang@huawei.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b90dc17a
...@@ -881,6 +881,7 @@ static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx) ...@@ -881,6 +881,7 @@ static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
if (evlist->mmap[idx].base != NULL) { if (evlist->mmap[idx].base != NULL) {
munmap(evlist->mmap[idx].base, evlist->mmap_len); munmap(evlist->mmap[idx].base, evlist->mmap_len);
evlist->mmap[idx].base = NULL; evlist->mmap[idx].base = NULL;
evlist->mmap[idx].fd = -1;
atomic_set(&evlist->mmap[idx].refcnt, 0); atomic_set(&evlist->mmap[idx].refcnt, 0);
} }
auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap); auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap);
...@@ -901,10 +902,14 @@ void perf_evlist__munmap(struct perf_evlist *evlist) ...@@ -901,10 +902,14 @@ void perf_evlist__munmap(struct perf_evlist *evlist)
static int perf_evlist__alloc_mmap(struct perf_evlist *evlist) static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
{ {
int i;
evlist->nr_mmaps = cpu_map__nr(evlist->cpus); evlist->nr_mmaps = cpu_map__nr(evlist->cpus);
if (cpu_map__empty(evlist->cpus)) if (cpu_map__empty(evlist->cpus))
evlist->nr_mmaps = thread_map__nr(evlist->threads); evlist->nr_mmaps = thread_map__nr(evlist->threads);
evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap)); evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
for (i = 0; i < evlist->nr_mmaps; i++)
evlist->mmap[i].fd = -1;
return evlist->mmap != NULL ? 0 : -ENOMEM; return evlist->mmap != NULL ? 0 : -ENOMEM;
} }
...@@ -941,6 +946,7 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx, ...@@ -941,6 +946,7 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
evlist->mmap[idx].base = NULL; evlist->mmap[idx].base = NULL;
return -1; return -1;
} }
evlist->mmap[idx].fd = fd;
if (auxtrace_mmap__mmap(&evlist->mmap[idx].auxtrace_mmap, if (auxtrace_mmap__mmap(&evlist->mmap[idx].auxtrace_mmap,
&mp->auxtrace_mp, evlist->mmap[idx].base, fd)) &mp->auxtrace_mp, evlist->mmap[idx].base, fd))
......
...@@ -28,6 +28,7 @@ struct record_opts; ...@@ -28,6 +28,7 @@ struct record_opts;
struct perf_mmap { struct perf_mmap {
void *base; void *base;
int mask; int mask;
int fd;
atomic_t refcnt; atomic_t refcnt;
u64 prev; u64 prev;
struct auxtrace_mmap auxtrace_mmap; struct auxtrace_mmap auxtrace_mmap;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment