Re: [PATCH 5/9] perf/x86: implement cross-HT corruption bug workaround

Peter Zijlstra
2014-06-05T13:42:40Z

[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]

On Wed, Jun 04, 2014 at 11:34:14PM +0200, Stephane Eranian wrote:
> +static void intel_commit_scheduling(struct cpu_hw_events *cpuc,
> + struct perf_event *event, int cntr)
> +{
> + struct intel_excl_cntrs *excl_cntrs = cpuc->excl_cntrs;
> + struct event_constraint *c = event->hw.constraint;
> + struct intel_excl_states *xlo, *xl;
> + int tid = cpuc->excl_thread_id;
> + int o_tid = 1 - tid;
> + int is_excl;
> +
> + if (cpuc->is_fake || !c)
> + return;
> +
> + is_excl = c->flags & PERF_X86_EVENT_EXCL;
> +
> + if (!(c->flags & PERF_X86_EVENT_DYNAMIC))
> + return;
> +
> + WARN_ON_ONCE(!excl_cntrs);
> +
> + if (!excl_cntrs)
> + return;
> +
> + xl = &excl_cntrs->states[tid];
> + xlo = &excl_cntrs->states[o_tid];
> +
> + WARN_ON_ONCE(!spin_is_locked(&excl_cntrs->lock));

Use:
lockdep_assert_held(&excl_cntrs->lock);

It also checks to see the current context is actually the lock holder,
and it doesn't generate any code when !lockdep.

> +
> + if (cntr >= 0) {
> + if (is_excl)
> + xlo->init_state[cntr] = INTEL_EXCL_EXCLUSIVE;
> + else
> + xlo->init_state[cntr] = INTEL_EXCL_SHARED;
> + }
> }

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]