diff options
author | Wang Nan <wangnan0@huawei.com> | 2016-05-20 12:38:24 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-05-20 13:56:58 -0400 |
commit | d4c6fb36ac2c82f8f0c05b04cf102dcdc2d5a14d (patch) | |
tree | 665c128afe013e67fc919f07e907445190bce2c2 | |
parent | b90dc17a5d14a881f9bb3b58edb3d71075d58afb (diff) |
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: Wang 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.com
Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/evlist.c | 6 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index c4bfe11479a0..1a370db02a8c 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -881,6 +881,7 @@ static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx) | |||
881 | if (evlist->mmap[idx].base != NULL) { | 881 | if (evlist->mmap[idx].base != NULL) { |
882 | munmap(evlist->mmap[idx].base, evlist->mmap_len); | 882 | munmap(evlist->mmap[idx].base, evlist->mmap_len); |
883 | evlist->mmap[idx].base = NULL; | 883 | evlist->mmap[idx].base = NULL; |
884 | evlist->mmap[idx].fd = -1; | ||
884 | atomic_set(&evlist->mmap[idx].refcnt, 0); | 885 | atomic_set(&evlist->mmap[idx].refcnt, 0); |
885 | } | 886 | } |
886 | auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap); | 887 | auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap); |
@@ -901,10 +902,14 @@ void perf_evlist__munmap(struct perf_evlist *evlist) | |||
901 | 902 | ||
902 | static int perf_evlist__alloc_mmap(struct perf_evlist *evlist) | 903 | static int perf_evlist__alloc_mmap(struct perf_evlist *evlist) |
903 | { | 904 | { |
905 | int i; | ||
906 | |||
904 | evlist->nr_mmaps = cpu_map__nr(evlist->cpus); | 907 | evlist->nr_mmaps = cpu_map__nr(evlist->cpus); |
905 | if (cpu_map__empty(evlist->cpus)) | 908 | if (cpu_map__empty(evlist->cpus)) |
906 | evlist->nr_mmaps = thread_map__nr(evlist->threads); | 909 | evlist->nr_mmaps = thread_map__nr(evlist->threads); |
907 | evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap)); | 910 | evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap)); |
911 | for (i = 0; i < evlist->nr_mmaps; i++) | ||
912 | evlist->mmap[i].fd = -1; | ||
908 | return evlist->mmap != NULL ? 0 : -ENOMEM; | 913 | return evlist->mmap != NULL ? 0 : -ENOMEM; |
909 | } | 914 | } |
910 | 915 | ||
@@ -941,6 +946,7 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx, | |||
941 | evlist->mmap[idx].base = NULL; | 946 | evlist->mmap[idx].base = NULL; |
942 | return -1; | 947 | return -1; |
943 | } | 948 | } |
949 | evlist->mmap[idx].fd = fd; | ||
944 | 950 | ||
945 | if (auxtrace_mmap__mmap(&evlist->mmap[idx].auxtrace_mmap, | 951 | if (auxtrace_mmap__mmap(&evlist->mmap[idx].auxtrace_mmap, |
946 | &mp->auxtrace_mp, evlist->mmap[idx].base, fd)) | 952 | &mp->auxtrace_mp, evlist->mmap[idx].base, fd)) |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 85d1b59802e8..0d165b1d8f77 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -28,6 +28,7 @@ struct record_opts; | |||
28 | struct perf_mmap { | 28 | struct perf_mmap { |
29 | void *base; | 29 | void *base; |
30 | int mask; | 30 | int mask; |
31 | int fd; | ||
31 | atomic_t refcnt; | 32 | atomic_t refcnt; |
32 | u64 prev; | 33 | u64 prev; |
33 | struct auxtrace_mmap auxtrace_mmap; | 34 | struct auxtrace_mmap auxtrace_mmap; |