diff options
author | 2024-10-08 16:43:12 +0200 | |
---|---|---|
committer | 2024-11-13 13:02:30 +0000 | |
commit | 661fb34a90a131658abd726f4faebdc566230cd8 (patch) | |
tree | 3b681985edfde1734fb891c49101df77eba9de9f /src/vppinfra/mem_dlmalloc.c | |
parent | 34083c41b2aea74a82775ce4b74f5bfa8c434106 (diff) |
vlib: add clib_stack_frame_get_raw()
clib_stack_frame_get() is getting the backtrace for all threads and
does symbol resolution which is too slow for certain features (eg.
memory traces).
clib_stack_frame_get_raw() only gets the local backtrace and defer
symbol resolution only when displaying results.
Type: improvement
Change-Id: Ia374d86e9175b6648a39ed5aaa676ceb7235e877
Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vppinfra/mem_dlmalloc.c')
-rw-r--r-- | src/vppinfra/mem_dlmalloc.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/src/vppinfra/mem_dlmalloc.c b/src/vppinfra/mem_dlmalloc.c index d5ff21e58c0..7944240390b 100644 --- a/src/vppinfra/mem_dlmalloc.c +++ b/src/vppinfra/mem_dlmalloc.c @@ -53,7 +53,7 @@ mheap_get_trace_internal (const clib_mem_heap_t *heap, uword offset, mheap_trace_t *t; uword i, trace_index, *p; mheap_trace_t trace = {}; - int index; + int n_callers; if (heap != tm->current_traced_mheap || mheap_trace_thread_disable) return; @@ -67,19 +67,10 @@ mheap_get_trace_internal (const clib_mem_heap_t *heap, uword offset, /* Turn off tracing for this thread to avoid embarrassment... */ mheap_trace_thread_disable = 1; - index = -2; /* skip first 2 stack frames */ - foreach_clib_stack_frame (sf) - { - if (index >= 0) - { - if (index == ARRAY_LEN (trace.callers)) - break; - trace.callers[index] = sf->ip; - } - index++; - } - - if (index < 1) + /* Skip our frame and mspace_get_aligned's frame */ + n_callers = + clib_stack_frame_get_raw (trace.callers, ARRAY_LEN (trace.callers), 2); + if (n_callers == 0) goto out; if (!tm->trace_by_callers) |