Merge branch 'master' into gfio
[fio.git] / memory.c
index f97749bc72c657f7b0d9f3739853dd7039797280..5293af96b226240117d312f24875f0406ceff5fd 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -5,7 +5,9 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#ifndef FIO_NO_HAVE_SHM_H
 #include <sys/shm.h>
+#endif
 #include <sys/mman.h>
 
 #include "fio.h"
@@ -119,6 +121,13 @@ static int alloc_mem_mmap(struct thread_data *td, size_t total_mem)
 
        td->mmapfd = 1;
 
+       if (td->o.mem_type == MEM_MMAPHUGE) {
+               unsigned long mask = td->o.hugepage_size - 1;
+
+               flags |= MAP_HUGETLB;
+               total_mem = (total_mem + mask) & ~mask;
+       }
+
        if (td->o.mmapfile) {
                td->mmapfd = open(td->o.mmapfile, O_RDWR|O_CREAT, 0644);