Skip to content

Commit

Permalink
ARM: perf: register cpu_notifier at driver init
Browse files Browse the repository at this point in the history
The current practice of registering the cpu hotplug notifier at PMU
registration time won't be safe with multiple PMUs, as we'll repeatedly
attempt to register the notifier. This has the unfortunate effect of
silently corrupting the notifier list, leading to boot stalling.

Instead, register the notifier at init time. Its sanity checks will
prevent anything bad from happening if the notifier is called before we
have any PMUs registered.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
  • Loading branch information
Mark Rutland authored and Will Deacon committed Nov 9, 2012
1 parent 7279adb commit 2a4961b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions arch/arm/kernel/perf_event_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ static int __devinit cpu_pmu_device_probe(struct platform_device *pdev)
cpu_pmu = pmu;
cpu_pmu->plat_device = pdev;
cpu_pmu_init(cpu_pmu);
register_cpu_notifier(&cpu_pmu_hotplug_notifier);
armpmu_register(cpu_pmu, cpu_pmu->name, PERF_TYPE_RAW);

return 0;
Expand All @@ -303,6 +302,16 @@ static struct platform_driver cpu_pmu_driver = {

static int __init register_pmu_driver(void)
{
return platform_driver_register(&cpu_pmu_driver);
int err;

err = register_cpu_notifier(&cpu_pmu_hotplug_notifier);
if (err)
return err;

err = platform_driver_register(&cpu_pmu_driver);
if (err)
unregister_cpu_notifier(&cpu_pmu_hotplug_notifier);

return err;
}
device_initcall(register_pmu_driver);

0 comments on commit 2a4961b

Please sign in to comment.