by avdicius on 9/19/15, 8:10 PM with 0 comments
http://stackoverflow.com/questions/32336694/huge-pages-on-mac-os-x
I'm trying to mmap a huge pages memory region using the documented Mac OS X API for this. But it simply doesn't work. Any ideas on what is wrong with the following code snippet:
#include <stdio.h>
#include <sys/mman.h>
#include <mach/vm_statistics.h>
int
main()
{
void *p = mmap((void *) 0x000200000000, 8 * 1024 * 1024,
PROT_READ | PROT_WRITE,
MAP_ANON | MAP_FIXED | MAP_PRIVATE,
VM_FLAGS_SUPERPAGE_SIZE_2MB, 0);
printf("%p\n", p);
if (p == MAP_FAILED)
perror(NULL);
return 0;
}