diff options
author | Benoît Ganne <bganne@cisco.com> | 2020-09-18 10:05:37 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2020-11-10 17:13:53 +0000 |
commit | ec4749a20f36af70d71dd37d86737a0d210fdc22 (patch) | |
tree | b1645d6b7c764dbae4a6b70670bdc943d194b96a /src/vppinfra/mem_dlmalloc.c | |
parent | ab0a87f32780a94f4d576bb9c5bef2715188d102 (diff) |
vpp: use vpp heap for libc
This makes libc use vpp main heap instead of the default libc heap.
This gives better visibility (accounting, tracing) on allocations
happening in external libraries called from vpp (eg. OpenSSL).
Type: feature
Change-Id: I5d8a673472145a4e090bedb443b8c58a967d1cca
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 | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/vppinfra/mem_dlmalloc.c b/src/vppinfra/mem_dlmalloc.c index df1489fd8d8..bc6561a738e 100644 --- a/src/vppinfra/mem_dlmalloc.c +++ b/src/vppinfra/mem_dlmalloc.c @@ -74,17 +74,17 @@ mheap_get_trace (uword offset, uword size) /* Spurious Coverity warnings be gone. */ clib_memset (&trace, 0, sizeof (trace)); - /* Skip our frame and mspace_get_aligned's frame */ - n_callers = clib_backtrace (trace.callers, ARRAY_LEN (trace.callers), 2); - if (n_callers == 0) - return; - clib_spinlock_lock (&tm->lock); /* Turn off tracing to avoid embarrassment... */ save_enabled = tm->enabled; tm->enabled = 0; + /* Skip our frame and mspace_get_aligned's frame */ + n_callers = clib_backtrace (trace.callers, ARRAY_LEN (trace.callers), 2); + if (n_callers == 0) + goto out; + if (!tm->trace_by_callers) tm->trace_by_callers = hash_create_shmem (0, sizeof (trace.callers), sizeof (uword)); @@ -137,6 +137,8 @@ mheap_get_trace (uword offset, uword size) t->n_bytes += size; t->offset = offset; /* keep a sample to autopsy */ hash_set (tm->trace_index_by_offset, offset, t - tm->traces); + +out: tm->enabled = save_enabled; clib_spinlock_unlock (&tm->lock); } |