Perform minimal RAM test at boot

Pavel Machek (pavel@suse.cz)
Fri, 29 Oct 1999 00:33:25 +0200


Hi!

This trivial patch will add simple memory test at boot.

Why? I have been bitten by non-working memory detection and stale
mem=XXX option in lilo by 5 times now. Once, system even went to full
multiuser and then corrupted disk like hell.

Please apply; this might save lots of developers time...
Pavel

--- clean/init/main.c Sat Oct 23 20:54:57 1999
+++ linux/init/main.c Fri Oct 29 00:29:29 1999
@@ -441,6 +482,46 @@
#endif

/*
+ * Perform simple memory check
+ */
+
+static void **eaten_memory;
+
+static void eat_memory(void)
+{
+ int i = 0;
+ void **c= eaten_memory, *m;
+
+ printk("Eating pages ");
+ while ((m = get_free_page(GFP_ATOMIC))) {
+ eaten_memory = m;
+ if (!(i%5000))
+ printk( "." );
+ *eaten_memory = c;
+ c = eaten_memory;
+ i++;
+ }
+ printk("(%dK)\n", i*4);
+}
+
+static void free_memory(void)
+{
+ int i = 0;
+ void **c = eaten_memory, *f;
+
+ printk( "Freeing pages " );
+ while (c) {
+ if (!(i%5000))
+ printk( "." );
+ f = *c;
+ c = *c;
+ if (f) { free_page( f ); i++; }
+ }
+ printk( "(%dK)\n", i*4 );
+ eaten_memory = NULL;
+}
+
+/*
* Activate the first processor.
*/

@@ -494,12 +575,15 @@
}
#endif
mem_init();
kmem_cache_sizes_init();
#ifdef CONFIG_PROC_FS
proc_root_init();
#endif
mempages = num_physpages;

+ eat_memory(); /* Before mounting root so that we don't damage it */
+ free_memory();
+
fork_init(mempages);
filescache_init();
dcache_init();

-- 
I'm really pavel@ucw.cz. Look at http://195.113.31.123/~pavel.  Pavel
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/