Skip to contentSkip to conversation

powerpc: DEBUG_PAGEALLOC for 32 bits

HACK Benjamin Herrenschmidt 1 participant 1 message Mar 6, 2007 PowerPC

lore
Share & tools
lore
#0 lore raw

Here's an implementation of DEBUG_PAGEALLOC for ppc32. It disables BAT mapping and is only tested with Hash table based processor though it shouldn't be too hard to adapt it to others.

It has at least one known problem: The current ppc32 kernel has a known problem when running without BATs as it can't cope with hash misses in some hash management code path. In practice, it will probably work just fine on UP and might deadlock every now and then on SMP. I might look into fixing that some day....

In the meantime, I think I already found a hit with that patch in ide-pmac... good tool to have. I'll look into doing it for 64 bits later.

arch/powerpc/Kconfig.debug +9 -0
Index: linux-work/arch/powerpc/Kconfig.debug
===================================================================
@@ -18,6 +18,15 @@
 
 	  This option will slow down process creation somewhat.
 
+config DEBUG_PAGEALLOC
+        bool "Debug page memory allocations"
+        depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND && PPC32
+        help
+          Unmap pages from the kernel linear mapping after free_pages().
+          This results in a large slowdown, but helps to find certain types
+          of memory corruptions.
+
+
 config HCALL_STATS
 	bool "Hypervisor call instrumentation"
 	depends on PPC_PSERIES && DEBUG_FS
arch/powerpc/mm/init_32.c +4 -0
Index: linux-work/arch/powerpc/mm/init_32.c
===================================================================
@@ -115,6 +115,10 @@
 	if (strstr(cmd_line, "noltlbs")) {
 		__map_without_ltlbs = 1;
 	}
+#ifdef CONFIG_DEBUG_PAGEALLOC
+	__map_without_bats = 1;
+	__map_without_ltlbs = 1;
+#endif
 }
 
 /*
arch/powerpc/mm/pgtable_32.c +55 -3

67 lines not on this page · raw message

arch/powerpc/mm/ppc_mmu_32.c +3 -1
Index: linux-work/arch/powerpc/mm/ppc_mmu_32.c
===================================================================
@@ -85,8 +85,10 @@
 	unsigned long max_size = (256<<20);
 	unsigned long align;
 
-	if (__map_without_bats)
+	if (__map_without_bats) {
+		printk(KERN_DEBUG "RAM mapped without BATs for data\n");
 		return 0;
+	}
 
 	/* Set up BAT2 and if necessary BAT3 to cover RAM. */
 
include/asm-powerpc/cacheflush.h +6 -0
Index: linux-work/include/asm-powerpc/cacheflush.h
===================================================================
@@ -64,6 +64,12 @@
 	memcpy(dst, src, len)
 
 
+
+#ifdef CONFIG_DEBUG_PAGEALLOC
+/* internal debugging function */
+void kernel_map_pages(struct page *page, int numpages, int enable);
+#endif
+
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_POWERPC_CACHEFLUSH_H */