aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/pmalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra/pmalloc.c')
-rw-r--r--src/vppinfra/pmalloc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/vppinfra/pmalloc.c b/src/vppinfra/pmalloc.c
index a881a65310a..46ccd7f6efc 100644
--- a/src/vppinfra/pmalloc.c
+++ b/src/vppinfra/pmalloc.c
@@ -290,7 +290,7 @@ pmalloc_map_pages (clib_pmalloc_main_t * pm, clib_pmalloc_arena_t * a,
return 0;
}
- mmap_flags = MAP_FIXED | MAP_ANONYMOUS;
+ mmap_flags = MAP_FIXED;
if ((pm->flags & CLIB_PMALLOC_F_NO_PAGEMAP) == 0)
mmap_flags |= MAP_LOCKED;
@@ -307,10 +307,12 @@ pmalloc_map_pages (clib_pmalloc_main_t * pm, clib_pmalloc_arena_t * a,
pm->error = clib_mem_create_fd ((char *) a->name, &a->fd);
if (a->fd == -1)
goto error;
+ if ((ftruncate (a->fd, size)) == -1)
+ goto error;
}
else
{
- mmap_flags |= MAP_PRIVATE;
+ mmap_flags |= MAP_PRIVATE | MAP_ANONYMOUS;
a->fd = -1;
}