static int __init cstate_init(void) { int err; cpuhp_setup_state(CPUHP_AP_PERF_X86_CSTATE_STARTING, "perf/x86/cstate:starting", cstate_cpu_init, NULL); cpuhp_setup_state(CPUHP_AP_PERF_X86_CSTATE_ONLINE, "perf/x86/cstate:online", NULL, cstate_cpu_exit); if (has_cstate_core) { err = perf_pmu_register(&cstate_core_pmu, cstate_core_pmu.name, -1); if (err) { has_cstate_core = false; pr_info("Failed to register cstate core pmu\n"); cstate_cleanup(); return err; } } if (has_cstate_pkg) { err = perf_pmu_register(&cstate_pkg_pmu, cstate_pkg_pmu.name, -1); if (err) { has_cstate_pkg = false; pr_info("Failed to register cstate pkg pmu\n"); cstate_cleanup(); return err; } } return 0; }
static void __exit cstate_pmu_exit(void) { cpuhp_remove_state_nocalls(CPUHP_AP_PERF_X86_CSTATE_ONLINE); cpuhp_remove_state_nocalls(CPUHP_AP_PERF_X86_CSTATE_STARTING); cstate_cleanup(); }
static void __exit cstate_pmu_exit(void) { cstate_cleanup(); }