diff options
author | Jiri Olsa <jolsa@kernel.org> | 2019-10-07 15:53:14 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-10-10 16:05:57 +0300 |
commit | 59d7ea620b58fa7d107834a81528e3098f1c27b0 (patch) | |
tree | 05ce71167abf0da1ccb069f60c5d23d65457de3d /tools/perf/lib | |
parent | e75710f063e29ae7715c57b45eb27c2d504b32ca (diff) | |
download | linux-59d7ea620b58fa7d107834a81528e3098f1c27b0.tar.xz |
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>
Diffstat (limited to 'tools/perf/lib')
-rw-r--r-- | tools/perf/lib/include/internal/mmap.h | 1 | ||||
-rw-r--r-- | tools/perf/lib/mmap.c | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/tools/perf/lib/include/internal/mmap.h b/tools/perf/lib/include/internal/mmap.h index 2e68974bffb4..5c2ca9ab12cd 100644 --- a/tools/perf/lib/include/internal/mmap.h +++ b/tools/perf/lib/include/internal/mmap.h @@ -39,6 +39,7 @@ size_t perf_mmap__mmap_len(struct perf_mmap *map); void perf_mmap__init(struct perf_mmap *map, bool overwrite); int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp, int fd, int cpu); +void perf_mmap__munmap(struct perf_mmap *map); void perf_mmap__get(struct perf_mmap *map); #endif /* __LIBPERF_INTERNAL_MMAP_H */ diff --git a/tools/perf/lib/mmap.c b/tools/perf/lib/mmap.c index b765e0505bb6..6eb228d89206 100644 --- a/tools/perf/lib/mmap.c +++ b/tools/perf/lib/mmap.c @@ -32,6 +32,16 @@ int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp, return 0; } +void perf_mmap__munmap(struct perf_mmap *map) +{ + if (map && map->base != NULL) { + munmap(map->base, perf_mmap__mmap_len(map)); + map->base = NULL; + map->fd = -1; + refcount_set(&map->refcnt, 0); + } +} + void perf_mmap__get(struct perf_mmap *map) { refcount_inc(&map->refcnt); |