linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Huge pages: Memory leak on mmap failure
@ 2012-05-17 21:07 Christoph Lameter
  2012-05-17 21:58 ` Dave Hansen
  2012-05-17 22:50 ` Dave Hansen
  0 siblings, 2 replies; 5+ messages in thread
From: Christoph Lameter @ 2012-05-17 21:07 UTC (permalink / raw)
  To: Andrea Arcangeli
  Cc: Dave Hansen, KOSAKI Motohiro, Hugh Dickins, David Rientjes,
	Alexey Dobriyan, linux-mm, Andrew Morton


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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-21 14:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-17 21:07 Huge pages: Memory leak on mmap failure Christoph Lameter
2012-05-17 21:58 ` Dave Hansen
2012-05-17 22:50 ` Dave Hansen
2012-05-18  0:54   ` KOSAKI Motohiro
2012-05-21 14:21   ` Mel Gorman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).