up unpinned mmap usable address space from 2 to 3 GB
Subsystems (2)
RFC PATCH 1/1 up unpinned mmap usable address space from 2 to 3 GB
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.
Due to the fragility of making changes to get_unmapped_area(), this patch is intended 'For Comment Only'.
Against 2.6.7.
Regards,
Joe
================== Test.java
public class Test
{
private static int threadCounter = 0;
public static synchronized int getThreadNumber() {
return threadCounter++;
} public static void main(String [] args) {
for(int i = 0; i < 6000; i++) {
new Thread(new Runnable() {
public void run() {
System.err.println("Thread " + getThreadNumber());
while(true) {
try {
Thread.currentThread().sleep(10000);
} catch(InterruptedException ie) {
// Don't care
}
}
}
}
).start();
} }
}
================== compilation instructions
Download Java 2 SDK 1.4.2_04 linux i586 from java.sun.com, install javac Test.java
java -Xmx1000M -Xms1000M -cp . Test
================== patch
include/asm-i386/processor.h +3 -0
@@ -301,6 +301,9 @@* space during mmap's. */ #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) +#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)/* * Size of io_bitmap, covering ports 0 to 0x3ff.
mm/mmap.c +40 -9
80 lines not on this page · raw message