[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150421105239.GA26455@gmail.com>
Date: Tue, 21 Apr 2015 12:52:40 +0200
From: Ingo Molnar <mingo@...nel.org>
To: Jiri Olsa <jolsa@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Andi Kleen <andi@...stfloor.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Paul Mackerras <paulus@...ba.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH] perf/x86/intel: Add cpu_(prepare|starting|dying) for
core_pmu
* Jiri Olsa <jolsa@...nel.org> wrote:
> The core_pmu does not define cpu_* callbacks, which handles
> allocation of 'struct cpu_hw_events::shared_regs' data,
> initialization of debug store and PMU_FL_EXCL_CNTRS counters.
>
> While this probably won't happen on bare metal, virtual CPU can
> define x86_pmu.extra_regs together with PMU version 1 and thus
> be using core_pmu -> using shared_regs data without it being
> allocated. That could could leave to following panic:
>
> BUG: unable to handle kernel NULL pointer dereference at (null)
> IP: [<ffffffff8152cd4f>] _spin_lock_irqsave+0x1f/0x40
ok.
> diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
> index 9da2400c2ec3..0a61a9a021de 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel.c
> +++ b/arch/x86/kernel/cpu/perf_event_intel.c
> @@ -2533,6 +2533,10 @@ ssize_t intel_event_sysfs_show(char *page, u64 config)
> return x86_event_sysfs_show(page, config, event);
> }
>
> +static int intel_pmu_cpu_prepare(int cpu);
> +static void intel_pmu_cpu_starting(int cpu);
> +static void intel_pmu_cpu_dying(int cpu);
> +
> static __initconst const struct x86_pmu core_pmu = {
> .name = "core",
> .handle_irq = x86_pmu_handle_irq,
> @@ -2559,6 +2563,9 @@ static __initconst const struct x86_pmu core_pmu = {
> .guest_get_msrs = core_guest_get_msrs,
> .format_attrs = intel_arch_formats_attr,
> .events_sysfs_show = intel_event_sysfs_show,
> + .cpu_prepare = intel_pmu_cpu_prepare,
> + .cpu_starting = intel_pmu_cpu_starting,
> + .cpu_dying = intel_pmu_cpu_dying,
> };
Instead of adding prototype declarations, please arrange the x86_pmu
definition's position so that it comes after the required functions -
so that no prototypes are needed.
Thanks,
Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists