Teach kerneltop about the new output ABI.[snip]
XXX: anybody fancy integrating the PID/TID data into the output?
Bump the mmap_data pages a little because we bloated the output and
have to be more careful about overruns with structured data.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
---
[snip]
@@ -1147,28 +1152,75 @@ static void mmap_read(struct mmap_data *
unsigned int head = mmap_read_head(md);
unsigned int old = md->prev;
unsigned char *data = md->base + page_size;
+ int diff;
gettimeofday(&this_read, NULL);
- if (head - old > md->mask) {
+ /*
+ * If we're further behind than half the buffer, there's a chance
+ * the writer will bite our tail and screw up the events under us.
+ *
+ * If we somehow ended up ahead of the head, we got messed up.
+ *
+ * In either case, truncate and restart at head.
+ */
+ diff = head - old;
+ if (diff > md->mask / 2 || diff < 0) {
struct timeval iv;
unsigned long msecs;
timersub(&this_read, &last_read, &iv);
msecs = iv.tv_sec*1000 + iv.tv_usec/1000;
- fprintf(stderr, "WARNING: failed to keep up with mmap data. Last read %lu msecs ago.\n", msecs);
+ fprintf(stderr, "WARNING: failed to keep up with mmap data."
+ " Last read %lu msecs ago.\n", msecs);