aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-09-28 19:03:37 +0200
committerDamjan Marion <damarion@cisco.com>2020-09-28 20:34:07 +0200
commit4537c30925050ffa34c33e6a481f07f1ec0a01ff (patch)
tree0516dba983516dd12027cd59d18e514dcebe24de /src/svm
parenta8af7cf253c4e8ab9ba1a2cfed50f6236fea3a62 (diff)
vppinfra: don't call dlmalloc API directly from the code
- it is confusing from end consumer perspective that some thing is somewhere called heap and somewhere mspace - this is base for additional work where heap pointer is not the same thing like mspace Type: improvement Change-Id: I644d5a0de17690d65d164d8cec3c5654571629ef Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/svm')
-rw-r--r--src/svm/fifo_segment.c5
-rw-r--r--src/svm/persist.c1
-rw-r--r--src/svm/ssvm.c27
-rw-r--r--src/svm/ssvm.h1
-rw-r--r--src/svm/svm.c13
-rw-r--r--src/svm/svm_test.c1
-rw-r--r--src/svm/svmdb.c1
-rw-r--r--src/svm/svmdbtool.c1
-rw-r--r--src/svm/svmtool.c1
9 files changed, 16 insertions, 35 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c
index 3fd7d9d6ede..5fb2758606e 100644
--- a/src/svm/fifo_segment.c
+++ b/src/svm/fifo_segment.c
@@ -40,10 +40,7 @@ static char *fifo_segment_mem_status_strings[] = {
static uword
fsh_free_space (fifo_segment_header_t * fsh)
{
- struct dlmallinfo dlminfo;
-
- dlminfo = mspace_mallinfo (fsh->ssvm_sh->heap);
- return dlminfo.fordblks;
+ return clib_mem_get_heap_free_space (fsh->ssvm_sh->heap);
}
static inline void
diff --git a/src/svm/persist.c b/src/svm/persist.c
index 023c596b9cf..d0cf172aea4 100644
--- a/src/svm/persist.c
+++ b/src/svm/persist.c
@@ -35,7 +35,6 @@
#include <vppinfra/bitmap.h>
#include <vppinfra/fifo.h>
#include <vppinfra/time.h>
-#include <vppinfra/mheap.h>
#include <vppinfra/heap.h>
#include <vppinfra/pool.h>
#include <vppinfra/format.h>
diff --git a/src/svm/ssvm.c b/src/svm/ssvm.c
index 073bc0b5403..d8831ec1c48 100644
--- a/src/svm/ssvm.c
+++ b/src/svm/ssvm.c
@@ -102,10 +102,9 @@ ssvm_master_init_shm (ssvm_private_t * ssvm)
sh->ssvm_size = ssvm->ssvm_size;
sh->ssvm_va = pointer_to_uword (sh);
sh->type = SSVM_SEGMENT_SHM;
- sh->heap = create_mspace_with_base (((u8 *) sh) + page_size,
- ssvm->ssvm_size - page_size,
- 1 /* locked */ );
- mspace_disable_expand (sh->heap);
+ sh->heap = clib_mem_create_heap (((u8 *) sh) + page_size,
+ ssvm->ssvm_size - page_size,
+ 1 /* locked */ , "ssvm master shm");
oldheap = ssvm_push_heap (sh);
sh->name = format (0, "%s", ssvm->name, 0);
@@ -254,10 +253,9 @@ ssvm_master_init_memfd (ssvm_private_t * memfd)
sh->ssvm_va = pointer_to_uword (sh);
sh->type = SSVM_SEGMENT_MEMFD;
- sh->heap = create_mspace_with_base (((u8 *) sh) + page_size,
- memfd->ssvm_size - page_size,
- 1 /* locked */ );
- mspace_disable_expand (sh->heap);
+ sh->heap = clib_mem_create_heap (((u8 *) sh) + page_size,
+ memfd->ssvm_size - page_size,
+ 1 /* locked */ , "ssvm master memfd");
oldheap = ssvm_push_heap (sh);
sh->name = format (0, "%s", memfd->name, 0);
ssvm_pop_heap (oldheap);
@@ -341,7 +339,6 @@ ssvm_master_init_private (ssvm_private_t * ssvm)
{
uword pagesize = clib_mem_get_page_size (), rnd_size = 0;
clib_mem_vm_alloc_t alloc = { 0 };
- struct dlmallinfo dlminfo;
ssvm_shared_header_t *sh;
clib_error_t *err;
u8 *heap;
@@ -363,19 +360,15 @@ ssvm_master_init_private (ssvm_private_t * ssvm)
return SSVM_API_ERROR_CREATE_FAILURE;
}
- heap = create_mspace_with_base ((u8 *) alloc.addr + pagesize, rnd_size,
- 1 /* locked */ );
+ heap = clib_mem_create_heap ((u8 *) alloc.addr + pagesize, rnd_size,
+ 1 /* locked */ , "ssvm master private");
if (heap == 0)
{
clib_unix_warning ("mheap alloc");
return -1;
}
- mspace_disable_expand (heap);
-
- /* Find actual size because mspace size is rounded up by dlmalloc */
- dlminfo = mspace_mallinfo (heap);
- rnd_size = dlminfo.fordblks;
+ rnd_size = clib_mem_get_heap_free_space (heap);
ssvm->ssvm_size = rnd_size;
ssvm->i_am_master = 1;
@@ -407,7 +400,7 @@ void
ssvm_delete_private (ssvm_private_t * ssvm)
{
vec_free (ssvm->name);
- destroy_mspace (ssvm->sh->heap);
+ clib_mem_destroy_heap (ssvm->sh->heap);
clib_mem_vm_free (ssvm->sh, ssvm->ssvm_size + clib_mem_get_page_size ());
}
diff --git a/src/svm/ssvm.h b/src/svm/ssvm.h
index 6225a63cae4..2a9da3d2f32 100644
--- a/src/svm/ssvm.h
+++ b/src/svm/ssvm.h
@@ -33,7 +33,6 @@
#include <vppinfra/bitmap.h>
#include <vppinfra/fifo.h>
#include <vppinfra/time.h>
-#include <vppinfra/mheap.h>
#include <vppinfra/heap.h>
#include <vppinfra/pool.h>
#include <vppinfra/format.h>
diff --git a/src/svm/svm.c b/src/svm/svm.c
index fc917825be6..c08765541ed 100644
--- a/src/svm/svm.c
+++ b/src/svm/svm.c
@@ -36,7 +36,6 @@
#include <vppinfra/bitmap.h>
#include <vppinfra/fifo.h>
#include <vppinfra/time.h>
-#include <vppinfra/mheap.h>
#include <vppinfra/heap.h>
#include <vppinfra/pool.h>
#include <vppinfra/format.h>
@@ -336,9 +335,8 @@ svm_data_region_create (svm_map_region_args_t * a, svm_region_t * rp)
if (a->flags & SVM_FLAGS_MHEAP)
{
- rp->data_heap = create_mspace_with_base (rp->data_base,
- map_size, 1 /* locked */ );
- mspace_disable_expand (rp->data_heap);
+ rp->data_heap = clib_mem_create_heap (rp->data_base, map_size,
+ 1 /* locked */ , "svm data");
rp->flags |= SVM_FLAGS_MHEAP;
}
@@ -487,12 +485,11 @@ svm_region_init_mapped_region (svm_map_region_args_t * a, svm_region_t * rp)
rp->virtual_base = a->baseva;
rp->virtual_size = a->size;
- rp->region_heap = create_mspace_with_base
+ rp->region_heap = clib_mem_create_heap
(uword_to_pointer (a->baseva + MMAP_PAGESIZE, void *),
(a->pvt_heap_size !=
- 0) ? a->pvt_heap_size : SVM_PVT_MHEAP_SIZE, 1 /* locked */ );
-
- mspace_disable_expand (rp->region_heap);
+ 0) ? a->pvt_heap_size : SVM_PVT_MHEAP_SIZE, 1 /* locked */ ,
+ "svm region");
oldheap = svm_push_pvt_heap (rp);
diff --git a/src/svm/svm_test.c b/src/svm/svm_test.c
index ab0b9e248e6..c55d631d3db 100644
--- a/src/svm/svm_test.c
+++ b/src/svm/svm_test.c
@@ -36,7 +36,6 @@
#include <vppinfra/bitmap.h>
#include <vppinfra/fifo.h>
#include <vppinfra/time.h>
-#include <vppinfra/mheap.h>
#include <vppinfra/heap.h>
#include <vppinfra/pool.h>
diff --git a/src/svm/svmdb.c b/src/svm/svmdb.c
index 15922ad68f4..2c3d351f0c7 100644
--- a/src/svm/svmdb.c
+++ b/src/svm/svmdb.c
@@ -35,7 +35,6 @@
#include <vppinfra/bitmap.h>
#include <vppinfra/fifo.h>
#include <vppinfra/time.h>
-#include <vppinfra/mheap.h>
#include <vppinfra/heap.h>
#include <vppinfra/pool.h>
#include <vppinfra/format.h>
diff --git a/src/svm/svmdbtool.c b/src/svm/svmdbtool.c
index ca8201bd22b..feb7eed07ef 100644
--- a/src/svm/svmdbtool.c
+++ b/src/svm/svmdbtool.c
@@ -33,7 +33,6 @@
#include <vppinfra/bitmap.h>
#include <vppinfra/fifo.h>
#include <vppinfra/time.h>
-#include <vppinfra/mheap.h>
#include <vppinfra/heap.h>
#include <vppinfra/pool.h>
#include <vppinfra/format.h>
diff --git a/src/svm/svmtool.c b/src/svm/svmtool.c
index 643b484bdf5..0f38d7fe0eb 100644
--- a/src/svm/svmtool.c
+++ b/src/svm/svmtool.c
@@ -35,7 +35,6 @@
#include <vppinfra/bitmap.h>
#include <vppinfra/fifo.h>
#include <vppinfra/time.h>
-#include <vppinfra/mheap.h>
#include <vppinfra/heap.h>
#include <vppinfra/pool.h>
#include <vppinfra/format.h>