aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-11-07 17:55:26 +0100
committerDamjan Marion <damarion@cisco.com>2018-11-07 17:55:28 +0100
commit54e8e39a5284917efab8fd6d7d92e589d4a911a4 (patch)
tree86d572f92e8646edb3803a5f0f9398b2cf179fb4
parent232b2d55807cfdb89bbad6fc985bd2d94bb2f22a (diff)
pmalloc: fix shared mappings
Change-Id: I6782544d5ee0a66b1a027874b23574416093ca92 Signed-off-by: Damjan Marion <damarion@cisco.com>
-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;
}