perf evlist: Support non overwrite mode in perf_evlist__read_on_cpu

I.e. stash the overwrite mode in struct perf_evlist and act accordingly
in perf_evlist__read_on_cpu, not checking for overwrites and touching
the tail after consuming one event, like perf record does, for instance.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ef2bf6d0
...@@ -116,8 +116,8 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) ...@@ -116,8 +116,8 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
unsigned int old = md->prev; unsigned int old = md->prev;
unsigned char *data = md->base + page_size; unsigned char *data = md->base + page_size;
event_t *event = NULL; event_t *event = NULL;
int diff;
if (evlist->overwrite) {
/* /*
* If we're further behind than half the buffer, there's a chance * If we're further behind than half the buffer, there's a chance
* the writer will bite our tail and mess up the samples under us. * the writer will bite our tail and mess up the samples under us.
...@@ -126,7 +126,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) ...@@ -126,7 +126,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
* *
* In either case, truncate and restart at head. * In either case, truncate and restart at head.
*/ */
diff = head - old; int diff = head - old;
if (diff > md->mask / 2 || diff < 0) { if (diff > md->mask / 2 || diff < 0) {
fprintf(stderr, "WARNING: failed to keep up with mmap data.\n"); fprintf(stderr, "WARNING: failed to keep up with mmap data.\n");
...@@ -135,6 +135,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) ...@@ -135,6 +135,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
*/ */
old = head; old = head;
} }
}
if (old != head) { if (old != head) {
size_t size; size_t size;
...@@ -166,5 +167,9 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) ...@@ -166,5 +167,9 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
} }
md->prev = old; md->prev = old;
if (!evlist->overwrite)
perf_mmap__write_tail(md, old);
return event; return event;
} }
...@@ -16,6 +16,7 @@ struct perf_evlist { ...@@ -16,6 +16,7 @@ struct perf_evlist {
int nr_entries; int nr_entries;
int nr_fds; int nr_fds;
int mmap_len; int mmap_len;
bool overwrite;
event_t event_copy; event_t event_copy;
struct perf_mmap *mmap; struct perf_mmap *mmap;
struct pollfd *pollfd; struct pollfd *pollfd;
......
...@@ -327,6 +327,7 @@ int perf_evlist__mmap(struct perf_evlist *evlist, struct cpu_map *cpus, ...@@ -327,6 +327,7 @@ int perf_evlist__mmap(struct perf_evlist *evlist, struct cpu_map *cpus,
perf_evlist__alloc_pollfd(evlist, cpus->nr, threads->nr) < 0) perf_evlist__alloc_pollfd(evlist, cpus->nr, threads->nr) < 0)
return -ENOMEM; return -ENOMEM;
evlist->overwrite = overwrite;
evlist->mmap_len = (pages + 1) * page_size; evlist->mmap_len = (pages + 1) * page_size;
first_evsel = list_entry(evlist->entries.next, struct perf_evsel, node); first_evsel = list_entry(evlist->entries.next, struct perf_evsel, node);
......
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