Skip to contentSkip to conversation

up unpinned mmap usable address space from 2 to 3 GB

RFC PATCH Joe Korty 1 participant 1 message Jun 18, 2004 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Joe Korty

author
#1 lore raw
Quoted 17 lines · Andrew Morton
Quoted 16 lines · Joe Korty

Make the full 3 GB of process address space available to unpinned mmaps.
Previously only the 2 GB from 40000000-c0000000 was available.

The process address space allocation behavior should remain unchanged for non-i386 architectures.

For i386, the new algorithm first allocates from virtual address 40000000 to the start of the stack area (as defined by ulimit -s), then from the start of the text area (08000000) down to 00400000, then from 40000000 down to the sbrk area, then (as a last resort) starts allocating from the unused portion of the stack area.

With this patch, a small java program, simulating a real application, can spin off 3,790 threads. Previously, only 1,750 threads could be spun off.

Quoted 8 lines
Quoted 2 lines

Due to the fragility of making changes to get_unmapped_area(), this patch is intended 'For Comment Only'.

Andi said:

It will break tons of software (worse than 4/4). Like Wine or all kinds of JITs and others. AFAIK Fedora already does a much weaker form of this and it isn't pretty.

1) The new algorithm keeps to the old address range and keeps to the same pattern of address space allocations for as long as possible. Only when the point is reached where the old algorithm would have failed is other address ranges looked at. This intrinsically prevents the problems mentioned above for all applications that would have run successfully under the old algorithm.

2) RedHat allocates differently, starting at TASK_SIZE-stacksize and working its way down to zero, yet Wine etc seem to work properly under RedHat.

Quoted 2 lines

But it's a good thing longer term to squeeze some more live out of 32bit. The current layout is indeed quite inefficient.

Yep.

Quoted 5 lines

I would do it not by default, but as a personality. This will be good enough for the people who really need the address space, and make it painless for others. And then maybe enable it unconditionally in 2.7 and support the personality for the old way. But don't switch it over by default in the stable series - that would quite bad.

Done. The attached patch adds a CONFIG option which by default will be off.

Quoted 2 lines

Also I'm not sure the vma last hit cache will still work with his approach. This probably needs some careful profiling.

While in the 'normal zone' the vma last hit cache will work the same as always. When out-of-zone I am pretty sure the cache will cease to be effective.

Joe

arch/i386/Kconfig +18 -0
diff -ura base/arch/i386/Kconfig new/arch/i386/Kconfig
@@ -503,6 +503,24 @@
 	  Say Y here if you are building a kernel for a desktop, embedded
 	  or real-time system.  Say N if you are unsure.
 
+config LARGE_MMAP_SPACE
+       bool "All user space available to unpinned mmaps?"
+       help
+	 If you answer N, then unpinned mmaps (that is, mmaps where the
+	 system picks the virtual address the mmap will attach to) will
+	 be restricted to their traditional address range of 0x40000000
+	 -> 0xc0000000.
+
+	 If you answer Y, then unpinned mmaps can be allocated anywhere
+	 a hole of sufficient size can be found in the address space;
+	 however, preference will continue to be given to its traditional
+	 address range.
+
+	 Users should say Y here unless they encounter an application
+	 which does not work well with the new algorithm.
+
+	 If unsure, say Y.
+
 config X86_UP_APIC
 	bool "Local APIC support on uniprocessors" if !SMP
 	depends on !(X86_VISWS || X86_VOYAGER)
include/asm-i386/processor.h +5 -0
diff -ura base/include/asm-i386/processor.h new/include/asm-i386/processor.h
@@ -301,6 +301,11 @@
  * space during mmap's.
  */
 #define TASK_UNMAPPED_BASE	(PAGE_ALIGN(TASK_SIZE / 3))
+#ifdef CONFIG_LARGE_MMAP_SPACE
+#define TASK_UNMAPPED_BASE_2	(PAGE_ALIGN(16 * PAGE_SIZE))
+#define TASK_SLOP_FUNCTION	(current->rlim[RLIMIT_STACK].rlim_cur)
+#define MIN_TASK_SLOP		(64 * PAGE_SIZE)
+#endif
 
 /*
  * Size of io_bitmap, covering ports 0 to 0x3ff.
mm/mmap.c +40 -9

80 lines not on this page · raw message