perf_events: Fix validation of events using an extra reg

The validate_group() function needs to validate events with
extra shared regs. Within an event group, only events with
the same value for the extra reg can co-exist. This was not
checked by validate_group() because it was missing the
shared_regs logic.

This patch changes the allocation of the fake cpuc used for
validation to also point to a fake shared_regs structure such
that group events be properly testing.

It modifies __intel_shared_reg_get_constraints() to use
spin_lock_irqsave() to avoid lockdep issues.

Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20110606145708.GA7279@quad
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Stephane Eranian
2011-06-06 16:57:08 +02:00
committed by Ingo Molnar
parent efc9f05df2
commit cd8a38d33e
2 changed files with 57 additions and 18 deletions

View File

@@ -1027,14 +1027,18 @@ __intel_shared_reg_get_constraints(struct cpu_hw_events *cpuc,
{
struct event_constraint *c = &emptyconstraint;
struct er_account *era;
unsigned long flags;
/* already allocated shared msr */
if (reg->alloc || !cpuc->shared_regs)
if (reg->alloc)
return &unconstrained;
era = &cpuc->shared_regs->regs[reg->idx];
raw_spin_lock(&era->lock);
/*
* we use spin_lock_irqsave() to avoid lockdep issues when
* passing a fake cpuc
*/
raw_spin_lock_irqsave(&era->lock, flags);
if (!atomic_read(&era->ref) || era->config == reg->config) {
@@ -1058,7 +1062,7 @@ __intel_shared_reg_get_constraints(struct cpu_hw_events *cpuc,
*/
c = &unconstrained;
}
raw_spin_unlock(&era->lock);
raw_spin_unlock_irqrestore(&era->lock, flags);
return c;
}
@@ -1524,4 +1528,8 @@ static int intel_pmu_init(void)
return 0;
}
static struct intel_shared_regs *allocate_shared_regs(int cpu)
{
return NULL;
}
#endif /* CONFIG_CPU_SUP_INTEL */