Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 362517
b: refs/heads/master
c: dd9c086
h: refs/heads/master
i:
  362515: d823c33
v: v3
  • Loading branch information
Stephane Eranian authored and Ingo Molnar committed Mar 21, 2013
1 parent 6978185 commit e5ead2d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0e48026ae7abf871e51eaa9183c81ab5bef4c267
refs/heads/master: dd9c086d9f507d02d5ba4d7c5eef4bb9518088b8
2 changes: 1 addition & 1 deletion trunk/kernel/events/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct ring_buffer {
int page_order; /* allocation order */
#endif
int nr_pages; /* nr of data pages */
int writable; /* are we writable */
int overwrite; /* can overwrite itself */

atomic_t poll; /* POLL_ for wakeups */

Expand Down
22 changes: 18 additions & 4 deletions trunk/kernel/events/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,24 @@
static bool perf_output_space(struct ring_buffer *rb, unsigned long tail,
unsigned long offset, unsigned long head)
{
unsigned long mask;
unsigned long sz = perf_data_size(rb);
unsigned long mask = sz - 1;

if (!rb->writable)
/*
* check if user-writable
* overwrite : over-write its own tail
* !overwrite: buffer possibly drops events.
*/
if (rb->overwrite)
return true;

mask = perf_data_size(rb) - 1;
/*
* verify that payload is not bigger than buffer
* otherwise masking logic may fail to detect
* the "not enough space" condition
*/
if ((head - offset) > sz)
return false;

offset = (offset - tail) & mask;
head = (head - tail) & mask;
Expand Down Expand Up @@ -212,7 +224,9 @@ ring_buffer_init(struct ring_buffer *rb, long watermark, int flags)
rb->watermark = max_size / 2;

if (flags & RING_BUFFER_WRITABLE)
rb->writable = 1;
rb->overwrite = 0;
else
rb->overwrite = 1;

atomic_set(&rb->refcount, 1);

Expand Down

0 comments on commit e5ead2d

Please sign in to comment.