Re: [PATCH 2/3] perf_events: fix validation of events using an extrareg (v3)

From: Stephane Eranian
Date: Mon May 30 2011 - 09:17:01 EST


On Mon, May 30, 2011 at 3:11 PM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Mon, 2011-05-23 at 18:12 +0200, Stephane Eranian wrote:
> > +static struct cpu_hw_events *allocate_fake_cpuc(void)
> > +{
> > + Â Â Â struct cpu_hw_events *cpuc;
> > + Â Â Â int cpu = smp_processor_id();
> > +
> > + Â Â Â cpuc = kzalloc(sizeof(*cpuc), GFP_KERNEL);
> > + Â Â Â if (!cpuc)
> > + Â Â Â Â Â Â Â return ERR_PTR(-ENOMEM);
> > +
> > + Â Â Â /* only needed, if we have extra_regs */
> > + Â Â Â if (x86_pmu.extra_regs) {
> > + Â Â Â Â Â Â Â cpuc->shared_regs = allocate_shared_regs(cpu);
> > + Â Â Â Â Â Â Â if (!cpuc->shared_regs)
> > + Â Â Â Â Â Â Â Â Â Â Â goto error;
> > + Â Â Â }
> > + Â Â Â return cpuc;
> > +error:
> > + Â Â Â free_fake_cpuc(cpuc);
> > + Â Â Â return ERR_PTR(-ENOMEM);
> > +}
>
> Ingo found a case where that use of allocate_shared_regs() failed to
> compile but didn't provide a .config. I suspect its CONFIG_CPU_SUP_INTEL
> and the below should fix it. I will try to push that again later today.
>
Yes, it is quite possible. I think you are right about the cause of
this problem.
The alloate routine is in the Intel-specific code. If you don't
compile for Intel
then you will get an undefined symbol. It is not clear to me why you would
compile with Intel support, though.

> ---
> diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
> index 41178c8..cf90e31 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel.c
> +++ b/arch/x86/kernel/cpu/perf_event_intel.c
> @@ -1528,4 +1623,9 @@ 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 */
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/