提交 441430eb 编写于 作者: A Alexander Shishkin 提交者: Ingo Molnar

perf/aux: Only update ->aux_wakeup in non-overwrite mode

The following commit:

  d9a50b02 ("perf/aux: Ensure aux_wakeup represents most recent wakeup index")

changed the AUX wakeup position calculation to rounddown(), which causes
a division-by-zero in AUX overwrite mode (aka "snapshot mode").

The zero denominator results from the fact that perf record doesn't set
aux_watermark to anything, in which case the kernel will set it to half
the AUX buffer size, but only for non-overwrite mode. In the overwrite
mode aux_watermark stays zero.

The good news is that, AUX overwrite mode, wakeups don't happen and
related bookkeeping is not relevant, so we can simply forego the whole
wakeup updates.
Signed-off-by: NAlexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: will.deacon@arm.com
Link: http://lkml.kernel.org/r/20170906160811.16510-1-alexander.shishkin@linux.intel.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 770b782f
...@@ -412,6 +412,19 @@ void *perf_aux_output_begin(struct perf_output_handle *handle, ...@@ -412,6 +412,19 @@ void *perf_aux_output_begin(struct perf_output_handle *handle,
return NULL; return NULL;
} }
static bool __always_inline rb_need_aux_wakeup(struct ring_buffer *rb)
{
if (rb->aux_overwrite)
return false;
if (rb->aux_head - rb->aux_wakeup >= rb->aux_watermark) {
rb->aux_wakeup = rounddown(rb->aux_head, rb->aux_watermark);
return true;
}
return false;
}
/* /*
* Commit the data written by hardware into the ring buffer by adjusting * Commit the data written by hardware into the ring buffer by adjusting
* aux_head and posting a PERF_RECORD_AUX into the perf buffer. It is the * aux_head and posting a PERF_RECORD_AUX into the perf buffer. It is the
...@@ -451,10 +464,8 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size) ...@@ -451,10 +464,8 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size)
} }
rb->user_page->aux_head = rb->aux_head; rb->user_page->aux_head = rb->aux_head;
if (rb->aux_head - rb->aux_wakeup >= rb->aux_watermark) { if (rb_need_aux_wakeup(rb))
wakeup = true; wakeup = true;
rb->aux_wakeup = rounddown(rb->aux_head, rb->aux_watermark);
}
if (wakeup) { if (wakeup) {
if (handle->aux_flags & PERF_AUX_FLAG_TRUNCATED) if (handle->aux_flags & PERF_AUX_FLAG_TRUNCATED)
...@@ -484,9 +495,8 @@ int perf_aux_output_skip(struct perf_output_handle *handle, unsigned long size) ...@@ -484,9 +495,8 @@ int perf_aux_output_skip(struct perf_output_handle *handle, unsigned long size)
rb->aux_head += size; rb->aux_head += size;
rb->user_page->aux_head = rb->aux_head; rb->user_page->aux_head = rb->aux_head;
if (rb->aux_head - rb->aux_wakeup >= rb->aux_watermark) { if (rb_need_aux_wakeup(rb)) {
perf_output_wakeup(handle); perf_output_wakeup(handle);
rb->aux_wakeup = rounddown(rb->aux_head, rb->aux_watermark);
handle->wakeup = rb->aux_wakeup + rb->aux_watermark; handle->wakeup = rb->aux_wakeup + rb->aux_watermark;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册