72 uword i, n_callers, trace_index, *p;
101 t = tm->
traces + trace_index;
118 if (tm->
traces != old_start)
125 q = uword_to_pointer (p->key, mheap_trace_t *);
126 ASSERT (q >= old_start && q < old_end);
127 p->key = pointer_to_uword (tm->traces + (q - old_start));
131 trace_index = t - tm->
traces;
134 t = tm->
traces + trace_index;
153 uword trace_index, *p;
178 t = tm->
traces + trace_index;
219 if (mheap_trace_main.
lock == 0)
234 int verbose = va_arg (*va,
int);
261 s =
format (s,
"%.2fG", (((
f64) a) / ((
f64) (1ULL << 30))));
262 else if (a >= 1ULL << 20)
263 s =
format (s,
"%.2fM", (((
f64) a) / ((
f64) (1ULL << 20))));
264 else if (a >= 1ULL << 10)
265 s =
format (s,
"%.2fK", (((
f64) a) / ((
f64) (1ULL << 10))));
267 s =
format (s,
"%lld", a);
288 int verbose = va_arg (*va,
int);
300 u32 indent, total_objects_traced;
304 qsort (traces_copy,
vec_len (traces_copy),
sizeof (traces_copy[0]),
307 total_objects_traced = 0;
318 if (!verbose && t->
n_bytes < 1024)
321 if (t == traces_copy)
322 s =
format (s,
"%=9s%=9s %=10s Traceback\n",
"Bytes",
"Count",
330 #if defined(CLIB_UNIX) && !defined(__APPLE__) 341 s =
format (s,
"%d total traced objects\n", total_objects_traced);
346 if (have_traces == 0)
347 s =
format (s,
"no traced allocations\n");
356 void *heap = va_arg (*va,
u8 *);
357 int verbose = va_arg (*va,
int);
363 s =
format (s,
"total: %U, used: %U, free: %U, trimmable: %U",
369 s =
format (s,
"\n free chunks %llu free fastbin blks %llu",
void * clib_per_cpu_mheaps[CLIB_MAX_MHEAPS]
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
#define hash_set(h, key, value)
vhost_user_memory_t memory
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
#define hash_unset(h, key)
void * current_traced_mheap
void * clib_mem_init(void *memory, uword memory_size)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
uword clib_backtrace(uword *callers, uword max_callers, uword n_frames_to_skip)
u8 * format_msize(u8 *s, va_list *va)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
void mheap_trace(void *v, int enable)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define hash_set_mem(h, key, value)
DLMALLOC_EXPORT struct dlmallinfo mspace_mallinfo(mspace msp)
DLMALLOC_EXPORT mspace create_mspace_with_base(void *base, size_t capacity, int locked)
MALLINFO_FIELD_TYPE uordblks
MALLINFO_FIELD_TYPE arena
#define vec_end(v)
End (last data address) of vector.
MALLINFO_FIELD_TYPE ordblks
static void clib_spinlock_init(clib_spinlock_t *p)
u8 * format_mheap(u8 *s, va_list *va)
#define hash_unset_mem(h, key)
mheap_trace_main_t mheap_trace_main
MALLINFO_FIELD_TYPE usmblks
void clib_mem_usage(clib_mem_usage_t *u)
DLMALLOC_EXPORT void mspace_disable_expand(mspace msp)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
void clib_mem_validate(void)
static int mheap_trace_sort(const void *_t1, const void *_t2)
uword * trace_index_by_offset
DLMALLOC_EXPORT int mspace_is_traced(mspace msp)
DLMALLOC_EXPORT mspace create_mspace(size_t capacity, int locked)
#define vec_free(V)
Free vector's memory (no header).
static void * clib_mem_set_heap(void *heap)
MALLINFO_FIELD_TYPE keepcost
#define clib_warning(format, args...)
DLMALLOC_EXPORT int mspace_enable_disable_trace(mspace msp, int enable)
u8 * format_mheap_trace(u8 *s, va_list *va)
static void * clib_mem_get_heap(void)
static void mheap_trace_main_free(mheap_trace_main_t *tm)
int clib_mem_is_traced(void)
MALLINFO_FIELD_TYPE smblks
#define hash_create_shmem(elts, key_bytes, value_bytes)
uword clib_mem_trace_enable_disable(uword enable)
void mheap_get_trace(uword offset, uword size)
void * mheap_alloc_with_lock(void *memory, uword size, int locked)
uword clib_mem_validate_serial
template key/value backing page structure
void qsort(void *base, uword n, uword size, int(*compar)(const void *, const void *))
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
void mheap_put_trace(uword offset, uword size)
format_function_t format_clib_elf_symbol_with_address
#define hash_get_mem(h, key)
struct clib_bihash_value offset
template key/value backing page structure
#define vec_foreach(var, vec)
Vector iterator.
void clib_mem_trace(int enable)
void * clib_mem_init_thread_safe(void *memory, uword memory_size)
MALLINFO_FIELD_TYPE fordblks
u8 * format_clib_mem_usage(u8 *s, va_list *va)