summaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2013-01-24 09:08:45 -0700
committerJens Axboe <axboe@kernel.dk>2013-01-24 09:08:45 -0700
commit836fcc0fceb233ebcc41ee63b4ea5cae20b678a4 (patch)
treeba33bc3088166274d603105a9e957fda8fa7c013 /memory.c
parent4aaefbfa2b7a7a70ff6c6851dc3cee01b5993149 (diff)
parent798827c895a585f284842f6b99378be19c821263 (diff)
Merge branch 'master' into gfio
Conflicts: Makefile backend.c client.c fio.c fio.h ioengine.h options.c os/os-linux.h server.c Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/memory.c b/memory.c
index 5293af9..e969221 100644
--- a/memory.c
+++ b/memory.c
@@ -117,14 +117,16 @@ static void free_mem_shm(struct thread_data *td)
static int alloc_mem_mmap(struct thread_data *td, size_t total_mem)
{
- int flags = MAP_PRIVATE;
+ int flags = 0;
td->mmapfd = 1;
if (td->o.mem_type == MEM_MMAPHUGE) {
unsigned long mask = td->o.hugepage_size - 1;
- flags |= MAP_HUGETLB;
+ /* TODO: make sure the file is a real hugetlbfs file */
+ if (!td->o.mmapfile)
+ flags |= MAP_HUGETLB;
total_mem = (total_mem + mask) & ~mask;
}
@@ -136,13 +138,18 @@ static int alloc_mem_mmap(struct thread_data *td, size_t total_mem)
td->orig_buffer = NULL;
return 1;
}
- if (ftruncate(td->mmapfd, total_mem) < 0) {
+ if (td->o.mem_type != MEM_MMAPHUGE &&
+ ftruncate(td->mmapfd, total_mem) < 0) {
td_verror(td, errno, "truncate mmap file");
td->orig_buffer = NULL;
return 1;
}
+ if (td->o.mem_type == MEM_MMAPHUGE)
+ flags |= MAP_SHARED;
+ else
+ flags |= MAP_PRIVATE;
} else
- flags |= OS_MAP_ANON;
+ flags |= OS_MAP_ANON | MAP_PRIVATE;
td->orig_buffer = mmap(NULL, total_mem, PROT_READ | PROT_WRITE, flags,
td->mmapfd, 0);