Reputation: 956
I want to test huge memory page allocation on Linux. Just to have another method up in the sleeve. But my test simply fails to compile.
pa = mmap(0, 1024*1024*2, PROT_READ, MAP_PRIVATE|MAP_HUGETLB, -1, 0)
Produces:
error: use of undeclared identifier 'MAP_HUGETLB'
Ideally I wish to mmap a file. But anonimous memory will also do.
The output from hugeadm --pool-list
:
Size Minimum Current Maximum Default
2097152 1024 1024 1024 *
1073741824 0 0 0
The question is, how could I allocate memory, backed by huge pages?
Upvotes: 1
Views: 967
Reputation: 15566
You have to #define _GNU_SOURCE
before #include <sys/mman.h>
because this is a nonstandard flag.
Upvotes: 2