Commit 8df7a869 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

libperf: Add 'overwrite' to 'struct perf_mmap'

Move 'overwrite' from tools/perf's mmap to libperf's perf_mmap struct.

Committer notes:

Add stdbool.h as we start using 'bool'.
Signed-off-by: default avatarJiri 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 <a.p.zijlstra@chello.nl>
Link: http://lore.kernel.org/lkml/20190913132355.21634-17-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ebe4d72b
......@@ -4,6 +4,7 @@
#include <linux/refcount.h>
#include <linux/types.h>
#include <stdbool.h>
/**
* struct perf_mmap - perf's ring buffer mmap details
......@@ -19,6 +20,7 @@ struct perf_mmap {
u64 prev;
u64 start;
u64 end;
bool overwrite;
};
#endif /* __LIBPERF_INTERNAL_MMAP_H */
......@@ -709,7 +709,7 @@ static struct mmap *evlist__alloc_mmap(struct evlist *evlist,
for (i = 0; i < evlist->nr_mmaps; i++) {
map[i].core.fd = -1;
map[i].overwrite = overwrite;
map[i].core.overwrite = overwrite;
/*
* When the perf_mmap() call is made we grab one refcount, plus
* one extra to let perf_mmap__consume() get the last
......
......@@ -93,12 +93,12 @@ union perf_event *perf_mmap__read_event(struct mmap *map)
return NULL;
/* non-overwirte doesn't pause the ringbuffer */
if (!map->overwrite)
if (!map->core.overwrite)
map->core.end = perf_mmap__read_head(map);
event = perf_mmap__read(map, &map->core.start, map->core.end);
if (!map->overwrite)
if (!map->core.overwrite)
map->core.prev = map->core.start;
return event;
......@@ -124,7 +124,7 @@ void perf_mmap__put(struct mmap *map)
void perf_mmap__consume(struct mmap *map)
{
if (!map->overwrite) {
if (!map->core.overwrite) {
u64 old = map->core.prev;
perf_mmap__write_tail(map, old);
......@@ -447,15 +447,15 @@ static int __perf_mmap__read_init(struct mmap *md)
unsigned char *data = md->core.base + page_size;
unsigned long size;
md->core.start = md->overwrite ? head : old;
md->core.end = md->overwrite ? old : head;
md->core.start = md->core.overwrite ? head : old;
md->core.end = md->core.overwrite ? old : head;
if ((md->core.end - md->core.start) < md->flush)
return -EAGAIN;
size = md->core.end - md->core.start;
if (size > (unsigned long)(md->core.mask) + 1) {
if (!md->overwrite) {
if (!md->core.overwrite) {
WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n");
md->core.prev = head;
......
......@@ -22,7 +22,6 @@ struct aiocb;
*/
struct mmap {
struct perf_mmap core;
bool overwrite;
struct auxtrace_mmap auxtrace_mmap;
char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);
#ifdef HAVE_AIO_SUPPORT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment