Refactor mutex profiling code with x-macros.
This commit is contained in:
@@ -4,14 +4,6 @@
|
||||
/* Maximum ctl tree depth. */
|
||||
#define CTL_MAX_DEPTH 7
|
||||
|
||||
#define NUM_GLOBAL_PROF_MUTEXES 3
|
||||
#define NUM_ARENA_PROF_MUTEXES 8
|
||||
#define NUM_MUTEX_PROF_COUNTERS 7
|
||||
|
||||
extern const char *arena_mutex_names[NUM_ARENA_PROF_MUTEXES];
|
||||
extern const char *global_mutex_names[NUM_GLOBAL_PROF_MUTEXES];
|
||||
extern const char *mutex_counter_names[NUM_MUTEX_PROF_COUNTERS];
|
||||
|
||||
int ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
|
||||
void *newp, size_t newlen);
|
||||
int ctl_nametomib(tsdn_t *tsdn, const char *name, size_t *mibp,
|
||||
|
@@ -42,9 +42,7 @@ struct ctl_stats_s {
|
||||
size_t mapped;
|
||||
size_t retained;
|
||||
|
||||
#define MTX(mutex) mutex_prof_data_t mutex##_mtx_data;
|
||||
GLOBAL_PROF_MUTEXES
|
||||
#undef MTX
|
||||
mutex_prof_data_t mutex_prof_data[num_global_prof_mutexes];
|
||||
};
|
||||
|
||||
struct ctl_arena_s {
|
||||
|
@@ -2,9 +2,49 @@
|
||||
#define JEMALLOC_INTERNAL_CTL_TYPES_H
|
||||
|
||||
#define GLOBAL_PROF_MUTEXES \
|
||||
MTX(base) \
|
||||
MTX(ctl) \
|
||||
MTX(prof)
|
||||
OP(base) \
|
||||
OP(ctl) \
|
||||
OP(prof)
|
||||
|
||||
typedef enum {
|
||||
#define OP(mtx) global_prof_mutex_##mtx,
|
||||
GLOBAL_PROF_MUTEXES
|
||||
#undef OP
|
||||
num_global_prof_mutexes
|
||||
} global_prof_mutex_ind_t;
|
||||
|
||||
#define ARENA_PROF_MUTEXES \
|
||||
OP(large) \
|
||||
OP(extent_freelist) \
|
||||
OP(extents_dirty) \
|
||||
OP(extents_muzzy) \
|
||||
OP(extents_retained) \
|
||||
OP(decay_dirty) \
|
||||
OP(decay_muzzy) \
|
||||
OP(tcache_list)
|
||||
|
||||
typedef enum {
|
||||
#define OP(mtx) arena_prof_mutex_##mtx,
|
||||
ARENA_PROF_MUTEXES
|
||||
#undef OP
|
||||
num_arena_prof_mutexes
|
||||
} arena_prof_mutex_ind_t;
|
||||
|
||||
#define MUTEX_PROF_COUNTERS \
|
||||
OP(num_ops, uint64_t) \
|
||||
OP(num_wait, uint64_t) \
|
||||
OP(num_spin_acq, uint64_t) \
|
||||
OP(num_owner_switch, uint64_t) \
|
||||
OP(total_wait_time, uint64_t) \
|
||||
OP(max_wait_time, uint64_t) \
|
||||
OP(max_num_thds, uint32_t)
|
||||
|
||||
typedef enum {
|
||||
#define OP(counter, type) mutex_counter_##counter,
|
||||
MUTEX_PROF_COUNTERS
|
||||
#undef OP
|
||||
num_mutex_prof_counters
|
||||
} mutex_prof_counter_ind_t;
|
||||
|
||||
typedef struct ctl_node_s ctl_node_t;
|
||||
typedef struct ctl_named_node_s ctl_named_node_t;
|
||||
|
@@ -124,14 +124,7 @@ struct arena_stats_s {
|
||||
/* Number of bytes cached in tcache associated with this arena. */
|
||||
atomic_zu_t tcache_bytes; /* Derived. */
|
||||
|
||||
mutex_prof_data_t large_mtx_data;
|
||||
mutex_prof_data_t extent_freelist_mtx_data;
|
||||
mutex_prof_data_t extents_dirty_mtx_data;
|
||||
mutex_prof_data_t extents_muzzy_mtx_data;
|
||||
mutex_prof_data_t extents_retained_mtx_data;
|
||||
mutex_prof_data_t decay_dirty_mtx_data;
|
||||
mutex_prof_data_t decay_muzzy_mtx_data;
|
||||
mutex_prof_data_t tcache_list_mtx_data;
|
||||
mutex_prof_data_t mutex_prof_data[num_arena_prof_mutexes];
|
||||
|
||||
/* One element for each large size class. */
|
||||
malloc_large_stats_t lstats[NSIZES - NBINS];
|
||||
|
Reference in New Issue
Block a user