71 uword i, n_callers, trace_index, *p;
100 t = tm->
traces + trace_index;
117 if (tm->
traces != old_start)
124 q = uword_to_pointer (p->key, mheap_trace_t *);
125 ASSERT (q >= old_start && q < old_end);
126 p->key = pointer_to_uword (tm->traces + (q - old_start));
130 trace_index = t - tm->
traces;
133 t = tm->
traces + trace_index;
152 uword trace_index, *p;
177 t = tm->
traces + trace_index;
221 if (mheap_trace_main.
lock == 0)
268 int verbose = va_arg (*va,
int);
295 s =
format (s,
"%.2fG", (((
f64) a) / ((
f64) (1ULL << 30))));
296 else if (a >= 1ULL << 20)
297 s =
format (s,
"%.2fM", (((
f64) a) / ((
f64) (1ULL << 20))));
298 else if (a >= 1ULL << 10)
299 s =
format (s,
"%.2fK", (((
f64) a) / ((
f64) (1ULL << 10))));
301 s =
format (s,
"%lld", a);
322 int verbose = va_arg (*va,
int);
334 u32 indent, total_objects_traced;
338 qsort (traces_copy,
vec_len (traces_copy),
sizeof (traces_copy[0]),
341 total_objects_traced = 0;
352 if (!verbose && t->
n_bytes < 1024)
355 if (t == traces_copy)
356 s =
format (s,
"%=9s%=9s %=10s Traceback\n",
"Bytes",
"Count",
364 #if defined(CLIB_UNIX) && !defined(__APPLE__) 375 s =
format (s,
"%d total traced objects\n", total_objects_traced);
380 if (have_traces == 0)
381 s =
format (s,
"no traced allocations\n");
390 void *heap = va_arg (*va,
u8 *);
391 int verbose = va_arg (*va,
int);
397 s =
format (s,
"total: %U, used: %U, free: %U, trimmable: %U",
403 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_per_numa_mheaps[CLIB_MAX_NUMAS]
uword bytes_free_reclaimed
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.
int numa_node
numa node preference.
#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
clib_error_t * clib_mem_vm_ext_alloc(clib_mem_vm_alloc_t *a)
MALLINFO_FIELD_TYPE arena
uword size
Allocation size, set by caller.
#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 CLIB_MEM_VM_F_NUMA_FORCE
#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)
DLMALLOC_EXPORT int mspace_is_traced(mspace msp)
DLMALLOC_EXPORT mspace create_mspace(size_t capacity, int locked)
sll srl srl sll sra u16x4 i
#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)
u32 flags
vm allocation flags: CLIB_MEM_VM_F_SHARED: request shared memory, file descriptor will be provided ...
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
#define clib_error_report(e)
template key/value backing page structure
void mheap_usage(void *heap, clib_mem_usage_t *usage)
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.
static void * clib_mem_init_internal(void *memory, uword memory_size, int set_heap)
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
DLMALLOC_EXPORT size_t mspace_footprint(mspace msp)
#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
uword * trace_index_by_offset
u8 * format_clib_mem_usage(u8 *s, va_list *va)
DLMALLOC_EXPORT void * mspace_least_addr(mspace msp)
void * clib_mem_init_thread_safe_numa(void *memory, uword memory_size, u8 numa)
#define CLIB_MEM_POISON(a, s)