summaryrefslogtreecommitdiffstats
path: root/src/vlib
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/vlib
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/vlib')
-rw-r--r--src/vlib/cli.c31
-rw-r--r--src/vlib/threads.c12
2 files changed, 20 insertions, 23 deletions
diff --git a/src/vlib/cli.c b/src/vlib/cli.c
index 6841a5b2996..c485f967bcd 100644
--- a/src/vlib/cli.c
+++ b/src/vlib/cli.c
@@ -507,7 +507,7 @@ vlib_cli_dispatch_sub_commands (vlib_main_t * vm,
}
(void) clib_mem_trace_enable_disable (0);
- leak_report = format (0, "%U", format_mheap, clib_mem_get_heap (),
+ leak_report = format (0, "%U", format_clib_mem_heap, 0,
1 /* verbose, i.e. print leaks */ );
clib_mem_trace (0);
vlib_cli_output (vm, "%v", leak_report);
@@ -781,8 +781,7 @@ show_memory_usage (vlib_main_t * vm,
{
void *oldheap = vl_msg_push_heap ();
was_enabled = clib_mem_trace_enable_disable (0);
- u8 *s_in_svm =
- format (0, "%U\n", format_mheap, clib_mem_get_heap (), 1);
+ u8 *s_in_svm = format (0, "%U\n", format_clib_mem_heap, 0, 1);
vl_msg_pop_heap (oldheap);
u8 *s = vec_dup (s_in_svm);
@@ -798,8 +797,7 @@ show_memory_usage (vlib_main_t * vm,
{
void *oldheap = vlib_stats_push_heap (0);
was_enabled = clib_mem_trace_enable_disable (0);
- u8 *s_in_svm =
- format (0, "%U\n", format_mheap, clib_mem_get_heap (), 1);
+ u8 *s_in_svm = format (0, "%U\n", format_clib_mem_heap, 0, 1);
if (oldheap)
clib_mem_set_heap (oldheap);
u8 *s = vec_dup (s_in_svm);
@@ -829,17 +827,14 @@ show_memory_usage (vlib_main_t * vm,
/* *INDENT-OFF* */
foreach_vlib_main (
({
- struct dlmallinfo mi;
- void *mspace;
- mspace = mm->per_cpu_mheaps[index];
+ void *heap = mm->per_cpu_mheaps[index];
- mi = mspace_mallinfo (mspace);
vlib_cli_output (vm, "%sThread %d %s\n", index ? "\n":"", index,
vlib_worker_threads[index].name);
vlib_cli_output (vm, " %U\n", format_page_map,
- pointer_to_uword (mspace_least_addr(mspace)),
- mi.arena);
- vlib_cli_output (vm, " %U\n", format_mheap,
+ pointer_to_uword (clib_mem_get_heap_base(heap)),
+ clib_mem_get_heap_size (heap));
+ vlib_cli_output (vm, " %U\n", format_clib_mem_heap,
mm->per_cpu_mheaps[index],
verbose);
index++;
@@ -851,8 +846,7 @@ show_memory_usage (vlib_main_t * vm,
}
if (numa_heaps)
{
- struct dlmallinfo mi;
- void *mspace;
+ void *heap;
for (i = 0; i < ARRAY_LEN (mm->per_numa_mheaps); i++)
{
@@ -864,14 +858,13 @@ show_memory_usage (vlib_main_t * vm,
continue;
}
was_enabled = clib_mem_trace_enable_disable (0);
- mspace = mm->per_numa_mheaps[i];
+ heap = mm->per_numa_mheaps[i];
- mi = mspace_mallinfo (mspace);
vlib_cli_output (vm, "Numa %d:", i);
vlib_cli_output (vm, " %U\n", format_page_map,
- pointer_to_uword (mspace_least_addr (mspace)),
- mi.arena);
- vlib_cli_output (vm, " %U\n", format_mheap,
+ pointer_to_uword (clib_mem_get_heap_base (heap)),
+ clib_mem_get_heap_size (heap));
+ vlib_cli_output (vm, " %U\n", format_clib_mem_heap,
mm->per_numa_mheaps[index], verbose);
}
}
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index c2ac4a1b389..0fc306db6f2 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -757,8 +757,10 @@ start_workers (vlib_main_t * vm)
vec_add2 (vlib_worker_threads, w, 1);
/* Currently unused, may not really work */
if (tr->mheap_size)
- w->thread_mheap = create_mspace (tr->mheap_size,
- 0 /* unlocked */ );
+ w->thread_mheap = clib_mem_create_heap (0, tr->mheap_size,
+ /* unlocked */ 0,
+ "%s%d heap",
+ tr->name, k);
else
w->thread_mheap = main_heap;
@@ -927,8 +929,10 @@ start_workers (vlib_main_t * vm)
vec_add2 (vlib_worker_threads, w, 1);
if (tr->mheap_size)
{
- w->thread_mheap =
- create_mspace (tr->mheap_size, 0 /* locked */ );
+ w->thread_mheap = clib_mem_create_heap (0, tr->mheap_size,
+ /* locked */ 0,
+ "%s%d heap",
+ tr->name, j);
}
else
w->thread_mheap = main_heap;