title: mmap failed when trying to map huge page (1GB)
body: <p>What I did: 1. Enable huge page with root (my system supports 1MB huge page)</p>
  
  <pre><code>$echo 20 &gt; /proc/sys/vm/nr_hugepages
  </code></pre>
  
  <p>2.Mount huge page filesystem to /mnt/hugepages</p>
  
  <pre><code>$mount -t hugetlbfs nodev /mnt/hugepages
  </code></pre>
  
  <p>3.Create a file in huge page filesystem</p>
  
  <pre><code>$touch /mnt/hugepages/hello
  </code></pre>
  
  <p>4.Then map a huge page using mmap to address 0 as shown in the code below</p>
  
  <pre><code>   #define FILE_NAME "/mnt/hugepages/hello"
     #define PROTECTION (PROT_READ | PROT_WRITE) // page flag
     #define LENGTH (1024*1024*1024)     // huge page size
     #define FLAGS (MAP_SHARED)      //page flag
     #define ADDR (void *) (0x0UL)   //starting address of the page
  
     fd = open(FILE_NAME, O_CREAT | O_RDWR, 0755);    
     if (fd &lt; 0) {                    // 
           perror("Open failed");
           exit(1);
      }
  
     // allocate a buffer using huge pages
     buf = mmap(ADDR, LENGTH, PROTECTION, FLAGS, fd, 0);
     if (buf == MAP_FAILED) {
             perror("mmap");
             unlink(FILE_NAME);
             exit(1);
      }
  </code></pre>
  
  <p>The program outputs:
  mmap: Cannot allocate memory</p>