patch-2.1.121 linux/arch/alpha/mm/init.c

Next file: linux/arch/arm/Makefile
Previous file: linux/arch/alpha/mm/fault.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.120/linux/arch/alpha/mm/init.c linux/arch/alpha/mm/init.c
@@ -7,7 +7,6 @@
 #include <linux/config.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
-#include <linux/head.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
@@ -16,6 +15,9 @@
 #include <linux/mman.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
+#ifdef CONFIG_BLK_DEV_INITRD
+#include <linux/blk.h>
+#endif
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -23,6 +25,8 @@
 #include <asm/hwrpb.h>
 #include <asm/dma.h>
 
+#define DEBUG_POISON 0
+
 extern void die_if_kernel(char *,struct pt_regs *,long);
 extern void show_net_buffers(void);
 
@@ -259,6 +263,29 @@
 }
 #endif /* __SMP__ */
 
+#if DEBUG_POISON
+static void
+kill_page(unsigned long pg)
+{
+	unsigned long *p = (unsigned long *)pg;
+	unsigned long i = PAGE_SIZE, v = 0xdeadbeefdeadbeef;
+	do {
+		p[0] = v;
+		p[1] = v;
+		p[2] = v;
+		p[3] = v;
+		p[4] = v;
+		p[5] = v;
+		p[6] = v;
+		p[7] = v;
+		i -= 64;
+		p += 8;
+	} while (i != 0);
+}
+#else
+#define kill_page(pg)
+#endif
+
 void
 mem_init(unsigned long start_mem, unsigned long end_mem)
 {
@@ -284,6 +311,11 @@
 		if (PageReserved(mem_map+MAP_NR(tmp)))
 			continue;
 		atomic_set(&mem_map[MAP_NR(tmp)].count, 1);
+#ifdef CONFIG_BLK_DEV_INITRD
+		if (initrd_start && tmp >= initrd_start && tmp < initrd_end)
+			continue;
+#endif
+		kill_page(tmp);
 		free_page(tmp);
 	}
 	tmp = nr_free_pages << PAGE_SHIFT;
@@ -301,6 +333,7 @@
 	for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
 		mem_map[MAP_NR(addr)].flags &= ~(1 << PG_reserved);
 		atomic_set(&mem_map[MAP_NR(addr)].count, 1);
+		kill_page(addr);
 		free_page(addr);
 	}
 	printk ("Freeing unused kernel memory: %ldk freed\n",

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov