Skip to contentSkip to conversation

powerpc/perf: fix Threshold Event CounterMultiplier width for P10

PATCH Superseded Madhavan Srinivasan 2 participants 5 messages Oct 12, 2020 – Oct 14, 2020 PowerPC

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Madhavan Srinivasan

author maintainer
#0 lore raw

PATCH 1/1 powerpc/perf: fix Threshold Event CounterMultiplier width for P10

Power9 and isa v3.1 has 7bit mantissa field for Threshold Event Counter Multiplier (TECM). TECM is part of Monitor Mode Control Register A (MMCRA). This field along with Threshold Event Counter Exponent (TECE) is used to get threshould counter value. In Power10, the width of TECM field is increase to 8bits. Patch fixes the current code to modify the MMCRA[TECM] extraction macro to handling this changes.

Fixes 170a315f41c64 ('powerpc/perf: Support to export MMCRA[TEC*] field to userspace')
---
 arch/powerpc/perf/isa207-common.c | 3 +++
 arch/powerpc/perf/isa207-common.h | 4 ++++
 2 files changed, 7 insertions(+)
arch/powerpc/perf/isa207-common.c +3 -0
index 964437adec18..5fe129f02290 100644
@@ -247,6 +247,9 @@ void isa207_get_mem_weight(u64 *weight)
 	u64 sier = mfspr(SPRN_SIER);
 	u64 val = (sier & ISA207_SIER_TYPE_MASK) >> ISA207_SIER_TYPE_SHIFT;
 
+	if (cpu_has_feature(CPU_FTR_ARCH_31))
+		mantissa = P10_MMCRA_THR_CTR_MANT(mmcra);
+
 	if (val == 0 || val == 7)
 		*weight = 0;
 	else
arch/powerpc/perf/isa207-common.h +4 -0
index 044de65e96b9..71380e854f48 100644
@@ -219,6 +219,10 @@
 #define MMCRA_THR_CTR_EXP(v)		(((v) >> MMCRA_THR_CTR_EXP_SHIFT) &\
 						MMCRA_THR_CTR_EXP_MASK)
 
+#define P10_MMCRA_THR_CTR_MANT_MASK	0xFFul
+#define P10_MMCRA_THR_CTR_MANT(v)	(((v) >> MMCRA_THR_CTR_MANT_SHIFT) &\
+						P10_MMCRA_THR_CTR_MANT_MASK)
+
 /* MMCRA Threshold Compare bit constant for power9 */
 #define p9_MMCRA_THR_CMP_SHIFT	45
 
Signature · 1 line
2.26.2
#1 lore raw

Hello,

Quoted 1 line · Madhavan Srinivasan

Power9 and isa v3.1 has 7bit mantissa field for Threshold Event Counter

                  ^^^ Shouldn't his be 3.0?
Quoted 45 lines

Multiplier (TECM). TECM is part of Monitor Mode Control Register A (MMCRA). This field along with Threshold Event Counter Exponent (TECE) is used to get threshould counter value. In Power10, the width of TECM field is increase to 8bits. Patch fixes the current code to modify the MMCRA[TECM] extraction macro to handling this changes.

Fixes 170a315f41c64 ('powerpc/perf: Support to export MMCRA[TEC*] field to userspace')
---
 arch/powerpc/perf/isa207-common.c | 3 +++
 arch/powerpc/perf/isa207-common.h | 4 ++++
 2 files changed, 7 insertions(+)
arch/powerpc/perf/isa207-common.c +3 -0
index 964437adec18..5fe129f02290 100644
@@ -247,6 +247,9 @@ void isa207_get_mem_weight(u64 *weight)
 	u64 sier = mfspr(SPRN_SIER);
 	u64 val = (sier & ISA207_SIER_TYPE_MASK) >> ISA207_SIER_TYPE_SHIFT;
 
+	if (cpu_has_feature(CPU_FTR_ARCH_31))
+		mantissa = P10_MMCRA_THR_CTR_MANT(mmcra);
+
 	if (val == 0 || val == 7)
 		*weight = 0;
 	else
arch/powerpc/perf/isa207-common.h +4 -0
index 044de65e96b9..71380e854f48 100644
@@ -219,6 +219,10 @@
 #define MMCRA_THR_CTR_EXP(v)		(((v) >> MMCRA_THR_CTR_EXP_SHIFT) &\
 						MMCRA_THR_CTR_EXP_MASK)
 
+#define P10_MMCRA_THR_CTR_MANT_MASK	0xFFul
+#define P10_MMCRA_THR_CTR_MANT(v)	(((v) >> MMCRA_THR_CTR_MANT_SHIFT) &\
+						P10_MMCRA_THR_CTR_MANT_MASK)
+
 /* MMCRA Threshold Compare bit constant for power9 */
 #define p9_MMCRA_THR_CMP_SHIFT	45
 
Signature · 1 line
2.26.2
author maintainer
#2 lore raw
Quoted 5 lines · Michal Suchánek

Hello,

Quoted 1 line · Madhavan Srinivasan

Power9 and isa v3.1 has 7bit mantissa field for Threshold Event Counter

                   ^^^ Shouldn't his be 3.0?

My bad, What I meant was

Power9, ISA v3.0 and ISA v3.1 define a 7 bit mantissa field for Threshold Event Counter Multiplier(TECM).

Maddy

Quoted 46 lines
Quoted 46 lines

Multiplier (TECM). TECM is part of Monitor Mode Control Register A (MMCRA). This field along with Threshold Event Counter Exponent (TECE) is used to get threshould counter value. In Power10, the width of TECM field is increase to 8bits. Patch fixes the current code to modify the MMCRA[TECM] extraction macro to handling this changes.

Fixes 170a315f41c64 ('powerpc/perf: Support to export MMCRA[TEC*] field to userspace')
---
  arch/powerpc/perf/isa207-common.c | 3 +++
  arch/powerpc/perf/isa207-common.h | 4 ++++
  2 files changed, 7 insertions(+)
arch/powerpc/perf/isa207-common.c +3 -0
index 964437adec18..5fe129f02290 100644
@@ -247,6 +247,9 @@ void isa207_get_mem_weight(u64 *weight)
  	u64 sier = mfspr(SPRN_SIER);
  	u64 val = (sier & ISA207_SIER_TYPE_MASK) >> ISA207_SIER_TYPE_SHIFT;
 
+	if (cpu_has_feature(CPU_FTR_ARCH_31))
+		mantissa = P10_MMCRA_THR_CTR_MANT(mmcra);
+
  	if (val == 0 || val == 7)
  		*weight = 0;
  	else
arch/powerpc/perf/isa207-common.h +4 -0
index 044de65e96b9..71380e854f48 100644
@@ -219,6 +219,10 @@
  #define MMCRA_THR_CTR_EXP(v)		(((v) >> MMCRA_THR_CTR_EXP_SHIFT) &\
  						MMCRA_THR_CTR_EXP_MASK)
 
+#define P10_MMCRA_THR_CTR_MANT_MASK	0xFFul
+#define P10_MMCRA_THR_CTR_MANT(v)	(((v) >> MMCRA_THR_CTR_MANT_SHIFT) &\
+						P10_MMCRA_THR_CTR_MANT_MASK)
+
  /* MMCRA Threshold Compare bit constant for power9 */
  #define p9_MMCRA_THR_CMP_SHIFT	45
 
Signature · 1 line
2.26.2
#3 lore raw
Quoted 4 lines · Madhavan Srinivasan
Quoted 2 lines · Michal Suchánek

Hello,

Quoted 8 lines
Quoted 3 lines · Madhavan Srinivasan
Quoted 1 line

Power9 and isa v3.1 has 7bit mantissa field for Threshold Event Counter

                   ^^^ Shouldn't his be 3.0?

My bad, What I meant was

Power9, ISA v3.0 and ISA v3.1 define a 7 bit mantissa field for Threshold Event Counter Multiplier(TECM).

I am really confused.

The following text and the code suggests that the mantissa is 8bit on POWER10 and ISA v3.1.

Thanks

Michal

Quoted 46 lines

Maddy

Quoted 43 lines
Quoted 43 lines

Multiplier (TECM). TECM is part of Monitor Mode Control Register A (MMCRA). This field along with Threshold Event Counter Exponent (TECE) is used to get threshould counter value. In Power10, the width of TECM field is increase to 8bits. Patch fixes the current code to modify the MMCRA[TECM] extraction macro to handling this changes.

Fixes 170a315f41c64 ('powerpc/perf: Support to export MMCRA[TEC*] field to userspace')
---
  arch/powerpc/perf/isa207-common.c | 3 +++
  arch/powerpc/perf/isa207-common.h | 4 ++++
  2 files changed, 7 insertions(+)
arch/powerpc/perf/isa207-common.c +3 -0
index 964437adec18..5fe129f02290 100644
@@ -247,6 +247,9 @@ void isa207_get_mem_weight(u64 *weight)
  	u64 sier = mfspr(SPRN_SIER);
  	u64 val = (sier & ISA207_SIER_TYPE_MASK) >> ISA207_SIER_TYPE_SHIFT;
+	if (cpu_has_feature(CPU_FTR_ARCH_31))
+		mantissa = P10_MMCRA_THR_CTR_MANT(mmcra);
+
  	if (val == 0 || val == 7)
  		*weight = 0;
  	else
arch/powerpc/perf/isa207-common.h +4 -0
index 044de65e96b9..71380e854f48 100644
@@ -219,6 +219,10 @@
  #define MMCRA_THR_CTR_EXP(v)		(((v) >> MMCRA_THR_CTR_EXP_SHIFT) &\
  						MMCRA_THR_CTR_EXP_MASK)
+#define P10_MMCRA_THR_CTR_MANT_MASK	0xFFul
+#define P10_MMCRA_THR_CTR_MANT(v)	(((v) >> MMCRA_THR_CTR_MANT_SHIFT) &\
+						P10_MMCRA_THR_CTR_MANT_MASK)
+
  /* MMCRA Threshold Compare bit constant for power9 */
  #define p9_MMCRA_THR_CMP_SHIFT	45
Signature · 1 line
2.26.2
author maintainer
#4 lore raw
Quoted 7 lines · Michal Suchánek
Quoted 6 lines · Madhavan Srinivasan
Quoted 5 lines · Michal Suchánek

Hello,

Quoted 1 line · Madhavan Srinivasan

Power9 and isa v3.1 has 7bit mantissa field for Threshold Event Counter

                    ^^^ Shouldn't his be 3.0?
Quoted 8 lines
Quoted 4 lines

My bad, What I meant was

Power9, ISA v3.0 and ISA v3.1 define a 7 bit mantissa field for Threshold Event Counter Multiplier(TECM).

I am really confused.

The following text and the code suggests that the mantissa is 8bit on POWER10 and ISA v3.1.

Ok got it. Will fix the CPU_FTR_ARCH_31 check.

Thanks for review

Maddy

Quoted 48 lines

Thanks

Michal

Quoted 44 lines

Maddy

Quoted 42 lines
Quoted 42 lines

Multiplier (TECM). TECM is part of Monitor Mode Control Register A (MMCRA). This field along with Threshold Event Counter Exponent (TECE) is used to get threshould counter value. In Power10, the width of TECM field is increase to 8bits. Patch fixes the current code to modify the MMCRA[TECM] extraction macro to handling this changes.

Fixes 170a315f41c64 ('powerpc/perf: Support to export MMCRA[TEC*] field to userspace')
---
   arch/powerpc/perf/isa207-common.c | 3 +++
   arch/powerpc/perf/isa207-common.h | 4 ++++
   2 files changed, 7 insertions(+)
arch/powerpc/perf/isa207-common.c +3 -0
index 964437adec18..5fe129f02290 100644
@@ -247,6 +247,9 @@ void isa207_get_mem_weight(u64 *weight)
   	u64 sier = mfspr(SPRN_SIER);
   	u64 val = (sier & ISA207_SIER_TYPE_MASK) >> ISA207_SIER_TYPE_SHIFT;
+	if (cpu_has_feature(CPU_FTR_ARCH_31))
+		mantissa = P10_MMCRA_THR_CTR_MANT(mmcra);
+
   	if (val == 0 || val == 7)
   		*weight = 0;
   	else
arch/powerpc/perf/isa207-common.h +4 -0
index 044de65e96b9..71380e854f48 100644
@@ -219,6 +219,10 @@
   #define MMCRA_THR_CTR_EXP(v)		(((v) >> MMCRA_THR_CTR_EXP_SHIFT) &\
   						MMCRA_THR_CTR_EXP_MASK)
+#define P10_MMCRA_THR_CTR_MANT_MASK	0xFFul
+#define P10_MMCRA_THR_CTR_MANT(v)	(((v) >> MMCRA_THR_CTR_MANT_SHIFT) &\
+						P10_MMCRA_THR_CTR_MANT_MASK)
+
   /* MMCRA Threshold Compare bit constant for power9 */
   #define p9_MMCRA_THR_CMP_SHIFT	45
Signature · 1 line
2.26.2