I ran the program with root privilege, but it continues to complain that mmap cannot allocate memory. The following is a snippet of code:
#define PROTECTION (PROT_READ | PROT_WRITE) #define LENGTH (4*1024) #ifndef MAP_HUGETLB #define MAP_HUGETLB 0x40000 #endif #define ADDR (void *) (0x0UL) #define FLAGS (MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB) int main (int argc, char *argv[]){ ...
Hardware: I have 8G RAM. Processor - ivybridge
Uname output:
Linux mymachine 3.13.0-43-generic
EDIT 1: perror output
mmap: Cannot allocate memory
Also added one line to print errno
printf("something is wrong: %d\n", errno);
But the way out:
something is wrong: 12
EDIT 2: huge tlb related information from / proc / meminfo
HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB
source share