lkml.org 
[lkml]   [2015]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v8 12/14] x86: perf: intel_pt: Intel PT PMU driver
On Fri, Nov 14, 2014 at 03:43:45PM +0200, Alexander Shishkin wrote:
> +static void pt_handle_status(struct pt *pt)
> +{
> + struct pt_buffer *buf = perf_get_aux(&pt->handle);
> + int advance = 0;
> + u64 status;
> +
> + rdmsrl(MSR_IA32_RTIT_STATUS, status);
> +
> + if (status & RTIT_STATUS_ERROR) {
> + pr_err_ratelimited("ToPA ERROR encountered, trying to recover\n");
> + pt_topa_dump(buf);
> + status &= ~RTIT_STATUS_ERROR;
> + }
> +
> + if (status & RTIT_STATUS_STOPPED) {
> + status &= ~RTIT_STATUS_STOPPED;
> +
> + /*
> + * On systems that only do single-entry ToPA, hitting STOP
> + * means we are already losing data; need to let the decoder
> + * know.
> + */
> + if (!pt_cap_get(PT_CAP_topa_multiple_entries) ||
> + buf->output_off == sizes(TOPA_ENTRY(buf->cur, buf->cur_idx)->size)) {
> + local_inc(&buf->lost);
> + advance++;
> + }
> + }
> +
> + /*
> + * Also on single-entry ToPA implementations, interrupt will come
> + * before the output reaches its output region's boundary.
> + */

My understanding was that, while yes it will attempt to generate the
interrupt early, there is absolutely no guarantee it will in fact arrive
in time or even it if does, guarantee that there is buffer left by the
time you're ready to read it.

> + if (!pt_cap_get(PT_CAP_topa_multiple_entries) && !buf->snapshot &&
> + pt_buffer_region_size(buf) - buf->output_off <= TOPA_PMI_MARGIN) {

Now this check appears to indeed cater for this scenario where the
buffer is overran, right?

> + void *head = pt_buffer_region(buf);
> +
> + /* everything within this margin needs to be zeroed out */
> + memset(head + buf->output_off, 0,
> + pt_buffer_region_size(buf) -
> + buf->output_off);
> + advance++;
> + }
> +
> + if (advance)
> + pt_buffer_advance(buf);
> +
> + wrmsrl(MSR_IA32_RTIT_STATUS, status);
> +}


\
 
 \ /
  Last update: 2015-01-09 14:21    [W:0.263 / U:0.392 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site