overlay: Fix wraparound handling of perf ringbuffer
authorChris Wilson <chris@chris-wilson.co.uk>
Sat, 17 Aug 2013 17:09:40 +0000 (18:09 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Sat, 17 Aug 2013 17:09:40 +0000 (18:09 +0100)
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
overlay/gpu-perf.c

index d2f09f5..7751132 100644 (file)
@@ -226,7 +226,7 @@ int gpu_perf_update(struct gpu_perf *gp)
                rmb();
 
                if (head < tail)
-                       tail = head; /* XXX */
+                       head += size;
 
                data = (uint8_t *)mmap + gp->page_size;
                while (head - tail >= sizeof (struct perf_event_header)) {
@@ -262,7 +262,7 @@ int gpu_perf_update(struct gpu_perf *gp)
                        tail += header->size;
                }
 
-               mmap->data_tail = tail;
+               mmap->data_tail = tail & mask;
        }
 
        free(buffer);