Re: [PATCH 3/3] perf, x86: Add INST_RETIRED.PREC_DIST workarounds

From: Peter Zijlstra
Date: Wed Aug 13 2014 - 04:10:38 EST


On Tue, Aug 12, 2014 at 06:45:15PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> On Broadwell INST_RETIRED.PREC_DIST cannot be used with any period
> that doesn't have the lowest 6 bits cleared. And the period
> should not be smaller than 128.
>
> Add a new callback to enforce this, and set it for Broadwell.
>
> This is erratum BDM57 and BDM11.

Urgh, this blows.

> +/*
> + * Broadwell:
> + * The INST_RETIRED.ALL period always needs to have lowest
> + * 6bits cleared (BDM57). It shall not use a period smaller
> + * than 100 (BDM11). We combine the two to enforce
> + * a min-period of 128.
> + */
> +static unsigned bdw_limit_period(struct perf_event *event, unsigned left)
> +{
> + if ((event->hw.config & 0xffff) == 0x1c0) {

ISTR we have actual proper defines for that.

> + if (left < 128)
> + left = 128;
> + left &= ~0x3fu;
> + }
> + return left;
> +}

Attachment: pgpY_S02sqjak.pgp
Description: PGP signature