Skip to contentSkip to conversation

Fix CPU hotplug when using the SLB shadow buffer

PATCH New Michael Neuling 2 participants 6 messages Jan 10, 2008 – Jan 11, 2008 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix CPU hotplug when using the SLB shadow buffer

Before we register the SLB shadow buffer, we need to invalidate the entries in the buffer otherwise we can end up stale entries from when we offlined the CPU.

This patch does this invalidate as well as unregistering the buffer with PHYP before we offline the cpu. Tested and fixes crashes seen on 970MP (thanks to tonyb) and POWER5.

---
paulus: This, or some variant of it, is probably 2.6.24 material.

 arch/powerpc/mm/slb.c                        |    2 +-
 arch/powerpc/platforms/pseries/hotplug-cpu.c |    2 ++
 arch/powerpc/platforms/pseries/lpar.c        |    6 ++++++
 3 files changed, 9 insertions(+), 1 deletion(-)
arch/powerpc/mm/slb.c +1 -1
Index: linux-2.6-ozlabs/arch/powerpc/mm/slb.c
===================================================================
@@ -77,7 +77,7 @@ static inline void slb_shadow_update(uns
 	get_slb_shadow()->save_area[entry].esid = mk_esid_data(ea, ssize, entry);
 }
 
-static inline void slb_shadow_clear(unsigned long entry)
+void slb_shadow_clear(unsigned long entry)
 {
 	get_slb_shadow()->save_area[entry].esid = 0;
 }
arch/powerpc/platforms/pseries/hotplug-cpu.c +2 -0
Index: linux-2.6-ozlabs/arch/powerpc/platforms/pseries/hotplug-cpu.c
===================================================================
@@ -29,6 +29,7 @@
 #include <asm/vdso_datapage.h>
 #include <asm/pSeries_reconfig.h>
 #include "xics.h"
+#include "plpar_wrappers.h"
 
 /* This version can't take the spinlock, because it never returns */
 static struct rtas_args rtas_stop_self_args = {
@@ -58,6 +59,7 @@ static void pseries_mach_cpu_die(void)
 	local_irq_disable();
 	idle_task_exit();
 	xics_teardown_cpu(0);
+	unregister_slb_shadow(smp_processor_id(), __pa(get_slb_shadow()));
 	rtas_stop_self();
 	/* Should never get here... */
 	BUG();
arch/powerpc/platforms/pseries/lpar.c +6 -0
Index: linux-2.6-ozlabs/arch/powerpc/platforms/pseries/lpar.c
===================================================================
@@ -248,16 +248,22 @@ out:
 	of_node_put(stdout_node);
 }
 
+extern void slb_shadow_clear(unsigned long entry);
+
 void vpa_init(int cpu)
 {
 	int hwcpu = get_hard_smp_processor_id(cpu);
 	unsigned long addr;
 	long ret;
+	int i;
 
 	if (cpu_has_feature(CPU_FTR_ALTIVEC))
 		lppaca[cpu].vmxregs_in_use = 1;
 
 	addr = __pa(&lppaca[cpu]);
+	for (i = 0; i < SLB_NUM_BOLTED; i++){
+		slb_shadow_clear(i);
+	}
 	ret = register_vpa(hwcpu, addr);
 
 	if (ret) {
#1 lore raw

PATCH 1/1 Fix CPU hotplug when using the SLB shadow buffer

Before we register the SLB shadow buffer, we need to invalidate the entries in the buffer otherwise we can end up stale entries from when we offlined the CPU.

This patch does this invalidate as well as unregistering the buffer with PHYP before we offline the cpu. Tested and fixes crashes seen on 970MP (thanks to tonyb) and POWER5.

---
Updates for comments by mpe.

Also, thanks to Anton for helping find this problem.

 arch/powerpc/mm/slb.c                        |    2 +-
 arch/powerpc/platforms/pseries/hotplug-cpu.c |    2 ++
 arch/powerpc/platforms/pseries/lpar.c        |    3 +++
 include/asm-powerpc/mmu-hash64.h             |    1 +
 4 files changed, 7 insertions(+), 1 deletion(-)
arch/powerpc/mm/slb.c +1 -1
Index: linux-2.6-ozlabs/arch/powerpc/mm/slb.c
===================================================================
@@ -77,7 +77,7 @@ static inline void slb_shadow_update(uns
 	get_slb_shadow()->save_area[entry].esid = mk_esid_data(ea, ssize, entry);
 }
 
-static inline void slb_shadow_clear(unsigned long entry)
+void slb_shadow_clear(unsigned long entry)
 {
 	get_slb_shadow()->save_area[entry].esid = 0;
 }
arch/powerpc/platforms/pseries/hotplug-cpu.c +2 -0
Index: linux-2.6-ozlabs/arch/powerpc/platforms/pseries/hotplug-cpu.c
===================================================================
@@ -29,6 +29,7 @@
 #include <asm/vdso_datapage.h>
 #include <asm/pSeries_reconfig.h>
 #include "xics.h"
+#include "plpar_wrappers.h"
 
 /* This version can't take the spinlock, because it never returns */
 static struct rtas_args rtas_stop_self_args = {
@@ -58,6 +59,7 @@ static void pseries_mach_cpu_die(void)
 	local_irq_disable();
 	idle_task_exit();
 	xics_teardown_cpu(0);
+	unregister_slb_shadow(smp_processor_id(), __pa(get_slb_shadow()));
 	rtas_stop_self();
 	/* Should never get here... */
 	BUG();
arch/powerpc/platforms/pseries/lpar.c +3 -0
Index: linux-2.6-ozlabs/arch/powerpc/platforms/pseries/lpar.c
===================================================================
@@ -253,6 +253,7 @@ void vpa_init(int cpu)
 	int hwcpu = get_hard_smp_processor_id(cpu);
 	unsigned long addr;
 	long ret;
+	int i;
 
 	if (cpu_has_feature(CPU_FTR_ALTIVEC))
 		lppaca[cpu].vmxregs_in_use = 1;
@@ -272,6 +273,8 @@ void vpa_init(int cpu)
 	 */
 	addr = __pa(&slb_shadow[cpu]);
 	if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
+		for (i = 0; i < SLB_NUM_BOLTED; i++)
+			slb_shadow_clear(i);
 		ret = register_slb_shadow(hwcpu, addr);
 		if (ret)
 			printk(KERN_ERR
include/asm-powerpc/mmu-hash64.h +1 -0
Index: linux-2.6-ozlabs/include/asm-powerpc/mmu-hash64.h
===================================================================
@@ -286,6 +286,7 @@ extern void hpte_init_iSeries(void);
 extern void hpte_init_beat(void);
 extern void hpte_init_beat_v3(void);
 
+extern void slb_shadow_clear(unsigned long entry);
 extern void stabs_alloc(void);
 extern void slb_initialize(void);
 extern void slb_flush_and_rebolt(void);
#2 lore raw

PATCH 1/1 Fix CPU hotplug when using the SLB shadow buffer

Before we register the SLB shadow buffer, we need to invalidate the entries in the buffer otherwise we can end up stale entries from when we offlined the CPU.

This patch does this invalidate as well as unregistering the buffer with PHYP before we offline the cpu. Tested and fixes crashes seen on 970MP (thanks to tonyb) and POWER5.

---
Updates for offline comments from paulus

 arch/powerpc/mm/slb.c                        |    8 ++++++++
 arch/powerpc/platforms/pseries/hotplug-cpu.c |    2 ++
 arch/powerpc/platforms/pseries/lpar.c        |    1 +
 include/asm-powerpc/mmu-hash64.h             |    1 +
 4 files changed, 12 insertions(+)
arch/powerpc/mm/slb.c +8 -0
Index: linux-2.6-ozlabs/arch/powerpc/mm/slb.c
===================================================================
@@ -82,6 +82,14 @@ static inline void slb_shadow_clear(unsi
 	get_slb_shadow()->save_area[entry].esid = 0;
 }
 
+void slb_shadow_clear_all(void)
+{
+	int i;
+
+	for (i = 0; i < SLB_NUM_BOLTED; i++)
+		slb_shadow_clear(i);
+}
+
 static inline void create_shadowed_slbe(unsigned long ea, int ssize,
 					unsigned long flags,
 					unsigned long entry)
arch/powerpc/platforms/pseries/hotplug-cpu.c +2 -0
Index: linux-2.6-ozlabs/arch/powerpc/platforms/pseries/hotplug-cpu.c
===================================================================
@@ -29,6 +29,7 @@
 #include <asm/vdso_datapage.h>
 #include <asm/pSeries_reconfig.h>
 #include "xics.h"
+#include "plpar_wrappers.h"
 
 /* This version can't take the spinlock, because it never returns */
 static struct rtas_args rtas_stop_self_args = {
@@ -58,6 +59,7 @@ static void pseries_mach_cpu_die(void)
 	local_irq_disable();
 	idle_task_exit();
 	xics_teardown_cpu(0);
+	unregister_slb_shadow(smp_processor_id(), __pa(get_slb_shadow()));
 	rtas_stop_self();
 	/* Should never get here... */
 	BUG();
arch/powerpc/platforms/pseries/lpar.c +1 -0
Index: linux-2.6-ozlabs/arch/powerpc/platforms/pseries/lpar.c
===================================================================
@@ -272,6 +272,7 @@ void vpa_init(int cpu)
 	 */
 	addr = __pa(&slb_shadow[cpu]);
 	if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
+		slb_shadow_clear_all();
 		ret = register_slb_shadow(hwcpu, addr);
 		if (ret)
 			printk(KERN_ERR
include/asm-powerpc/mmu-hash64.h +1 -0
Index: linux-2.6-ozlabs/include/asm-powerpc/mmu-hash64.h
===================================================================
@@ -286,6 +286,7 @@ extern void hpte_init_iSeries(void);
 extern void hpte_init_beat(void);
 extern void hpte_init_beat_v3(void);
 
+extern void slb_shadow_clear_all(void);
 extern void stabs_alloc(void);
 extern void slb_initialize(void);
 extern void slb_flush_and_rebolt(void);
#3 lore raw

arch/powerpc/platforms/pseries/hotplug-cpu.c static void pseries_mach_cpu_die(void) · line 62

Quoted 5 lines · Michael Neuling
arch/powerpc/platforms/pseries/hotplug-cpu.c +1 -0
@@ -58,6 +59,7 @@ static void pseries_mach_cpu_die(void)
 	local_irq_disable();
 	idle_task_exit();
 	xics_teardown_cpu(0);
+	unregister_slb_shadow(smp_processor_id(), __pa(get_slb_shadow()));
                                     ^

Should that not be hard_smp_processor_id()?

(sorry for not commenting earlier)

#4 lore raw
Quoted 7 lines

arch/powerpc/platforms/pseries/hotplug-cpu.c static void pseries_mach_cpu_die(void) · line 62

Quoted 5 lines
arch/powerpc/platforms/pseries/hotplug-cpu.c +1 -0
@@ -58,6 +59,7 @@ static void pseries_mach_cpu_die(void)
 	local_irq_disable();
 	idle_task_exit();
 	xics_teardown_cpu(0);
+	unregister_slb_shadow(smp_processor_id(), __pa(get_slb_shadow()));
                                     ^

Should that not be hard_smp_processor_id()?

Thanks.. I think you're right since we register each CPU with a get_hard_smp_processor_id(cpu).

I'll update.

Mikey

#5 lore raw

PATCH 1/1 Fix CPU hotplug when using the SLB shadow buffer

In reply to Nathan Lynch

Before we register the SLB shadow buffer, we need to invalidate the entries in the buffer otherwise we can end up stale entries from when we offlined the CPU.

This patch does this invalidate as well as unregistering the buffer with PHYP before we offline the cpu. Tested and fixes crashes seen on 970MP (thanks to tonyb) and POWER5.

---
Updated based on comment from ntl

 arch/powerpc/mm/slb.c                        |    8 ++++++++
 arch/powerpc/platforms/pseries/hotplug-cpu.c |    2 ++
 arch/powerpc/platforms/pseries/lpar.c        |    1 +
 include/asm-powerpc/mmu-hash64.h             |    1 +
 4 files changed, 12 insertions(+)
arch/powerpc/mm/slb.c +8 -0
Index: linux-2.6-ozlabs/arch/powerpc/mm/slb.c
===================================================================
@@ -82,6 +82,14 @@ static inline void slb_shadow_clear(unsi
 	get_slb_shadow()->save_area[entry].esid = 0;
 }
 
+void slb_shadow_clear_all(void)
+{
+	int i;
+
+	for (i = 0; i < SLB_NUM_BOLTED; i++)
+		slb_shadow_clear(i);
+}
+
 static inline void create_shadowed_slbe(unsigned long ea, int ssize,
 					unsigned long flags,
 					unsigned long entry)
arch/powerpc/platforms/pseries/hotplug-cpu.c +2 -0
Index: linux-2.6-ozlabs/arch/powerpc/platforms/pseries/hotplug-cpu.c
===================================================================
@@ -29,6 +29,7 @@
 #include <asm/vdso_datapage.h>
 #include <asm/pSeries_reconfig.h>
 #include "xics.h"
+#include "plpar_wrappers.h"
 
 /* This version can't take the spinlock, because it never returns */
 static struct rtas_args rtas_stop_self_args = {
@@ -58,6 +59,7 @@ static void pseries_mach_cpu_die(void)
 	local_irq_disable();
 	idle_task_exit();
 	xics_teardown_cpu(0);
+	unregister_slb_shadow(hard_smp_processor_id(), __pa(get_slb_shadow()));
 	rtas_stop_self();
 	/* Should never get here... */
 	BUG();
arch/powerpc/platforms/pseries/lpar.c +1 -0
Index: linux-2.6-ozlabs/arch/powerpc/platforms/pseries/lpar.c
===================================================================
@@ -272,6 +272,7 @@ void vpa_init(int cpu)
 	 */
 	addr = __pa(&slb_shadow[cpu]);
 	if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
+		slb_shadow_clear_all();
 		ret = register_slb_shadow(hwcpu, addr);
 		if (ret)
 			printk(KERN_ERR
include/asm-powerpc/mmu-hash64.h +1 -0
Index: linux-2.6-ozlabs/include/asm-powerpc/mmu-hash64.h
===================================================================
@@ -286,6 +286,7 @@ extern void hpte_init_iSeries(void);
 extern void hpte_init_beat(void);
 extern void hpte_init_beat_v3(void);
 
+extern void slb_shadow_clear_all(void);
 extern void stabs_alloc(void);
 extern void slb_initialize(void);
 extern void slb_flush_and_rebolt(void);