Skip to contentSkip to conversation

powerpc: Fix page_ins details in lppaca comments

PATCH New Jeremy Kerr 2 participants 8 messages Mar 12, 2009 – Mar 25, 2009 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 powerpc: Fix page_ins details in lppaca comments

The page_ins member ends at byte 0x3, not 0x4. Also, fix up the alignment.

---
 arch/powerpc/include/asm/lppaca.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/lppaca.h +1 -1
index 25aaa97..b063121 100644
@@ -133,7 +133,7 @@ struct lppaca {
 //=============================================================================
 // CACHE_LINE_4-5 0x0180 - 0x027F Contains PMC interrupt data
 //=============================================================================
-	u32	page_ins;			// CMO Hint - # page ins by OS  x00-x04
+	u32	page_ins;		// CMO Hint - # page ins by OS  x00-x03
 	u8	pmc_save_area[252];	// PMC interrupt Area           x04-xFF
 } __attribute__((__aligned__(0x400)));
 
#1 lore raw

PATCH 2/3 powerpc: Add dispatch trace log fields to lppaca

PAPR v2.3 defines fields in the virtual processor area for a dispatch trace log (DLT). Since we'd like to use the DLT, add the necessary fields to struct lppaca.

---
 arch/powerpc/include/asm/lppaca.h |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/lppaca.h +4 -2
index b063121..68235f7 100644
@@ -97,7 +97,7 @@ struct lppaca {
 	u64	saved_gpr4;		// Saved GPR4                   x28-x2F
 	u64	saved_gpr5;		// Saved GPR5                   x30-x37
 
-	u8	reserved4;		// Reserved			x38-x38
+	u8	dtl_enable_mask;	// Dispatch Trace Log mask	x38-x38
 	u8	donate_dedicated_cpu;	// Donate dedicated CPU cycles  x39-x39
 	u8	fpregs_in_use;		// FP regs in use               x3A-x3A
 	u8	pmcregs_in_use;		// PMC regs in use              x3B-x3B
@@ -134,7 +134,9 @@ struct lppaca {
 // CACHE_LINE_4-5 0x0180 - 0x027F Contains PMC interrupt data
 //=============================================================================
 	u32	page_ins;		// CMO Hint - # page ins by OS  x00-x03
-	u8	pmc_save_area[252];	// PMC interrupt Area           x04-xFF
+	u8	reserved8[148];		// Reserved                     x04-x97
+	volatile u64 dtl_idx;		// Dispatch Trace Log head idx	x98-x9F
+	u8	reserved9[96];		// Reserved                     xA0-xFF
 } __attribute__((__aligned__(0x400)));
 
 extern struct lppaca lppaca[];
#2 lore raw

PATCH 3/3 powerpc: Add virtual processor dispatch trace log

In reply to Jeremy Kerr

pseries SPLPAR machines are able to retrieve a log of dispatch and preempt events from the hypervisor. With this information, we can see when and why each dispatch & preempt is occuring.

This change adds a set of debugfs files allowing userspace to read this dispatch log.

Based on initial patches from Nishanth Aravamudan <[email protected]>.

---
 arch/powerpc/platforms/pseries/Kconfig          |   10 
 arch/powerpc/platforms/pseries/Makefile         |    1 
 arch/powerpc/platforms/pseries/dtl.c            |  274 ++++++++++++++++++++++++
 arch/powerpc/platforms/pseries/plpar_wrappers.h |   10 
 4 files changed, 295 insertions(+)
arch/powerpc/platforms/pseries/Kconfig +10 -0
index ddc2a30..730a5cd 100644
@@ -63,3 +63,13 @@ config CMM
 	  makes sense for a system running in an LPAR where the unused pages
 	  will be reused for other LPARs. The interface allows firmware to
 	  balance memory across many LPARs.
+
+config DTL
+	bool "Dispatch Trace Log"
+	depends on PPC_SPLPAR && DEBUG_FS
+	help
+	  SPLPAR machines can log hypervisor preempt & dispatch events to a
+	  kernel buffer. Saying Y here will enable logging these events,
+	  which are accessible through a debugfs file.
+
+	  Say N if you are unsure.
arch/powerpc/platforms/pseries/Makefile +1 -0
index dfe574a..1b388b3 100644
@@ -25,3 +25,4 @@ obj-$(CONFIG_HVCS)		+= hvcserver.o
 obj-$(CONFIG_HCALL_STATS)	+= hvCall_inst.o
 obj-$(CONFIG_PHYP_DUMP)	+= phyp_dump.o
 obj-$(CONFIG_CMM)		+= cmm.o
+obj-$(CONFIG_DTL)		+= dtl.o
arch/powerpc/platforms/pseries/dtl.c new file +274 -0

274 lines not on this page · raw message

arch/powerpc/platforms/pseries/plpar_wrappers.h +10 -0
index d967c18..a24a6b2 100644
@@ -43,6 +43,16 @@ static inline long register_slb_shadow(unsigned long cpu, unsigned long vpa)
 	return vpa_call(0x3, cpu, vpa);
 }
 
+static inline long unregister_dtl(unsigned long cpu, unsigned long vpa)
+{
+	return vpa_call(0x6, cpu, vpa);
+}
+
+static inline long register_dtl(unsigned long cpu, unsigned long vpa)
+{
+	return vpa_call(0x2, cpu, vpa);
+}
+
 static inline long plpar_page_set_loaned(unsigned long vpa)
 {
 	unsigned long cmo_page_sz = cmo_get_page_size();
#3 lore raw

PATCH v2 1/1 powerpc: Add virtual processor dispatch trace log

pseries SPLPAR machines are able to retrieve a log of dispatch and preempt events from the hypervisor. With this information, we can see when and why each dispatch & preempt is occuring.

This change adds a set of debugfs files allowing userspace to read this dispatch log.

Based on initial patches from Nishanth Aravamudan <[email protected]>.

---
v2: smp_wmb before enabling logging

---
 arch/powerpc/platforms/pseries/Kconfig          |   10 
 arch/powerpc/platforms/pseries/Makefile         |    1 
 arch/powerpc/platforms/pseries/dtl.c            |  278 ++++++++++++++++++++++++
 arch/powerpc/platforms/pseries/plpar_wrappers.h |   10 
 4 files changed, 299 insertions(+)
arch/powerpc/platforms/pseries/Kconfig +10 -0
index ddc2a30..730a5cd 100644
@@ -63,3 +63,13 @@ config CMM
 	  makes sense for a system running in an LPAR where the unused pages
 	  will be reused for other LPARs. The interface allows firmware to
 	  balance memory across many LPARs.
+
+config DTL
+	bool "Dispatch Trace Log"
+	depends on PPC_SPLPAR && DEBUG_FS
+	help
+	  SPLPAR machines can log hypervisor preempt & dispatch events to a
+	  kernel buffer. Saying Y here will enable logging these events,
+	  which are accessible through a debugfs file.
+
+	  Say N if you are unsure.
arch/powerpc/platforms/pseries/Makefile +1 -0
index dfe574a..1b388b3 100644
@@ -25,3 +25,4 @@ obj-$(CONFIG_HVCS)		+= hvcserver.o
 obj-$(CONFIG_HCALL_STATS)	+= hvCall_inst.o
 obj-$(CONFIG_PHYP_DUMP)	+= phyp_dump.o
 obj-$(CONFIG_CMM)		+= cmm.o
+obj-$(CONFIG_DTL)		+= dtl.o
arch/powerpc/platforms/pseries/dtl.c new file +278 -0

278 lines not on this page · raw message

arch/powerpc/platforms/pseries/plpar_wrappers.h +10 -0
index d967c18..a24a6b2 100644
@@ -43,6 +43,16 @@ static inline long register_slb_shadow(unsigned long cpu, unsigned long vpa)
 	return vpa_call(0x3, cpu, vpa);
 }
 
+static inline long unregister_dtl(unsigned long cpu, unsigned long vpa)
+{
+	return vpa_call(0x6, cpu, vpa);
+}
+
+static inline long register_dtl(unsigned long cpu, unsigned long vpa)
+{
+	return vpa_call(0x2, cpu, vpa);
+}
+
 static inline long plpar_page_set_loaned(unsigned long vpa)
 {
 	unsigned long cmo_page_sz = cmo_get_page_size();
#4 lore raw

PATCH 1/1 powerpc: Add write barrier before enabling DTL flags

In reply to Jeremy Kerr

Currently, we don't enforce any ordering for updates to the lppaca when enabling dtl logging, so we may end up enabling logging before the index fields have been established.

This change adds a smp_wmb() before doing the actual enable.

---
 arch/powerpc/platforms/pseries/dtl.c |    4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/platforms/pseries/dtl.c +4 -0
index dc9b0f8..fafcaa0 100644
@@ -107,6 +107,10 @@ static int dtl_enable(struct dtl *dtl)
 	/* set our initial buffer indices */
 	dtl->last_idx = lppaca[dtl->cpu].dtl_idx = 0;
 
+	/* ensure that our updates to the lppaca fields have occurred before
+	 * we actually enable the logging */
+	smp_wmb();
+
 	/* enable event logging */
 	lppaca[dtl->cpu].dtl_enable_mask = dtl_event_mask;
 
#5 lore raw

Re: [PATCH] powerpc: Add write barrier before enabling DTL flags

Quoted 17 lines · Jeremy Kerr

Currently, we don't enforce any ordering for updates to the lppaca when enabling dtl logging, so we may end up enabling logging before the index fields have been established.

This change adds a smp_wmb() before doing the actual enable.

---
 arch/powerpc/platforms/pseries/dtl.c |    4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/platforms/pseries/dtl.c +0 -0
index dc9b0f8..fafcaa0 100644

arch/powerpc/platforms/pseries/dtl.c static int dtl_enable(struct dtl *dtl) · line 112

Quoted 6 lines
arch/powerpc/platforms/pseries/dtl.c +3 -0
@@ -107,6 +107,10 @@ static int dtl_enable(struct dtl *dtl)
 	/* set our initial buffer indices */
 	dtl->last_idx = lppaca[dtl->cpu].dtl_idx = 0;
 
+	/* ensure that our updates to the lppaca fields have occurred before
+	 * we actually enable the logging */
+	smp_wmb();

Wouldn't this still be a problem on a UP kernel?

cheers

Signature · 8 lines
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
#6 lore raw

Re: [PATCH] powerpc: Add write barrier before enabling DTL flags

Michael,

Quoted 1 line

Wouldn't this still be a problem on a UP kernel?

I don't believe so - stores should be ordered with respect to the current CPU, and in the UP case we still get a barrier().

However, perhaps there are other considerations with the HV that I'm not aware of. Anyone?

Cheers,

Jeremy

#7 lore raw

Re: [PATCH] powerpc: Add write barrier before enabling DTL flags

Quoted 6 lines · Jeremy Kerr

Michael,

Quoted 1 line

Wouldn't this still be a problem on a UP kernel?

I don't believe so - stores should be ordered with respect to the current CPU, and in the UP case we still get a barrier().

But what if the CPU decides to do the store to the enable_mask before the stores to the other fields?

cheers

Signature · 8 lines
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person