Skip to contentSkip to conversation

oprofile support for ppc750

PATCH Superseded Octavian Purdila 3 participants 14 messages Jan 6, 2009 – Mar 4, 2009 PowerPC

lore
Share & tools
lore
#0 lore raw

cover oprofile support for ppc750

Adds oprofile support for ppc750. ppc750 performance counters interface is similar with G4, but it only has 4 performance counters instead of 6.

I tested this on a PPC750GX and it seems to work fine.

tavi

#1 lore raw

PATCH 1/2 powerpc: G4 oprofile: variable number of counters

For ppc750 processors which use 4 performance counters instead of the 6 G4 uses but otherwise is compatible with G4.

---
 arch/powerpc/oprofile/op_model_7450.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)
arch/powerpc/oprofile/op_model_7450.c +11 -10
index cc599eb..97348f5 100644
@@ -29,7 +29,7 @@
 static unsigned long reset_value[OP_MAX_COUNTER];
 
 static int oprofile_running;
-static u32 mmcr0_val, mmcr1_val, mmcr2_val;
+static u32 mmcr0_val, mmcr1_val, mmcr2_val, ctrs;
 
 #define MMCR0_PMC1_SHIFT	6
 #define MMCR0_PMC2_SHIFT	0
@@ -88,13 +88,12 @@ static int fsl7450_cpu_setup(struct op_counter_config *ctr)
 
 	mtspr(SPRN_MMCR0, mmcr0_val);
 	mtspr(SPRN_MMCR1, mmcr1_val);
-	mtspr(SPRN_MMCR2, mmcr2_val);
+	if (ctrs > 4)
+		mtspr(SPRN_MMCR2, mmcr2_val);
 
 	return 0;
 }
 
-#define NUM_CTRS 6
-
 /* Configures the global settings for the countes on all CPUs. */
 static int fsl7450_reg_setup(struct op_counter_config *ctr,
 			     struct op_system_config *sys,
@@ -102,12 +101,13 @@ static int fsl7450_reg_setup(struct op_counter_config *ctr,
 {
 	int i;
 
+	ctrs = num_ctrs;
 	/* Our counters count up, and "count" refers to
 	 * how much before the next interrupt, and we interrupt
 	 * on overflow.  So we calculate the starting value
 	 * which will give us "count" until overflow.
 	 * Then we set the events on the enabled counters */
-	for (i = 0; i < NUM_CTRS; ++i)
+	for (i = 0; i < num_ctrs; ++i)
 		reset_value[i] = 0x80000000UL - ctr[i].count;
 
 	/* Set events for Counters 1 & 2 */
@@ -123,9 +123,10 @@ static int fsl7450_reg_setup(struct op_counter_config *ctr,
 
 	/* Set events for Counters 3-6 */
 	mmcr1_val = mmcr1_event3(ctr[2].event)
-		| mmcr1_event4(ctr[3].event)
-		| mmcr1_event5(ctr[4].event)
-		| mmcr1_event6(ctr[5].event);
+		| mmcr1_event4(ctr[3].event);
+	if (num_ctrs > 4)
+		mmcr1_val |= mmcr1_event5(ctr[4].event)
+			| mmcr1_event6(ctr[5].event);
 
 	mmcr2_val = 0;
 
@@ -139,7 +140,7 @@ static int fsl7450_start(struct op_counter_config *ctr)
 
 	mtmsr(mfmsr() | MSR_PMM);
 
-	for (i = 0; i < NUM_CTRS; ++i) {
+	for (i = 0; i < ctrs; ++i) {
 		if (ctr[i].enabled)
 			classic_ctr_write(i, reset_value[i]);
 		else
@@ -184,7 +185,7 @@ static void fsl7450_handle_interrupt(struct pt_regs *regs,
 	pc = mfspr(SPRN_SIAR);
 	is_kernel = is_kernel_addr(pc);
 
-	for (i = 0; i < NUM_CTRS; ++i) {
+	for (i = 0; i < ctrs; ++i) {
 		val = classic_ctr_read(i);
 		if (val < 0) {
 			if (oprofile_running && ctr[i].enabled) {
Signature · 1 line
1.5.6.5
#2 lore raw

Re: [PATCH 1/2] powerpc: G4 oprofile: variable number of counters

Quoted 13 lines · Octavian Purdila

For ppc750 processors which use 4 performance counters instead of the 6 G4 uses but otherwise is compatible with G4.

---
 arch/powerpc/oprofile/op_model_7450.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)
arch/powerpc/oprofile/op_model_7450.c +0 -0
index cc599eb..97348f5 100644

arch/powerpc/oprofile/op_model_7450.c line 32

Quoted 5 lines
arch/powerpc/oprofile/op_model_7450.c +1 -1
@@ -29,7 +29,7 @@
 static unsigned long reset_value[OP_MAX_COUNTER];
 
 static int oprofile_running;
-static u32 mmcr0_val, mmcr1_val, mmcr2_val;
+static u32 mmcr0_val, mmcr1_val, mmcr2_val, ctrs;

This may be static but it's still a global scope as far as kernel symbols are concerned. Care to give it a slightly better name ? num_pmcs would probably be already more telling.

Cheers,
Ben.

#3 lore raw

PATCH v2 1/2 powerpc: G4 oprofile: variable number of counters

For ppc750 processors which use 4 performance counters instead of the 6 G4 uses but otherwise is compatible with G4.

---
 arch/powerpc/oprofile/op_model_7450.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)
arch/powerpc/oprofile/op_model_7450.c +11 -10
index cc599eb..f8d36f9 100644
@@ -29,7 +29,7 @@
 static unsigned long reset_value[OP_MAX_COUNTER];
 
 static int oprofile_running;
-static u32 mmcr0_val, mmcr1_val, mmcr2_val;
+static u32 mmcr0_val, mmcr1_val, mmcr2_val, num_pmcs;
 
 #define MMCR0_PMC1_SHIFT	6
 #define MMCR0_PMC2_SHIFT	0
@@ -88,13 +88,12 @@ static int fsl7450_cpu_setup(struct op_counter_config *ctr)
 
 	mtspr(SPRN_MMCR0, mmcr0_val);
 	mtspr(SPRN_MMCR1, mmcr1_val);
-	mtspr(SPRN_MMCR2, mmcr2_val);
+	if (num_pmcs > 4)
+		mtspr(SPRN_MMCR2, mmcr2_val);
 
 	return 0;
 }
 
-#define NUM_CTRS 6
-
 /* Configures the global settings for the countes on all CPUs. */
 static int fsl7450_reg_setup(struct op_counter_config *ctr,
 			     struct op_system_config *sys,
@@ -102,12 +101,13 @@ static int fsl7450_reg_setup(struct op_counter_config *ctr,
 {
 	int i;
 
+	num_pmcs = num_ctrs;
 	/* Our counters count up, and "count" refers to
 	 * how much before the next interrupt, and we interrupt
 	 * on overflow.  So we calculate the starting value
 	 * which will give us "count" until overflow.
 	 * Then we set the events on the enabled counters */
-	for (i = 0; i < NUM_CTRS; ++i)
+	for (i = 0; i < num_ctrs; ++i)
 		reset_value[i] = 0x80000000UL - ctr[i].count;
 
 	/* Set events for Counters 1 & 2 */
@@ -123,9 +123,10 @@ static int fsl7450_reg_setup(struct op_counter_config *ctr,
 
 	/* Set events for Counters 3-6 */
 	mmcr1_val = mmcr1_event3(ctr[2].event)
-		| mmcr1_event4(ctr[3].event)
-		| mmcr1_event5(ctr[4].event)
-		| mmcr1_event6(ctr[5].event);
+		| mmcr1_event4(ctr[3].event);
+	if (num_ctrs > 4)
+		mmcr1_val |= mmcr1_event5(ctr[4].event)
+			| mmcr1_event6(ctr[5].event);
 
 	mmcr2_val = 0;
 
@@ -139,7 +140,7 @@ static int fsl7450_start(struct op_counter_config *ctr)
 
 	mtmsr(mfmsr() | MSR_PMM);
 
-	for (i = 0; i < NUM_CTRS; ++i) {
+	for (i = 0; i < num_pmcs; ++i) {
 		if (ctr[i].enabled)
 			classic_ctr_write(i, reset_value[i]);
 		else
@@ -184,7 +185,7 @@ static void fsl7450_handle_interrupt(struct pt_regs *regs,
 	pc = mfspr(SPRN_SIAR);
 	is_kernel = is_kernel_addr(pc);
 
-	for (i = 0; i < NUM_CTRS; ++i) {
+	for (i = 0; i < num_pmcs; ++i) {
 		val = classic_ctr_read(i);
 		if (val < 0) {
 			if (oprofile_running && ctr[i].enabled) {
Signature · 1 line
1.5.6.5
#4 lore raw

PATCH v2 2/2 powerpc: oprofile: enable support for ppc750 processors

In reply to Benjamin Herrenschmidt
---
 arch/powerpc/kernel/cputable.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
arch/powerpc/kernel/cputable.c +6 -0
index 923f87a..4e20cfb 100644
@@ -726,6 +726,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/7450",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 750FX rev 2.0 must disable HID0[DPM] */
 		.pvr_mask		= 0xffffffff,
@@ -741,6 +743,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/7450",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 750FX (All revs except 2.0) */
 		.pvr_mask		= 0xffff0000,
@@ -756,6 +760,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750fx,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/7450",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 750GX */
 		.pvr_mask		= 0xffff0000,
Signature · 1 line
1.5.6.5
#5 lore raw

Re: [PATCH v2 2/2] powerpc: oprofile: enable support for ppc750 processors

On Tue, Feb 24, 2009 at 6:09 AM, Octavian Purdila <[email protected]> wr= ote:

arch/powerpc/kernel/cputabl=

Quoted 6 lines

---
=A0arch/powerpc/kernel/cputable.c | =A0 =A06 ++++++ =A01 files changed, 6 insertions(+), 0 deletions(-)

arch/powerpc/kernel/cputabl= renamed from arch/powerpc/kernel/cputable.c +0 -0

e.c

Quoted 5 lines

index 923f87a..4e20cfb 100644

arch/powerpc/kernel/cputable.c +0 -0
@@ -726,6 +726,8 @@ static struct cpu_spec __initdata cpu_specs[] =3D {

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.cpu_setup =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D =

__setup_cpu_750,

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.machine_check =A0 =A0 =A0 =A0 =A0=3D mach=

ine_check_generic,

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.platform =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D =

"ppc750",

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 .oprofile_cpu_type =A0 =A0 =A0=3D "ppc/7450=

",

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 .oprofile_type =A0 =A0 =A0 =A0 =A0=3D PPC_O=

PROFILE_G4,

Quoted 1 line

=A0 =A0 =A0 =A0},

I know this saves you some code, but it seems hacky. It would be better to modify oprofile to detect the proper cpu type. Also, this will screw things up if you try to use the different event set that the 750 has.

Also, one more concern is the long-standing errata which makes this quite dangerous. All of the versions of the 750 I'm aware of have a bug where if a Performance Monitor exception occurs within one cycle of the Decrementer exception, the cpu will lose the ability to return from the interrupt (SRR0/SRR1 become corrupted). It's possible the 750s you have modified to support oprofile don't have this errata. Alternatively, we can decide we don't care, as you have to be root to use oprofile. But this is why I didn't add support for anything before the 7450.

Andy

#6 lore raw

Re: [PATCH v2 2/2] powerpc: oprofile: enable support for ppc750 processors

Quoted 5 lines · Andy Fleming

I know this saves you some code, but it seems hacky. It would be better to modify oprofile to detect the proper cpu type. Also, this will screw things up if you try to use the different event set that the 750 has.

Agreed. Note that Jack Miller (CC) has some patches for the oprofile side.

Quoted 9 lines

Also, one more concern is the long-standing errata which makes this quite dangerous. All of the versions of the 750 I'm aware of have a bug where if a Performance Monitor exception occurs within one cycle of the Decrementer exception, the cpu will lose the ability to return from the interrupt (SRR0/SRR1 become corrupted). It's possible the 750s you have modified to support oprofile don't have this errata. Alternatively, we can decide we don't care, as you have to be root to use oprofile. But this is why I didn't add support for anything before the 7450.

I think we need to advertise it as broken in some way... I -think- the latest batch of IBM 750CL have that bug fixed but I'm not 100% certain.

Cheers,
Ben.

#7 lore raw

Re: [PATCH v2 2/2] powerpc: oprofile: enable support for ppc750 processors

From: Benjamin Herrenschmidt <[email protected]>

Quoted 9 lines · Andy Fleming
Quoted 4 lines

I know this saves you some code, but it seems hacky. It would be better to modify oprofile to detect the proper cpu type. Also, this will screw things up if you try to use the different event set that the 750 has.

Agreed. Note that Jack Miller (CC) has some patches for the oprofile side.

Not sure I understand, but the oprofile userspace tool sees it as new processor (ppc750). I had to patch it to add the events for the new processor.

Quoted 10 lines
Quoted 9 lines

Also, one more concern is the long-standing errata which makes this quite dangerous. All of the versions of the 750 I'm aware of have a bug where if a Performance Monitor exception occurs within one cycle of the Decrementer exception, the cpu will lose the ability to return from the interrupt (SRR0/SRR1 become corrupted). It's possible the 750s you have modified to support oprofile don't have this errata. Alternatively, we can decide we don't care, as you have to be root to use oprofile. But this is why I didn't add support for anything before the 7450.

Yes, I understand. We knew about the errata and we used the timer interrupt for profiling for some time, but then we run into some issue were we had to use advanced counters as L1 cache misses / TLB misses to diagnose some issues and we decided to give it a try. And _seems_ to work fine. Although we didn't stress it too hard (around 10-20 minutes of continuous run).

So maybe it would be useful for other people in the same situation as ours. BTW, this is the out of cat /proc/cpuinfo on our hw:

processor : 0
cpu : 750GX
temperature : 10-12 C (uncalibrated)
revision : 1.2 (pvr 7002 0102)
bogomips : 1597.44
vendor : Ixia
machine : TCPX [0x6b]

Quoted 1 line

I think we need to advertise it as broken in some way...

Perhaps set it to use the timer by default, and allow the user to switch to the hardware performance counter + printing a message that this mode is dangerous?

Thanks,
tavi

#8 lore raw

Re: [PATCH 1/2] powerpc: G4 oprofile: variable number of counters

In reply to Benjamin Herrenschmidt
Quoted 7 lines

arch/powerpc/oprofile/op_model_7450.c line 32

Quoted 3 lines

static int oprofile_running;

arch/powerpc/oprofile/op_model_7450.c +1 -1
-static u32 mmcr0_val, mmcr1_val, mmcr2_val;
+static u32 mmcr0_val, mmcr1_val, mmcr2_val, ctrs;

This may be static but it's still a global scope as far as kernel symbols are concerned. Care to give it a slightly better name ? num_pmcs would probably be already more telling.

Sure. v2 will follow, with s/ctrs/num_pmcs/.

Thanks,
tavi

#9 lore raw

PATCH 2/2 powerpc: oprofile: enable support for ppc750 processors

In reply to Octavian Purdila
---
 arch/powerpc/kernel/cputable.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
arch/powerpc/kernel/cputable.c +6 -0
index 923f87a..4e20cfb 100644
@@ -726,6 +726,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/7450",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 750FX rev 2.0 must disable HID0[DPM] */
 		.pvr_mask		= 0xffffffff,
@@ -741,6 +743,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/7450",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 750FX (All revs except 2.0) */
 		.pvr_mask		= 0xffff0000,
@@ -756,6 +760,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750fx,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/7450",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 750GX */
 		.pvr_mask		= 0xffff0000,
Signature · 1 line
1.5.6.5
#10 lore raw

Re: [PATCH 2/2] powerpc: oprofile: enable support for ppc750 processors

Quoted 1 line · Octavian Purdila

So I'm going to merge 1/2 but this one should really be changed to advertise ppc/750 in oprofile_cpu_type (ie. to userspace).

Cheers,
Ben.

Quoted 34 lines
 arch/powerpc/kernel/cputable.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
arch/powerpc/kernel/cputable.c +6 -0
index 923f87a..4e20cfb 100644
@@ -726,6 +726,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/7450",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 750FX rev 2.0 must disable HID0[DPM] */
 		.pvr_mask		= 0xffffffff,
@@ -741,6 +743,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/7450",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 750FX (All revs except 2.0) */
 		.pvr_mask		= 0xffff0000,
@@ -756,6 +760,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750fx,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/7450",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 750GX */
 		.pvr_mask		= 0xffff0000,
#11 lore raw

Re: [PATCH 2/2] powerpc: oprofile: enable support for ppc750 processors

From: Benjamin Herrenschmidt <[email protected]>

Quoted 6 lines · Octavian Purdila
Quoted 1 line

So I'm going to merge 1/2 but this one should really be changed to advertise ppc/750 in oprofile_cpu_type (ie. to userspace).

Sure. Here is the new patch which uses ppc/750. It enables oprofile for all 3 FX variants and GX as well.

Thanks!
tavi

commit 70f4865a614e9b0ff4594ebd52b95f78e998b79f

Author: Octavian Purdila <[email protected]>
Date:   Tue Jan 6 12:51:43 2009 +0200

powerpc: oprofile: enable support for ppc750 processors

arch/powerpc/kernel/cputable.c +8 -0
index 923f87a..c3ea72b 100644
@@ -726,6 +726,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/750",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 750FX rev 2.0 must disable HID0[DPM] */
 		.pvr_mask		= 0xffffffff,
@@ -741,6 +743,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/750",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 750FX (All revs except 2.0) */
 		.pvr_mask		= 0xffff0000,
@@ -756,6 +760,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750fx,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/750",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 750GX */
 		.pvr_mask		= 0xffff0000,
@@ -771,6 +777,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.cpu_setup		= __setup_cpu_750fx,
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/750",
+		.oprofile_type		= PPC_OPROFILE_G4,
 	},
 	{	/* 740/750 (L2CR bit need fixup for 740) */
 		.pvr_mask		= 0xffff0000,
#12 lore raw
In reply to Octavian Purdila
Quoted 5 lines · Octavian Purdila

Adds oprofile support for ppc750. ppc750 performance counters interface is similar with G4, but it only has 4 performance counters instead of 6.

I tested this on a PPC750GX and it seems to work fine.

I'm not too sure about using the same model as 74xx... I have some patches that haven't been released yet from Jack Miller to implement the full OP support for 750 but they appear to cause crashes.

There is a known HW bug in various 750's that basically make the performance interrupt unuseable. I -think- it may have been fixed in the very latest revision of the 750CL though but I'm not sure.

Cheers,
Ben.

#13 lore raw

=46rom: Benjamin Herrenschmidt <[email protected]>

Quoted 8 lines · Octavian Purdila
Quoted 5 lines

Adds oprofile support for ppc750. ppc750 performance counters interface is similar with G4, but it only has 4 performance counters instead of 6.

I tested this on a PPC750GX and it seems to work fine.

I'm not too sure about using the same model as 74xx...=20

I've double checked the bits, and it looks to me that what is implemented i= n=20
op_model_7450.c maps with my User=E2=80=99s Manual IBM PowerPC 750GX and 75= 0GL RISC=20
Microprocessor copy :)

Quoted 4 lines

I have some
patches that haven't been released yet from Jack Miller to implement the full OP support for 750 but they appear to cause crashes.

Were they posted somewhere?

Quoted 3 lines

There is a known HW bug in various 750's that basically make the performance interrupt unuseable. I -think- it may have been fixed in the very latest revision of the 750CL though but I'm not sure.

Yeah, I've read that somewhere, but I did not notice any issues with 750GX = I=20
am using - so far.

Thanks,
tavi