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

Peter Zijlstra
2014-06-05T13:38:49Z

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

On Wed, Jun 04, 2014 at 11:34:14PM +0200, Stephane Eranian wrote:
> static void
> +intel_start_scheduling(struct cpu_hw_events *cpuc)
> +{

> + /*
> + * lock shared state until we are done scheduling
> + * in stop_event_scheduling()
> + * makes scheduling appear as a transaction
> + */
> + spin_lock_irqsave(&excl_cntrs->lock, excl_cntrs->lock_flags);
> +
> + /*
> + * save initial state of sibling thread
> + */
> + memcpy(xlo->init_state, xlo->state, sizeof(xlo->init_state));
> +}
> +
> +static void
> +intel_stop_scheduling(struct cpu_hw_events *cpuc)
> +{

> + /*
> + * make new sibling thread state visible
> + */
> + memcpy(xlo->state, xlo->init_state, sizeof(xlo->state));
> +
> + xl->sched_started = false;
> + /*
> + * release shared state lock (lock acquire in intel_start_scheduling())
> + */
> + spin_unlock_irqrestore(&excl_cntrs->lock, excl_cntrs->lock_flags);
> +}

Do you really need the irqsave/irqrestore? From what I can tell this is
always called under perf_event_context::lock and that is already an
IRQ-safe lock, so interrupts should always be disabled here.

Also, it looks like xl->state is the effective state, and ->init_state
is the work state? Is init the right name for this?

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