This bug can be easily triggered by test-tool in attachment. I run it with with this arguments: ./mm-thp-torture 100 100
/* * torture-test for transparent huge pages, * memory migration and memory compaction =) * * usage: ./mm-thp-tortire <threads> <pages> * * to eat all avaliable huge pages: * threads * pages >= ram[mb] / 2[mb] * */ #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <signal.h> #include <sys/mman.h> #define PAGE_SIZE (4096) #define HPAGE_SIZE (4096*512) int main(int argc, char **argv) { long pages, threads; char *buf, *ptr; if (argc < 3) return 2; signal(SIGCHLD, SIG_IGN); threads = atol(argv[1]); pages = atol(argv[2]); buf = mmap(NULL, (pages + 1) * HPAGE_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0); if (buf == MAP_FAILED) return 3; buf += HPAGE_SIZE - ((long)buf & (HPAGE_SIZE-1)); while (--threads > 0 && !fork()); while (1) { for ( ptr = buf ; ptr < buf + pages * HPAGE_SIZE ; ptr += HPAGE_SIZE ) { if (mmap(ptr, HPAGE_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE|MAP_FIXED, -1, 0) != ptr) return 4; *ptr = 0; munmap(ptr + PAGE_SIZE, HPAGE_SIZE - PAGE_SIZE); } if (!fork()) exit(0); munmap(buf, pages * HPAGE_SIZE); } return 0; }