lkml.org 
[lkml]   [2015]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf/x86/intel: Add cpu_(prepare|starting|dying) for core_pmu

* Jiri Olsa <jolsa@kernel.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


\
 
 \ /
  Last update: 2015-04-21 13:21    [W:0.105 / U:12.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site