summaryrefslogtreecommitdiffstats
path: root/src/vlib/cli.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-07-04 10:56:23 -0400
committerDamjan Marion <dmarion@me.com>2018-07-18 12:09:42 +0000
commit6a5adc369591fcac2447e9809deaa22f56b53911 (patch)
treec9a56b1ed0d5e8eb2f21a843552c6c0bc6df5597 /src/vlib/cli.c
parent2a3fb1a28b170ac1d37815983611e83d148811d4 (diff)
Add config option to use dlmalloc instead of mheap
Configure w/ --enable-dlmalloc, see .../build-data/platforms/vpp.mk src/vppinfra/dlmalloc.[ch] are slightly modified versions of the well-known Doug Lea malloc. Main advantage: dlmalloc mspaces have no inherent size limit. Change-Id: I19b3f43f3c65bcfb82c1a265a97922d01912446e Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlib/cli.c')
-rw-r--r--src/vlib/cli.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/vlib/cli.c b/src/vlib/cli.c
index 1692ad82672..820fdefd106 100644
--- a/src/vlib/cli.c
+++ b/src/vlib/cli.c
@@ -707,7 +707,7 @@ static clib_error_t *
show_memory_usage (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
- int verbose = 0, api_segment = 0;
+ int verbose __attribute__ ((unused)) = 0, api_segment = 0;
clib_error_t *error;
u32 index = 0;
@@ -742,19 +742,55 @@ show_memory_usage (vlib_main_t * vm,
vec_free (s);
}
+#if USE_DLMALLOC == 0
/* *INDENT-OFF* */
foreach_vlib_main (
({
mheap_t *h = mheap_header (clib_per_cpu_mheaps[index]);
- vlib_cli_output (vm, "%sThread %d %v\n", index ? "\n":"", index,
+ 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 (h) -
h->vm_alloc_offset_from_header,
h->vm_alloc_size);
- vlib_cli_output (vm, " %U\n", format_mheap, clib_per_cpu_mheaps[index], verbose);
+ vlib_cli_output (vm, " %U\n", format_mheap, clib_per_cpu_mheaps[index],
+ verbose);
index++;
}));
/* *INDENT-ON* */
+#else
+ {
+ uword clib_mem_trace_enable_disable (uword enable);
+ uword was_enabled;
+
+ /*
+ * Note: the foreach_vlib_main cause allocator traffic,
+ * so shut off tracing before we go there...
+ */
+ was_enabled = clib_mem_trace_enable_disable (0);
+
+ /* *INDENT-OFF* */
+ foreach_vlib_main (
+ ({
+ struct mallinfo mi;
+ void *mspace;
+ mspace = clib_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, clib_per_cpu_mheaps[index],
+ verbose);
+ index++;
+ }));
+ /* *INDENT-ON* */
+
+ /* Restore the trace flag */
+ clib_mem_trace_enable_disable (was_enabled);
+ }
+#endif /* USE_DLMALLOC */
return 0;
}
@@ -850,6 +886,7 @@ static clib_error_t *
test_heap_validate (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
+#if USE_DLMALLOC == 0
clib_error_t *error = 0;
void *heap;
mheap_t *mheap;
@@ -897,6 +934,9 @@ test_heap_validate (vlib_main_t * vm, unformat_input_t * input,
}
return error;
+#else
+ return clib_error_return (0, "unimplemented...");
+#endif /* USE_DLMALLOC */
}
/* *INDENT-OFF* */