Skip to content

Commit

Permalink
libperf: Adopt perf_mmap__get() function from tools/perf
Browse files Browse the repository at this point in the history
Move perf_mmap__get() from tools/perf to libperf in the internal header
internal/mmap.h.

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-6-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Oct 10, 2019
1 parent 32c261c commit e75710f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ static int record__aio_pushfn(struct mmap *map, void *to, void *buf, size_t size
* after started aio request completion or at record__aio_push()
* if the request failed to start.
*/
perf_mmap__get(map);
perf_mmap__get(&map->core);
}

aio->size += size;
Expand Down
1 change: 1 addition & 0 deletions tools/perf/lib/include/internal/mmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ 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__get(struct perf_mmap *map);

#endif /* __LIBPERF_INTERNAL_MMAP_H */
5 changes: 5 additions & 0 deletions tools/perf/lib/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp,
map->cpu = cpu;
return 0;
}

void perf_mmap__get(struct perf_mmap *map)
{
refcount_inc(&map->refcnt);
}
2 changes: 1 addition & 1 deletion tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ static int evlist__mmap_per_evsel(struct evlist *evlist, int idx,
if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
return -1;

perf_mmap__get(&maps[idx]);
perf_mmap__get(&maps[idx].core);
}

revent = perf_evlist__should_poll(evlist, evsel) ? POLLIN : 0;
Expand Down
5 changes: 0 additions & 5 deletions tools/perf/util/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ static bool perf_mmap__empty(struct mmap *map)
return perf_mmap__read_head(map) == map->core.prev && !map->auxtrace_mmap.base;
}

void perf_mmap__get(struct mmap *map)
{
refcount_inc(&map->core.refcnt);
}

void perf_mmap__put(struct mmap *map)
{
BUG_ON(map->core.base && refcount_read(&map->core.refcnt) == 0);
Expand Down
1 change: 0 additions & 1 deletion tools/perf/util/mmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ struct mmap_params {
int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu);
void perf_mmap__munmap(struct mmap *map);

void perf_mmap__get(struct mmap *map);
void perf_mmap__put(struct mmap *map);

void perf_mmap__consume(struct mmap *map);
Expand Down

0 comments on commit e75710f

Please sign in to comment.