• Andrea Arcangeli's avatar
    thp: mremap support and TLB optimization · 37a1c49a
    Andrea Arcangeli authored
    This adds THP support to mremap (decreases the number of split_huge_page()
    calls).
    
    Here are also some benchmarks with a proggy like this:
    
    ===
    #define _GNU_SOURCE
    #include <sys/mman.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    #include <sys/time.h>
    
    #define SIZE (5UL*1024*1024*1024)
    
    int main()
    {
            static struct timeval oldstamp, newstamp;
    	long diffsec;
    	char *p, *p2, *p3, *p4;
    	if (posix_memalign((void **)&p, 2*1024*1024, SIZE))
    		perror("memalign"), exit(1);
    	if (posix_memalign((void **)&p2, 2*1024*1024, SIZE))
    		perror("memalign"), exit(1);
    	if (posix_memalign((void **)&p3, 2*1024*1024, 4096))
    		perror("memalign"), exit(1);
    
    	memset(p, 0xff, SIZE);
    	memset(p2, 0xff, SIZE);
    	memset(p3, 0x77, 4096);
    	gettimeofday(&oldstamp, NULL);
    	p4 = mremap(p, SIZE, SIZE, MREMAP_FIXED|MREMAP_MAYMOVE, p3);
    	gettimeofday(&newstamp, NULL);
    	diffsec = newstamp.tv_sec - oldstamp.tv_sec;
    	diffsec = newstamp.tv_usec - oldstamp.tv_usec + 1000000 * diffsec;
    	pri...
    37a1c49a
mremap.c 13.7 KB