[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-mm
Subject:    Huge pages: Memory leak on mmap failure
From:       Christoph Lameter <cl () linux ! com>
Date:       2012-05-17 21:07:30
Message-ID: alpine.DEB.2.00.1205171605001.19076 () router ! home
[Download RAW message or body]


On 2.6.32 and 3.4-rc6 mmap failure of a huge page causes a memory
leak. The 32 byte kmalloc cache grows by 10 mio entries if running
the following code:

--------
#include <sys/mman.h>
#include <stdlib.h>

#ifndef MAP_HUGETLB
#define MAP_HUGETLB 0x0040000
#endif

int main() {
    for (int i=0; i!=10000000; ++i) {
        void* ptr=mmap(NULL, 2*1024*1024, PROT_READ|PROT_WRITE, \
MAP_PRIVATE|MAP_ANONYMOUS|MAP_HUGETLB, 0, 0);  if (ptr!=MAP_FAILED) abort();
    }
    return 0;
}

-------


g++ -O2 test.cpp && echo good
good

$ egrep 'SUnreclaim|HugePages_Total' /proc/meminfo
SUnreclaim:      1900756 kB
HugePages_Total:       0

$ ./a.out && echo good
good

$ egrep 'SUnreclaim|HugePages_Total' /proc/meminfo
SUnreclaim:      2213268 kB
HugePages_Total:       0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic