Re: [PATCH 07/36] libperf: Add perf_mmap__put() function

From: Arnaldo Carvalho de Melo
Date: Thu Oct 10 2019 - 09:11:11 EST


Em Mon, Oct 07, 2019 at 02:53:15PM +0200, Jiri Olsa escreveu:
> +++ b/tools/perf/lib/mmap.c
> @@ -3,10 +3,12 @@
> #include <internal/mmap.h>
> #include <internal/lib.h>
>
> -void perf_mmap__init(struct perf_mmap *map, bool overwrite)
> +void perf_mmap__init(struct perf_mmap *map, bool overwrite,
> + libperf_unmap_cb_t unmap_cb)
> {
> map->fd = -1;
> map->overwrite = overwrite;
> + map->unmap_cb = unmap_cb;
> refcount_set(&map->refcnt, 0);
> }
>
> @@ -40,9 +42,19 @@ void perf_mmap__munmap(struct perf_mmap *map)
> map->fd = -1;
> refcount_set(&map->refcnt, 0);
> }
> + if (map && map->unmap_cb)
> + map->unmap_cb(map);
> }
>
> void perf_mmap__get(struct perf_mmap *map)
> {
> refcount_inc(&map->refcnt);
> }
> +
> +void perf_mmap__put(struct perf_mmap *map)
> +{
> + BUG_ON(map->base && refcount_read(&map->refcnt) == 0);

Added missing linux/kernel.h to this file to pick up BUG_ON().

- Arnaldo