@@ -131,7 +131,9 @@ struct rapl_pmus {
131
131
};
132
132
133
133
struct rapl_model {
134
+ struct perf_msr * rapl_msrs ;
134
135
unsigned long events ;
136
+ unsigned int msr_power_unit ;
135
137
bool apply_quirk ;
136
138
};
137
139
@@ -141,7 +143,7 @@ static struct rapl_pmus *rapl_pmus;
141
143
static cpumask_t rapl_cpu_mask ;
142
144
static unsigned int rapl_cntr_mask ;
143
145
static u64 rapl_timer_ms ;
144
- static struct perf_msr rapl_msrs [] ;
146
+ static struct perf_msr * rapl_msrs ;
145
147
146
148
static inline struct rapl_pmu * cpu_to_rapl_pmu (unsigned int cpu )
147
149
{
@@ -516,7 +518,7 @@ static bool test_msr(int idx, void *data)
516
518
return test_bit (idx , (unsigned long * ) data );
517
519
}
518
520
519
- static struct perf_msr rapl_msrs [] = {
521
+ static struct perf_msr intel_rapl_msrs [] = {
520
522
[PERF_RAPL_PP0 ] = { MSR_PP0_ENERGY_STATUS , & rapl_events_cores_group , test_msr },
521
523
[PERF_RAPL_PKG ] = { MSR_PKG_ENERGY_STATUS , & rapl_events_pkg_group , test_msr },
522
524
[PERF_RAPL_RAM ] = { MSR_DRAM_ENERGY_STATUS , & rapl_events_ram_group , test_msr },
@@ -578,13 +580,13 @@ static int rapl_cpu_online(unsigned int cpu)
578
580
return 0 ;
579
581
}
580
582
581
- static int rapl_check_hw_unit (bool apply_quirk )
583
+ static int rapl_check_hw_unit (struct rapl_model * rm )
582
584
{
583
585
u64 msr_rapl_power_unit_bits ;
584
586
int i ;
585
587
586
588
/* protect rdmsrl() to handle virtualization */
587
- if (rdmsrl_safe (MSR_RAPL_POWER_UNIT , & msr_rapl_power_unit_bits ))
589
+ if (rdmsrl_safe (rm -> msr_power_unit , & msr_rapl_power_unit_bits ))
588
590
return -1 ;
589
591
for (i = 0 ; i < NR_RAPL_DOMAINS ; i ++ )
590
592
rapl_hw_unit [i ] = (msr_rapl_power_unit_bits >> 8 ) & 0x1FULL ;
@@ -595,7 +597,7 @@ static int rapl_check_hw_unit(bool apply_quirk)
595
597
* "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2
596
598
* of 2. Datasheet, September 2014, Reference Number: 330784-001 "
597
599
*/
598
- if (apply_quirk )
600
+ if (rm -> apply_quirk )
599
601
rapl_hw_unit [PERF_RAPL_RAM ] = 16 ;
600
602
601
603
/*
@@ -676,13 +678,17 @@ static struct rapl_model model_snb = {
676
678
BIT (PERF_RAPL_PKG ) |
677
679
BIT (PERF_RAPL_PP1 ),
678
680
.apply_quirk = false,
681
+ .msr_power_unit = MSR_RAPL_POWER_UNIT ,
682
+ .rapl_msrs = intel_rapl_msrs ,
679
683
};
680
684
681
685
static struct rapl_model model_snbep = {
682
686
.events = BIT (PERF_RAPL_PP0 ) |
683
687
BIT (PERF_RAPL_PKG ) |
684
688
BIT (PERF_RAPL_RAM ),
685
689
.apply_quirk = false,
690
+ .msr_power_unit = MSR_RAPL_POWER_UNIT ,
691
+ .rapl_msrs = intel_rapl_msrs ,
686
692
};
687
693
688
694
static struct rapl_model model_hsw = {
@@ -691,19 +697,25 @@ static struct rapl_model model_hsw = {
691
697
BIT (PERF_RAPL_RAM ) |
692
698
BIT (PERF_RAPL_PP1 ),
693
699
.apply_quirk = false,
700
+ .msr_power_unit = MSR_RAPL_POWER_UNIT ,
701
+ .rapl_msrs = intel_rapl_msrs ,
694
702
};
695
703
696
704
static struct rapl_model model_hsx = {
697
705
.events = BIT (PERF_RAPL_PP0 ) |
698
706
BIT (PERF_RAPL_PKG ) |
699
707
BIT (PERF_RAPL_RAM ),
700
708
.apply_quirk = true,
709
+ .msr_power_unit = MSR_RAPL_POWER_UNIT ,
710
+ .rapl_msrs = intel_rapl_msrs ,
701
711
};
702
712
703
713
static struct rapl_model model_knl = {
704
714
.events = BIT (PERF_RAPL_PKG ) |
705
715
BIT (PERF_RAPL_RAM ),
706
716
.apply_quirk = true,
717
+ .msr_power_unit = MSR_RAPL_POWER_UNIT ,
718
+ .rapl_msrs = intel_rapl_msrs ,
707
719
};
708
720
709
721
static struct rapl_model model_skl = {
@@ -713,6 +725,8 @@ static struct rapl_model model_skl = {
713
725
BIT (PERF_RAPL_PP1 ) |
714
726
BIT (PERF_RAPL_PSYS ),
715
727
.apply_quirk = false,
728
+ .msr_power_unit = MSR_RAPL_POWER_UNIT ,
729
+ .rapl_msrs = intel_rapl_msrs ,
716
730
};
717
731
718
732
static const struct x86_cpu_id rapl_model_match [] __initconst = {
@@ -760,10 +774,13 @@ static int __init rapl_pmu_init(void)
760
774
return - ENODEV ;
761
775
762
776
rm = (struct rapl_model * ) id -> driver_data ;
777
+
778
+ rapl_msrs = rm -> rapl_msrs ;
779
+
763
780
rapl_cntr_mask = perf_msr_probe (rapl_msrs , PERF_RAPL_MAX ,
764
781
false, (void * ) & rm -> events );
765
782
766
- ret = rapl_check_hw_unit (rm -> apply_quirk );
783
+ ret = rapl_check_hw_unit (rm );
767
784
if (ret )
768
785
return ret ;
769
786
0 commit comments