aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-03-04 16:41:35 +0100
committerFlorin Coras <florin.coras@gmail.com>2018-03-04 17:58:02 +0000
commit7b185360843c2b1cbcbeede64340add8a56fe440 (patch)
tree1d1920fe15491747e00d9cc6536f1ca79a411645 /src
parent30787378f49714319e75437b347b7027a949700d (diff)
vppinfra: fix clib_mem_vm_ext_alloc non-shared allocations
Change-Id: I6d049c0875b91f67f008dc04ae7efe2f8ddc276e Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vppinfra/linux/mem.c10
-rw-r--r--src/vppinfra/mem.h2
2 files changed, 9 insertions, 3 deletions
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c
index c4973a6b8e0..75d2a7e0559 100644
--- a/src/vppinfra/linux/mem.c
+++ b/src/vppinfra/linux/mem.c
@@ -83,7 +83,7 @@ clib_mem_vm_ext_alloc (clib_mem_vm_alloc_t * a)
clib_error_t *err = 0;
void *addr = 0;
u8 *filename = 0;
- int mmap_flags = MAP_SHARED;
+ int mmap_flags = 0;
int log2_page_size;
int n_pages;
int old_mpol = -1;
@@ -108,9 +108,13 @@ clib_mem_vm_ext_alloc (clib_mem_vm_alloc_t * a)
}
}
+ if (a->flags & CLIB_MEM_VM_F_LOCKED)
+ mmap_flags |= MAP_LOCKED;
+
/* if we are creating shared segment, we need file descriptor */
if (a->flags & CLIB_MEM_VM_F_SHARED)
{
+ mmap_flags |= MAP_SHARED;
/* if hugepages are needed we need to create mount point */
if (a->flags & CLIB_MEM_VM_F_HUGETLB)
{
@@ -169,14 +173,14 @@ clib_mem_vm_ext_alloc (clib_mem_vm_alloc_t * a)
}
else /* not CLIB_MEM_VM_F_SHARED */
{
+ mmap_flags |= MAP_PRIVATE | MAP_ANONYMOUS;
if (a->flags & CLIB_MEM_VM_F_HUGETLB)
{
- mmap_flags |= MAP_HUGETLB | MAP_PRIVATE | MAP_ANONYMOUS;
+ mmap_flags |= MAP_HUGETLB;
log2_page_size = 21;
}
else
{
- mmap_flags |= MAP_PRIVATE | MAP_ANONYMOUS;
log2_page_size = min_log2 (sysconf (_SC_PAGESIZE));
}
}
diff --git a/src/vppinfra/mem.h b/src/vppinfra/mem.h
index 028289c50a5..55a276f466c 100644
--- a/src/vppinfra/mem.h
+++ b/src/vppinfra/mem.h
@@ -328,6 +328,7 @@ typedef struct
#define CLIB_MEM_VM_F_NUMA_PREFER (1 << 2)
#define CLIB_MEM_VM_F_NUMA_FORCE (1 << 3)
#define CLIB_MEM_VM_F_HUGETLB_PREALLOC (1 << 4)
+#define CLIB_MEM_VM_F_LOCKED (1 << 5)
u32 flags; /**< vm allocation flags:
<br> CLIB_MEM_VM_F_SHARED: request shared memory, file
descriptor will be provided on successful allocation.
@@ -337,6 +338,7 @@ typedef struct
<br> CLIB_MEM_VM_F_NUMA_FORCE: fail if setting numa policy fails.
<br> CLIB_MEM_VM_F_HUGETLB_PREALLOC: pre-allocate hugepages if
number of available pages is not sufficient.
+ <br> CLIB_MEM_VM_F_LOCKED: request locked memory.
*/
char *name; /**< Name for memory allocation, set by caller. */
uword size; /**< Allocation size, set by caller. */