aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/util/mmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/mmap.c')
-rw-r--r--tools/perf/util/mmap.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index f246dd403507..abe7cbe6c95f 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -13,6 +13,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h> // sysconf()
+#include <perf/mmap.h>
#ifdef HAVE_LIBNUMA_SUPPORT
#include <numaif.h>
#endif
@@ -95,7 +96,7 @@ union perf_event *perf_mmap__read_event(struct mmap *map)
/* non-overwirte doesn't pause the ringbuffer */
if (!map->core.overwrite)
- map->core.end = perf_mmap__read_head(map);
+ map->core.end = perf_mmap__read_head(&map->core);
event = perf_mmap__read(map, &map->core.start, map->core.end);
@@ -105,25 +106,6 @@ union perf_event *perf_mmap__read_event(struct mmap *map)
return event;
}
-static bool perf_mmap__empty(struct mmap *map)
-{
- struct perf_event_mmap_page *pc = map->core.base;
-
- return perf_mmap__read_head(map) == map->core.prev && !pc->aux_size;
-}
-
-void perf_mmap__consume(struct mmap *map)
-{
- if (!map->core.overwrite) {
- u64 old = map->core.prev;
-
- perf_mmap__write_tail(map, old);
- }
-
- if (refcount_read(&map->core.refcnt) == 1 && perf_mmap__empty(map))
- perf_mmap__put(&map->core);
-}
-
int __weak auxtrace_mmap__mmap(struct auxtrace_mmap *mm __maybe_unused,
struct auxtrace_mmap_params *mp __maybe_unused,
void *userpg __maybe_unused,
@@ -420,7 +402,7 @@ static int overwrite_rb_find_range(void *buf, int mask, u64 *start, u64 *end)
*/
static int __perf_mmap__read_init(struct mmap *md)
{
- u64 head = perf_mmap__read_head(md);
+ u64 head = perf_mmap__read_head(&md->core);
u64 old = md->core.prev;
unsigned char *data = md->core.base + page_size;
unsigned long size;
@@ -437,7 +419,7 @@ static int __perf_mmap__read_init(struct mmap *md)
WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n");
md->core.prev = head;
- perf_mmap__consume(md);
+ perf_mmap__consume(&md->core);
return -EAGAIN;
}
@@ -466,7 +448,7 @@ int perf_mmap__read_init(struct mmap *map)
int perf_mmap__push(struct mmap *md, void *to,
int push(struct mmap *map, void *to, void *buf, size_t size))
{
- u64 head = perf_mmap__read_head(md);
+ u64 head = perf_mmap__read_head(&md->core);
unsigned char *data = md->core.base + page_size;
unsigned long size;
void *buf;
@@ -499,7 +481,7 @@ int perf_mmap__push(struct mmap *md, void *to,
}
md->core.prev = head;
- perf_mmap__consume(md);
+ perf_mmap__consume(&md->core);
out:
return rc;
}
@@ -518,5 +500,5 @@ void perf_mmap__read_done(struct mmap *map)
if (!refcount_read(&map->core.refcnt))
return;
- map->core.prev = perf_mmap__read_head(map);
+ map->core.prev = perf_mmap__read_head(&map->core);
}