perf/x86/rapl: Fix missing psys sysfs attributes
Subsystems (2)
PATCH 1/3 perf/x86/rapl: Fix missing psys sysfs attributes
This fixes a problem introduced by
commit 5fb5273a905c ("perf/x86/rapl: Use new MSR detection interface") that perf event sysfs attributes for psys RAPL domain are missing.
--- arch/x86/events/rapl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/rapl.c +1 -1
@@ -665,7 +665,7 @@ static const struct attribute_group *rapl_attr_update[] = { &rapl_events_pkg_group, &rapl_events_ram_group, &rapl_events_gpu_group, - &rapl_events_gpu_group, + &rapl_events_psys_group, NULL, };
Signature · 1 line
2.17.1
PATCH 2/3 perf/x86/rapl: Support multiple rapl unit quirks
There will be more platforms with different fixed energy units. Enhance the code to support different rapl unit quirks for different platforms.
--- arch/x86/events/rapl.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
arch/x86/events/rapl.c +15 -9
@@ -130,11 +130,16 @@ struct rapl_pmus {struct rapl_pmu *pmus[]; }; +enum rapl_unit_quirk { +RAPL_UNIT_QUIRK_NONE , +RAPL_UNIT_QUIRK_INTEL_HSW , +}; +struct rapl_model {struct perf_msr *rapl_msrs;unsigned long events;unsigned int msr_power_unit; -bool apply_quirk; +enum rapl_unit_quirk unit_quirk; };/* 1/2^hw_unit Joule */
@@ -612,14 +617,20 @@ static int rapl_check_hw_unit(struct rapl_model *rm)for (i =0 ; i <NR_RAPL_DOMAINS ; i++) rapl_hw_unit[i] = (msr_rapl_power_unit_bits >>8 ) &0x1FULL ; +switch (rm->unit_quirk) {/* * DRAM domain on HSW server and KNL has fixed energy unit which can be * different than the unit from power unit MSR. See * "Intel Xeon Processor E5-1600 and E5-2600 v3 Product Families, V2 * of 2. Datasheet, September 2014, Reference Number: 330784-001 " */ -if (rm->apply_quirk) +case RAPL_UNIT_QUIRK_INTEL_HSW : rapl_hw_unit[PERF_RAPL_RAM ] =16 ; +break ; +default : +break ; + } +/* * Calculate the timer rate:
@@ -698,7 +709,6 @@ static struct rapl_model model_snb = { .events = BIT(PERF_RAPL_PP0) | BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_PP1), - .apply_quirk = false, .msr_power_unit = MSR_RAPL_POWER_UNIT, .rapl_msrs = intel_rapl_msrs, };
@@ -707,7 +717,6 @@ static struct rapl_model model_snbep = { .events = BIT(PERF_RAPL_PP0) | BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_RAM), - .apply_quirk = false, .msr_power_unit = MSR_RAPL_POWER_UNIT, .rapl_msrs = intel_rapl_msrs, };
@@ -717,7 +726,6 @@ static struct rapl_model model_hsw = {BIT (PERF_RAPL_PKG ) |BIT (PERF_RAPL_RAM ) | BIT(PERF_RAPL_PP1), - .apply_quirk = false, .msr_power_unit = MSR_RAPL_POWER_UNIT, .rapl_msrs = intel_rapl_msrs, };
@@ -726,7 +734,7 @@ static struct rapl_model model_hsx = { .events = BIT(PERF_RAPL_PP0) | BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_RAM), - .apply_quirk = true, + .unit_quirk = RAPL_UNIT_QUIRK_INTEL_HSW, .msr_power_unit = MSR_RAPL_POWER_UNIT, .rapl_msrs = intel_rapl_msrs, };
@@ -734,7 +742,7 @@ static struct rapl_model model_hsx = {static struct rapl_model model_knl = { .events =BIT (PERF_RAPL_PKG ) |BIT (PERF_RAPL_RAM ), - .apply_quirk = true, + .unit_quirk =RAPL_UNIT_QUIRK_INTEL_HSW , .msr_power_unit =MSR_RAPL_POWER_UNIT , .rapl_msrs = intel_rapl_msrs, };
@@ -745,14 +753,12 @@ static struct rapl_model model_skl = {BIT (PERF_RAPL_RAM ) |BIT (PERF_RAPL_PP1 ) | BIT(PERF_RAPL_PSYS), - .apply_quirk = false, .msr_power_unit = MSR_RAPL_POWER_UNIT, .rapl_msrs = intel_rapl_msrs, };static struct rapl_model model_amd_fam17h = { .events =BIT (PERF_RAPL_PKG ), - .apply_quirk = false, .msr_power_unit =MSR_AMD_RAPL_POWER_UNIT , .rapl_msrs = amd_rapl_msrs, };
Signature · 1 line
2.17.1
PATCH 3/3 perf/x86/rapl: Add support for Intel SPR platform
In reply to Zhang RuiIntel SPR platform uses fixed 16 bit energy unit for DRAM RAPL domain, and fixed 0 bit energy unit for Psys RAPL domain.
After this, on SPR platform the energy counters appear in perf list.
--- arch/x86/events/rapl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/x86/events/rapl.c +20 -0
@@ -133,6 +133,7 @@ struct rapl_pmus {enum rapl_unit_quirk {RAPL_UNIT_QUIRK_NONE ,RAPL_UNIT_QUIRK_INTEL_HSW , +RAPL_UNIT_QUIRK_INTEL_SPR , };struct rapl_model {
@@ -627,6 +628,14 @@ static int rapl_check_hw_unit(struct rapl_model *rm)case RAPL_UNIT_QUIRK_INTEL_HSW : rapl_hw_unit[PERF_RAPL_RAM ] =16 ;break ; +/* +* SPR shares the same DRAM domain energy unit as HSW, plus it +* also has a fixed energy unit for Psys domain. +*/ +case RAPL_UNIT_QUIRK_INTEL_SPR : + rapl_hw_unit[PERF_RAPL_RAM ] =16 ; + rapl_hw_unit[PERF_RAPL_PSYS ] =0 ; +break ;default :break ; }
@@ -757,6 +766,16 @@ static struct rapl_model model_skl = { .rapl_msrs = intel_rapl_msrs, }; +static struct rapl_model model_spr = { + .events =BIT (PERF_RAPL_PP0 ) | +BIT (PERF_RAPL_PKG ) | +BIT (PERF_RAPL_RAM ) | +BIT (PERF_RAPL_PSYS ), + .unit_quirk =RAPL_UNIT_QUIRK_INTEL_SPR , + .msr_power_unit =MSR_RAPL_POWER_UNIT , + .rapl_msrs = intel_rapl_msrs, +}; +static struct rapl_model model_amd_fam17h = { .events =BIT (PERF_RAPL_PKG ), .msr_power_unit =MSR_AMD_RAPL_POWER_UNIT ,
@@ -793,6 +812,7 @@ static const struct x86_cpu_id rapl_model_match[] __initconst = {X86_MATCH_INTEL_FAM6_MODEL (ICELAKE_X , &model_hsx),X86_MATCH_INTEL_FAM6_MODEL (COMETLAKE_L , &model_skl),X86_MATCH_INTEL_FAM6_MODEL (COMETLAKE , &model_skl), +X86_MATCH_INTEL_FAM6_MODEL (SAPPHIRERAPIDS_X , &model_spr), X86_MATCH_VENDOR_FAM(AMD, 0x17, &model_amd_fam17h), {}, };
Signature · 1 line
2.17.1
Quoted 17 lines · Zhang Rui
This fixes a problem introduced by
commit5fb5273a905c("perf/x86/rapl: Use new MSR detection interface") that perf event sysfs attributes for psys RAPL domain are missing.Fixes 5fb5273a905c ("perf/x86/rapl: Use new MSR detection interface")Signed-off-by Zhang Rui <[email protected]>Reviewed-by Kan Liang <[email protected]>Reviewed-by Len Brown <[email protected]>--- arch/x86/events/rapl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/events/rapl.c +0
-0
arch/x86/events/rapl.c static const struct attribute_group *rapl_attr_update[] = { · line 668
Quoted 5 lines
arch/x86/events/rapl.c +1
-1@@ -665,7 +665,7 @@ static const struct attribute_group *rapl_attr_update[] = { &rapl_events_pkg_group, &rapl_events_ram_group, &rapl_events_gpu_group, - &rapl_events_gpu_group, + &rapl_events_psys_group,
I did copy & paste but did not change to psys :-\
thanks,
jirka
Quoted 6 lines
arch/x86/events/rapl.c +0
-0NULL, };Signature · 1 line
2.17.1
Quoted 29 lines · Jiri Olsa
Quoted 19 lines · Zhang Rui
This fixes a problem introduced by
commit5fb5273a905c("perf/x86/rapl: Use new MSR detection interface")
that perf event sysfs attributes for psys RAPL domain are missing.Fixes 5fb5273a905c ("perf/x86/rapl: Use new MSR detectioninterface")
Signed-off-by Zhang Rui <[email protected]>Reviewed-by Kan Liang <[email protected]>Reviewed-by Len Brown <[email protected]>--- arch/x86/events/rapl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/events/rapl.c +0
-0arch/x86/events/rapl.c static const struct attribute_group · line 669
Quoted 6 lines
arch/x86/events/rapl.c +1
-1@@ -665,7 +665,7 @@ static const struct attribute_group *rapl_attr_update[] = { &rapl_events_pkg_group, &rapl_events_ram_group, &rapl_events_gpu_group, - &rapl_events_gpu_group, + &rapl_events_psys_group,I did copy & paste but did not change to psys :-\
Quoted 1 line
Acked-by Jiri Olsa <[email protected]>
Hi, jirka,
Thanks for your ACK.
Hi, Peter,
A gentle ping on this patch series.
thanks,
rui
Quoted 12 lines
thanks,
jirkaQuoted 6 lines
arch/x86/events/rapl.c +0
-0NULL, };Signature · 2 lines
-- 2.17.1