summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-08-28 10:39:00 -0400
committerFlorin Coras <florin.coras@gmail.com>2020-08-28 15:31:07 +0000
commit2b79341dcafe8fa9397acf42b8021c88664db2df (patch)
tree6bfc5c5c86d5e6c42f62445d68822adab48eac00
parente6df80de415f53a7df326d06ab4a8a60a96ba039 (diff)
vppinfra: add clib_mem_destroy_mspace(void *ms)
Also clib_mem_destroy() to destroy the current mspace. Handy when an application wants to make a memory allocation arena disappear. Type: improvement Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I020db902fbe2473545506fecbc230c2b048992f8
-rw-r--r--src/vppinfra/mem.h2
-rw-r--r--src/vppinfra/mem_dlmalloc.c17
2 files changed, 19 insertions, 0 deletions
diff --git a/src/vppinfra/mem.h b/src/vppinfra/mem.h
index 06694ccadeb..c97ee8af157 100644
--- a/src/vppinfra/mem.h
+++ b/src/vppinfra/mem.h
@@ -412,6 +412,8 @@ uword clib_mem_get_default_hugepage_size (void);
int clib_mem_get_fd_log2_page_size (int fd);
uword clib_mem_vm_reserve (uword start, uword size, u32 log2_page_sz);
u64 *clib_mem_vm_get_paddr (void *mem, int log2_page_size, int n_pages);
+void clib_mem_destroy_mspace (void *mspace);
+void clib_mem_destroy (void);
typedef struct
{
diff --git a/src/vppinfra/mem_dlmalloc.c b/src/vppinfra/mem_dlmalloc.c
index 663b2f162f7..1b0dbb24500 100644
--- a/src/vppinfra/mem_dlmalloc.c
+++ b/src/vppinfra/mem_dlmalloc.c
@@ -237,6 +237,23 @@ clib_mem_init_thread_safe (void *memory, uword memory_size)
1 /* do clib_mem_set_heap */ );
}
+void
+clib_mem_destroy_mspace (void *mspace)
+{
+ mheap_trace_main_t *tm = &mheap_trace_main;
+
+ if (tm->enabled && mspace == tm->current_traced_mheap)
+ tm->enabled = 0;
+
+ destroy_mspace (mspace);
+}
+
+void
+clib_mem_destroy (void)
+{
+ clib_mem_destroy_mspace (clib_mem_get_heap ());
+}
+
void *
clib_mem_init_thread_safe_numa (void *memory, uword memory_size, u8 numa)
{