aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/events/intel/cstate.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2016-03-20 14:59:03 -0400
committerIngo Molnar <mingo@kernel.org>2016-03-31 04:30:37 -0400
commitd29859e7777ebc2c8e2db6e4d8e299f50fc26414 (patch)
tree44cf303b2d103181acf98877bb26f564f7c21c39 /arch/x86/events/intel/cstate.c
parent424646eeadab64da959f960928804e5289417819 (diff)
x86/perf/intel/cstate: Sanitize error handling
There is no point in WARN_ON() inside of a well known init function. We already know the call stack and it's really not of critical importance whether the registration of a PMU fails. Aside of that for consistency reasons it's just pointless to try to register another PMU if the first register attempt failed. There is also no value in keeping one PMU if the second one can not be registered. Make it consistent so we can finaly modularize the driver. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Borislav Petkov <bp@suse.de> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kan Liang <kan.liang@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Vince Weaver <vincent.weaver@maine.edu> Link: http://lkml.kernel.org/r/20160320185623.579794064@linutronix.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/events/intel/cstate.c')
-rw-r--r--arch/x86/events/intel/cstate.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c
index 1aac40f1e4fe..e90ec9e73ac7 100644
--- a/arch/x86/events/intel/cstate.c
+++ b/arch/x86/events/intel/cstate.c
@@ -581,37 +581,45 @@ static int __init cstate_probe(const struct cstate_model *cm)
581 return (has_cstate_core || has_cstate_pkg) ? 0 : -ENODEV; 581 return (has_cstate_core || has_cstate_pkg) ? 0 : -ENODEV;
582} 582}
583 583
584static void __init cstate_cpumask_init(void) 584static void __init cstate_cleanup(void)
585{ 585{
586 int cpu; 586 if (has_cstate_core)
587 587 perf_pmu_unregister(&cstate_core_pmu);
588 cpu_notifier_register_begin();
589
590 for_each_online_cpu(cpu)
591 cstate_cpu_init(cpu);
592 588
593 __perf_cpu_notifier(cstate_cpu_notifier); 589 if (has_cstate_pkg)
594 590 perf_pmu_unregister(&cstate_pkg_pmu);
595 cpu_notifier_register_done();
596} 591}
597 592
598static void __init cstate_pmus_register(void) 593static int __init cstate_init(void)
599{ 594{
600 int err; 595 int cpu, err;
596
597 cpu_notifier_register_begin();
598 for_each_online_cpu(cpu)
599 cstate_cpu_init(cpu);
601 600
602 if (has_cstate_core) { 601 if (has_cstate_core) {
603 err = perf_pmu_register(&cstate_core_pmu, cstate_core_pmu.name, -1); 602 err = perf_pmu_register(&cstate_core_pmu, cstate_core_pmu.name, -1);
604 if (WARN_ON(err)) 603 if (err) {
605 pr_info("Failed to register PMU %s error %d\n", 604 has_cstate_core = false;
606 cstate_core_pmu.name, err); 605 pr_info("Failed to register cstate core pmu\n");
606 goto out;
607 }
607 } 608 }
608 609
609 if (has_cstate_pkg) { 610 if (has_cstate_pkg) {
610 err = perf_pmu_register(&cstate_pkg_pmu, cstate_pkg_pmu.name, -1); 611 err = perf_pmu_register(&cstate_pkg_pmu, cstate_pkg_pmu.name, -1);
611 if (WARN_ON(err)) 612 if (err) {
612 pr_info("Failed to register PMU %s error %d\n", 613 has_cstate_pkg = false;
613 cstate_pkg_pmu.name, err); 614 pr_info("Failed to register cstate pkg pmu\n");
615 cstate_cleanup();
616 goto out;
617 }
614 } 618 }
619 __perf_cpu_notifier(cstate_cpu_notifier);
620out:
621 cpu_notifier_register_done();
622 return err;
615} 623}
616 624
617static int __init cstate_pmu_init(void) 625static int __init cstate_pmu_init(void)
@@ -630,10 +638,6 @@ static int __init cstate_pmu_init(void)
630 if (err) 638 if (err)
631 return err; 639 return err;
632 640
633 cstate_cpumask_init(); 641 return cstate_init();
634
635 cstate_pmus_register();
636
637 return 0;
638} 642}
639device_initcall(cstate_pmu_init); 643device_initcall(cstate_pmu_init);