@@ -130,11 +130,17 @@ struct rapl_pmus {
130
130
struct rapl_pmu * pmus [];
131
131
};
132
132
133
+ enum rapl_unit_quirk {
134
+ RAPL_UNIT_QUIRK_NONE ,
135
+ RAPL_UNIT_QUIRK_INTEL_HSW ,
136
+ RAPL_UNIT_QUIRK_INTEL_SPR ,
137
+ };
138
+
133
139
struct rapl_model {
134
140
struct perf_msr * rapl_msrs ;
135
141
unsigned long events ;
136
142
unsigned int msr_power_unit ;
137
- bool apply_quirk ;
143
+ enum rapl_unit_quirk unit_quirk ;
138
144
};
139
145
140
146
/* 1/2^hw_unit Joule */
@@ -612,14 +618,28 @@ static int rapl_check_hw_unit(struct rapl_model *rm)
612
618
for (i = 0 ; i < NR_RAPL_DOMAINS ; i ++ )
613
619
rapl_hw_unit [i ] = (msr_rapl_power_unit_bits >> 8 ) & 0x1FULL ;
614
620
621
+ switch (rm -> unit_quirk ) {
615
622
/*
616
623
* DRAM domain on HSW server and KNL has fixed energy unit which can be
617
624
* different than the unit from power unit MSR. See
618
625
* "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2
619
626
* of 2. Datasheet, September 2014, Reference Number: 330784-001 "
620
627
*/
621
- if (rm -> apply_quirk )
628
+ case RAPL_UNIT_QUIRK_INTEL_HSW :
629
+ rapl_hw_unit [PERF_RAPL_RAM ] = 16 ;
630
+ break ;
631
+ /*
632
+ * SPR shares the same DRAM domain energy unit as HSW, plus it
633
+ * also has a fixed energy unit for Psys domain.
634
+ */
635
+ case RAPL_UNIT_QUIRK_INTEL_SPR :
622
636
rapl_hw_unit [PERF_RAPL_RAM ] = 16 ;
637
+ rapl_hw_unit [PERF_RAPL_PSYS ] = 0 ;
638
+ break ;
639
+ default :
640
+ break ;
641
+ }
642
+
623
643
624
644
/*
625
645
* Calculate the timer rate:
@@ -665,7 +685,7 @@ static const struct attribute_group *rapl_attr_update[] = {
665
685
& rapl_events_pkg_group ,
666
686
& rapl_events_ram_group ,
667
687
& rapl_events_gpu_group ,
668
- & rapl_events_gpu_group ,
688
+ & rapl_events_psys_group ,
669
689
NULL ,
670
690
};
671
691
@@ -698,7 +718,6 @@ static struct rapl_model model_snb = {
698
718
.events = BIT (PERF_RAPL_PP0 ) |
699
719
BIT (PERF_RAPL_PKG ) |
700
720
BIT (PERF_RAPL_PP1 ),
701
- .apply_quirk = false,
702
721
.msr_power_unit = MSR_RAPL_POWER_UNIT ,
703
722
.rapl_msrs = intel_rapl_msrs ,
704
723
};
@@ -707,7 +726,6 @@ static struct rapl_model model_snbep = {
707
726
.events = BIT (PERF_RAPL_PP0 ) |
708
727
BIT (PERF_RAPL_PKG ) |
709
728
BIT (PERF_RAPL_RAM ),
710
- .apply_quirk = false,
711
729
.msr_power_unit = MSR_RAPL_POWER_UNIT ,
712
730
.rapl_msrs = intel_rapl_msrs ,
713
731
};
@@ -717,7 +735,6 @@ static struct rapl_model model_hsw = {
717
735
BIT (PERF_RAPL_PKG ) |
718
736
BIT (PERF_RAPL_RAM ) |
719
737
BIT (PERF_RAPL_PP1 ),
720
- .apply_quirk = false,
721
738
.msr_power_unit = MSR_RAPL_POWER_UNIT ,
722
739
.rapl_msrs = intel_rapl_msrs ,
723
740
};
@@ -726,15 +743,15 @@ static struct rapl_model model_hsx = {
726
743
.events = BIT (PERF_RAPL_PP0 ) |
727
744
BIT (PERF_RAPL_PKG ) |
728
745
BIT (PERF_RAPL_RAM ),
729
- .apply_quirk = true ,
746
+ .unit_quirk = RAPL_UNIT_QUIRK_INTEL_HSW ,
730
747
.msr_power_unit = MSR_RAPL_POWER_UNIT ,
731
748
.rapl_msrs = intel_rapl_msrs ,
732
749
};
733
750
734
751
static struct rapl_model model_knl = {
735
752
.events = BIT (PERF_RAPL_PKG ) |
736
753
BIT (PERF_RAPL_RAM ),
737
- .apply_quirk = true ,
754
+ .unit_quirk = RAPL_UNIT_QUIRK_INTEL_HSW ,
738
755
.msr_power_unit = MSR_RAPL_POWER_UNIT ,
739
756
.rapl_msrs = intel_rapl_msrs ,
740
757
};
@@ -745,14 +762,22 @@ static struct rapl_model model_skl = {
745
762
BIT (PERF_RAPL_RAM ) |
746
763
BIT (PERF_RAPL_PP1 ) |
747
764
BIT (PERF_RAPL_PSYS ),
748
- .apply_quirk = false,
765
+ .msr_power_unit = MSR_RAPL_POWER_UNIT ,
766
+ .rapl_msrs = intel_rapl_msrs ,
767
+ };
768
+
769
+ static struct rapl_model model_spr = {
770
+ .events = BIT (PERF_RAPL_PP0 ) |
771
+ BIT (PERF_RAPL_PKG ) |
772
+ BIT (PERF_RAPL_RAM ) |
773
+ BIT (PERF_RAPL_PSYS ),
774
+ .unit_quirk = RAPL_UNIT_QUIRK_INTEL_SPR ,
749
775
.msr_power_unit = MSR_RAPL_POWER_UNIT ,
750
776
.rapl_msrs = intel_rapl_msrs ,
751
777
};
752
778
753
779
static struct rapl_model model_amd_fam17h = {
754
780
.events = BIT (PERF_RAPL_PKG ),
755
- .apply_quirk = false,
756
781
.msr_power_unit = MSR_AMD_RAPL_POWER_UNIT ,
757
782
.rapl_msrs = amd_rapl_msrs ,
758
783
};
@@ -787,6 +812,7 @@ static const struct x86_cpu_id rapl_model_match[] __initconst = {
787
812
X86_MATCH_INTEL_FAM6_MODEL (ICELAKE_X , & model_hsx ),
788
813
X86_MATCH_INTEL_FAM6_MODEL (COMETLAKE_L , & model_skl ),
789
814
X86_MATCH_INTEL_FAM6_MODEL (COMETLAKE , & model_skl ),
815
+ X86_MATCH_INTEL_FAM6_MODEL (SAPPHIRERAPIDS_X , & model_spr ),
790
816
X86_MATCH_VENDOR_FAM (AMD , 0x17 , & model_amd_fam17h ),
791
817
X86_MATCH_VENDOR_FAM (HYGON , 0x18 , & model_amd_fam17h ),
792
818
{},
0 commit comments