[patch] perf_events: fix perf buffer watermark setting

From: Vince Weaver
Date: Wed Jun 01 2011 - 15:16:04 EST



Since 2.6.36 (specifically commit d57e34fdd60be7ffd0b1d86bfa1a553df86b7172)
the perf_buffer_init_code() has been mis-setting the buffer watermark if
perf_event_attr.wakeup_events has a non-zero value.

This is because perf_event_attr.wakeup_events is a union with
perf_event_attr.wakeup_watermark.

This commit re-enables the check for perf_event_attr.watermark being
set before continuing with setting a non-default watermark.

This bug is most noticable when you are trying to use PERF_IOC_REFRESH
with a value larger than one and perf_event_attr.wakeup_events is set to
one. In this case the buffer watermark will be set to 1 and you will
get extraneous POLL_IN overflows rather than POLL_HUP as expected.

Signed-off-by: Vince Weaver <vweaver1@xxxxxxxxxxxx>


diff --git a/kernel/events/core.c b/kernel/events/core.c
index d863b3c..b949661 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3787,7 +3787,8 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
if (vma->vm_flags & VM_WRITE)
flags |= PERF_BUFFER_WRITABLE;

- buffer = perf_buffer_alloc(nr_pages, event->attr.wakeup_watermark,
+ buffer = perf_buffer_alloc(nr_pages,
+ event->attr.watermark?event->attr.wakeup_watermark:0,
event->cpu, flags);
if (!buffer) {
ret = -ENOMEM;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/