diff options
author | Wang Nan <wangnan0@huawei.com> | 2016-07-14 04:34:38 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-15 16:27:47 -0400 |
commit | a1f72618346a4e7ce9cff6aec1a62737d5d08763 (patch) | |
tree | 62d32ea095693439a56178a80bf8a1b9e7b39a73 | |
parent | 4876075b3205af992bf1012f6d6fbc03593d55b9 (diff) |
perf evlist: Extract common code in mmap failure processing
In perf_evlist__mmap_per_cpu() and perf_evlist__mmap_per_thread(), in
case of mmap failure, successfully created maps should be cleared.
Current code uses two loops calling __perf_evlist__munmap() for each
function.
This patch extracts common code to perf_evlist__munmap_nofree() and use
previous introduced decoupled API perf_mmap__munmap(). Now
__perf_evlist__munmap() can be removed because of no user.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
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/1468485287-33422-7-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/evlist.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 1462085a8618..54ae0a0bc22c 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/err.h> | 28 | #include <linux/err.h> |
29 | 29 | ||
30 | static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx); | 30 | static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx); |
31 | static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx); | ||
32 | static void perf_mmap__munmap(struct perf_mmap *map); | 31 | static void perf_mmap__munmap(struct perf_mmap *map); |
33 | static void perf_mmap__put(struct perf_mmap *map); | 32 | static void perf_mmap__put(struct perf_mmap *map); |
34 | 33 | ||
@@ -970,12 +969,7 @@ static void perf_mmap__munmap(struct perf_mmap *map) | |||
970 | auxtrace_mmap__munmap(&map->auxtrace_mmap); | 969 | auxtrace_mmap__munmap(&map->auxtrace_mmap); |
971 | } | 970 | } |
972 | 971 | ||
973 | static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx) | 972 | static void perf_evlist__munmap_nofree(struct perf_evlist *evlist) |
974 | { | ||
975 | perf_mmap__munmap(&evlist->mmap[idx]); | ||
976 | } | ||
977 | |||
978 | void perf_evlist__munmap(struct perf_evlist *evlist) | ||
979 | { | 973 | { |
980 | int i; | 974 | int i; |
981 | 975 | ||
@@ -983,8 +977,12 @@ void perf_evlist__munmap(struct perf_evlist *evlist) | |||
983 | return; | 977 | return; |
984 | 978 | ||
985 | for (i = 0; i < evlist->nr_mmaps; i++) | 979 | for (i = 0; i < evlist->nr_mmaps; i++) |
986 | __perf_evlist__munmap(evlist, i); | 980 | perf_mmap__munmap(&evlist->mmap[i]); |
981 | } | ||
987 | 982 | ||
983 | void perf_evlist__munmap(struct perf_evlist *evlist) | ||
984 | { | ||
985 | perf_evlist__munmap_nofree(evlist); | ||
988 | zfree(&evlist->mmap); | 986 | zfree(&evlist->mmap); |
989 | } | 987 | } |
990 | 988 | ||
@@ -1142,8 +1140,7 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, | |||
1142 | return 0; | 1140 | return 0; |
1143 | 1141 | ||
1144 | out_unmap: | 1142 | out_unmap: |
1145 | for (cpu = 0; cpu < nr_cpus; cpu++) | 1143 | perf_evlist__munmap_nofree(evlist); |
1146 | __perf_evlist__munmap(evlist, cpu); | ||
1147 | return -1; | 1144 | return -1; |
1148 | } | 1145 | } |
1149 | 1146 | ||
@@ -1168,8 +1165,7 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, | |||
1168 | return 0; | 1165 | return 0; |
1169 | 1166 | ||
1170 | out_unmap: | 1167 | out_unmap: |
1171 | for (thread = 0; thread < nr_threads; thread++) | 1168 | perf_evlist__munmap_nofree(evlist); |
1172 | __perf_evlist__munmap(evlist, thread); | ||
1173 | return -1; | 1169 | return -1; |
1174 | } | 1170 | } |
1175 | 1171 | ||