
From: Ingo Molnar <mingo@elte.hu>

There are a few devices that use lots of ioremap space.  vmalloc space is a
showstopper problem for them.

this patch adds the vmalloc=<size> boot parameter to override
__VMALLOC_RESERVE.  The default is 128mb right now - e.g.  vmalloc=256m
doubles the size.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjanv@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/i386/boot/setup.S   |    2 +-
 25-akpm/arch/i386/kernel/setup.c |    8 ++++++++
 25-akpm/arch/i386/mm/init.c      |    2 ++
 25-akpm/include/asm-i386/page.h  |    6 +++---
 25-akpm/mm/vmalloc.c             |    2 ++
 5 files changed, 16 insertions(+), 4 deletions(-)

diff -puN arch/i386/boot/setup.S~tune-vmalloc-size arch/i386/boot/setup.S
--- 25/arch/i386/boot/setup.S~tune-vmalloc-size	2004-09-15 23:29:24.671634800 -0700
+++ 25-akpm/arch/i386/boot/setup.S	2004-09-15 23:29:24.682633128 -0700
@@ -156,7 +156,7 @@ cmd_line_ptr:	.long 0			# (Header versio
 					# can be located anywhere in
 					# low memory 0x10000 or higher.
 
-ramdisk_max:	.long (MAXMEM-1) & 0x7fffffff
+ramdisk_max:	.long (-__PAGE_OFFSET-(512 << 20)-1) & 0x7fffffff
 					# (Header version 0x0203 or later)
 					# The highest safe address for
 					# the contents of an initrd
diff -puN arch/i386/kernel/setup.c~tune-vmalloc-size arch/i386/kernel/setup.c
--- 25/arch/i386/kernel/setup.c~tune-vmalloc-size	2004-09-15 23:29:24.672634648 -0700
+++ 25-akpm/arch/i386/kernel/setup.c	2004-09-15 23:29:24.684632824 -0700
@@ -815,6 +815,14 @@ static void __init parse_cmdline_early (
 		if (c == ' ' && !memcmp(from, "highmem=", 8))
 			highmem_pages = memparse(from+8, &from) >> PAGE_SHIFT;
 	
+		/*
+		 * vmalloc=size forces the vmalloc area to be exactly 'size'
+		 * bytes. This can be used to increase (or decrease) the
+		 * vmalloc area - the default is 128m.
+		 */
+		if (c == ' ' && !memcmp(from, "vmalloc=", 8))
+			__VMALLOC_RESERVE = memparse(from+8, &from);
+
 		c = *(from++);
 		if (!c)
 			break;
diff -puN arch/i386/mm/init.c~tune-vmalloc-size arch/i386/mm/init.c
--- 25/arch/i386/mm/init.c~tune-vmalloc-size	2004-09-15 23:29:24.674634344 -0700
+++ 25-akpm/arch/i386/mm/init.c	2004-09-15 23:29:24.684632824 -0700
@@ -40,6 +40,8 @@
 #include <asm/tlbflush.h>
 #include <asm/sections.h>
 
+unsigned int __VMALLOC_RESERVE = 128 << 20;
+
 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 unsigned long highstart_pfn, highend_pfn;
 
diff -puN include/asm-i386/page.h~tune-vmalloc-size include/asm-i386/page.h
--- 25/include/asm-i386/page.h~tune-vmalloc-size	2004-09-15 23:29:24.675634192 -0700
+++ 25-akpm/include/asm-i386/page.h	2004-09-15 23:29:24.685632672 -0700
@@ -94,13 +94,13 @@ typedef struct { unsigned long pgprot; }
  * and CONFIG_HIGHMEM64G options in the kernel configuration.
  */
 
+#ifndef __ASSEMBLY__
+
 /*
  * This much address space is reserved for vmalloc() and iomap()
  * as well as fixmap mappings.
  */
-#define __VMALLOC_RESERVE	(128 << 20)
-
-#ifndef __ASSEMBLY__
+extern unsigned int __VMALLOC_RESERVE;
 
 /* Pure 2^n version of get_order */
 static __inline__ int get_order(unsigned long size)
diff -puN mm/vmalloc.c~tune-vmalloc-size mm/vmalloc.c
--- 25/mm/vmalloc.c~tune-vmalloc-size	2004-09-15 23:29:24.678633736 -0700
+++ 25-akpm/mm/vmalloc.c	2004-09-15 23:29:24.686632520 -0700
@@ -247,6 +247,8 @@ found:
 out:
 	write_unlock(&vmlist_lock);
 	kfree(area);
+	if (printk_ratelimit())
+		printk(KERN_WARNING "allocation failed: out of vmalloc space - use vmalloc=<size> to increase size.\n");
 	return NULL;
 }
 
_
