Here is my testing program that intentionally caused OOM by calling mmap() to
allocate 8MB each time.
Without patch, it failed at 168th mmap call, and with patch, it failed at 254th
mmap call. It is 688MB more usable virtual address space.
/*
* A simple testing program to cause OOM by calling mmap()
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
void *test_mmap(unsigned long addr, unsigned long size)
{
void *pMem;
pMem = (char *)mmap((void *)addr, size, PROT_NONE, MAP_PRIVATE |
MAP_ANONYMOUS, -1, 0);
printf("%s:addr=0x%08x, size=0x%x, return 0x%08x\n", __FUNCTION__,
addr, size, pMem);
if (MAP_FAILED == pMem)
{
printf("test_mmap FAILED\n");
pMem = NULL;
}
return pMem;
}
int main(int argc, char **argv)
{
int done = 0;
int keep = 1;
while(keep)
{
int i;
int loops =;
if(!done) {
for(i=0; i<loops; i++)
if(test_mmap(0, 0x800000) == NULL)
{
printf("\t\tFAILED at %d try\n", i);
break;
}
done = 1;
}
sleep(1);
}
}
-----Original Message-----
From:
[] On Behalf Of Jian Peng
Sent: Monday, May 16, 2011 2:10 PM
To:
Cc: Ralf Baechle
Subject: patch to support topdown mmap allocation in MIPS
|