lkml.org 
[lkml]   [1999]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectPerform minimal RAM test at boot
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/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.043 / U:1.592 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site