68 uword i, n_callers, trace_index, *p;
76 memset (&trace, 0,
sizeof (trace));
102 t = tm->
traces + trace_index;
119 if (tm->
traces != old_start)
126 q = uword_to_pointer (p->key, mheap_trace_t *);
127 ASSERT (q >= old_start && q < old_end);
128 p->key = pointer_to_uword (tm->traces + (q - old_start));
132 trace_index = t - tm->
traces;
135 t = tm->
traces + trace_index;
154 uword trace_index, *p;
179 t = tm->
traces + trace_index;
188 memset (t, 0,
sizeof (t[0]));
220 if (mheap_trace_main.
lock == 0)
232 #ifdef CLIB_LINUX_KERNEL 233 #include <asm/page.h> 246 return getpagesize ();
251 #ifdef CLIB_STANDALONE 262 int verbose = va_arg (*va,
int);
289 s =
format (s,
"%.2fG", (((
f64) a) / ((
f64) (1ULL << 30))));
290 else if (a >= 1ULL << 20)
291 s =
format (s,
"%.2fM", (((
f64) a) / ((
f64) (1ULL << 20))));
292 else if (a >= 1ULL << 10)
293 s =
format (s,
"%.2fK", (((
f64) a) / ((
f64) (1ULL << 10))));
295 s =
format (s,
"%lld", a);
316 int verbose = va_arg (*va,
int);
327 u32 indent, total_objects_traced;
331 qsort (traces_copy,
vec_len (traces_copy),
sizeof (traces_copy[0]),
334 total_objects_traced = 0;
345 if (!verbose && t->
n_bytes < 1024)
348 if (t == traces_copy)
349 s =
format (s,
"%=9s%=9s %=10s Traceback\n",
"Bytes",
"Count",
357 #if defined(CLIB_UNIX) && !defined(__APPLE__) 368 s =
format (s,
"%d total traced objects\n", total_objects_traced);
373 if (have_traces == 0)
374 s =
format (s,
"no traced allocations\n");
383 void *heap = va_arg (*va,
u8 *);
384 int verbose = va_arg (*va,
int);
390 s =
format (s,
"total: %U, used: %U, free: %U, trimmable: %U",
396 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 * clib_mem_init(void *memory, uword memory_size)
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
memset(h->entries, 0, sizeof(h->entries[0])*entries)
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 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)
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
uword clib_mem_get_page_size(void)
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)