libperf: Adopt perf_mmap__unmap() function from tools/perf

Move perf_mmap__unmap() from tools/perf to libperf, to internal header
internal/mmap.h. It will be used in the following patches. And rename
the existing perf's function to mmap__munmap().

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20191007125344.14268-7-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Jiri Olsa 2019-10-07 14:53:14 +02:00 committed by Arnaldo Carvalho de Melo
parent e75710f063
commit 59d7ea620b
5 changed files with 17 additions and 11 deletions

View file

@ -115,7 +115,7 @@ void perf_mmap__put(struct mmap *map)
BUG_ON(map->core.base && refcount_read(&map->core.refcnt) == 0);
if (refcount_dec_and_test(&map->core.refcnt))
perf_mmap__munmap(map);
mmap__munmap(map);
}
void perf_mmap__consume(struct mmap *map)
@ -306,19 +306,14 @@ static void perf_mmap__aio_munmap(struct mmap *map __maybe_unused)
}
#endif
void perf_mmap__munmap(struct mmap *map)
void mmap__munmap(struct mmap *map)
{
perf_mmap__munmap(&map->core);
perf_mmap__aio_munmap(map);
if (map->data != NULL) {
munmap(map->data, mmap__mmap_len(map));
map->data = NULL;
}
if (map->core.base != NULL) {
munmap(map->core.base, mmap__mmap_len(map));
map->core.base = NULL;
map->core.fd = -1;
refcount_set(&map->core.refcnt, 0);
}
auxtrace_mmap__munmap(&map->auxtrace_mmap);
}