91
91
#include <asm/cpu_device_id.h>
92
92
#include "../perf_event.h"
93
93
94
+ MODULE_LICENSE ("GPL" );
95
+
94
96
#define DEFINE_CSTATE_FORMAT_ATTR (_var , _name , _format ) \
95
97
static ssize_t __cstate_##_var##_show(struct kobject *kobj, \
96
98
struct kobj_attribute *attr, \
@@ -432,6 +434,11 @@ static int cstate_cpu_notifier(struct notifier_block *self,
432
434
return NOTIFY_OK ;
433
435
}
434
436
437
+ static struct notifier_block cstate_cpu_nb = {
438
+ .notifier_call = cstate_cpu_notifier ,
439
+ .priority = CPU_PRI_PERF + 1 ,
440
+ };
441
+
435
442
static struct pmu cstate_core_pmu = {
436
443
.attr_groups = core_attr_groups ,
437
444
.name = "cstate_core" ,
@@ -581,7 +588,7 @@ static int __init cstate_probe(const struct cstate_model *cm)
581
588
return (has_cstate_core || has_cstate_pkg ) ? 0 : - ENODEV ;
582
589
}
583
590
584
- static void __init cstate_cleanup (void )
591
+ static inline void cstate_cleanup (void )
585
592
{
586
593
if (has_cstate_core )
587
594
perf_pmu_unregister (& cstate_core_pmu );
@@ -616,7 +623,7 @@ static int __init cstate_init(void)
616
623
goto out ;
617
624
}
618
625
}
619
- __perf_cpu_notifier ( cstate_cpu_notifier );
626
+ __register_cpu_notifier ( & cstate_cpu_nb );
620
627
out :
621
628
cpu_notifier_register_done ();
622
629
return err ;
@@ -640,4 +647,13 @@ static int __init cstate_pmu_init(void)
640
647
641
648
return cstate_init ();
642
649
}
643
- device_initcall (cstate_pmu_init );
650
+ module_init (cstate_pmu_init );
651
+
652
+ static void __exit cstate_pmu_exit (void )
653
+ {
654
+ cpu_notifier_register_begin ();
655
+ __unregister_cpu_notifier (& cstate_cpu_nb );
656
+ cstate_cleanup ();
657
+ cpu_notifier_register_done ();
658
+ }
659
+ module_exit (cstate_pmu_exit );
0 commit comments