Move bin initialization from arena module to bin module.
This commit is contained in:
parent
4bf4a1c4ea
commit
a8dd8876fb
@ -78,4 +78,7 @@ struct bin_s {
|
|||||||
malloc_bin_stats_t stats;
|
malloc_bin_stats_t stats;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Returns true on error. */
|
||||||
|
bool bin_init(bin_t *bin);
|
||||||
|
|
||||||
#endif /* JEMALLOC_INTERNAL_BIN_H */
|
#endif /* JEMALLOC_INTERNAL_BIN_H */
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
#define WITNESS_RANK_ARENA_LARGE 19U
|
#define WITNESS_RANK_ARENA_LARGE 19U
|
||||||
|
|
||||||
#define WITNESS_RANK_LEAF 0xffffffffU
|
#define WITNESS_RANK_LEAF 0xffffffffU
|
||||||
#define WITNESS_RANK_ARENA_BIN WITNESS_RANK_LEAF
|
#define WITNESS_RANK_BIN WITNESS_RANK_LEAF
|
||||||
#define WITNESS_RANK_ARENA_STATS WITNESS_RANK_LEAF
|
#define WITNESS_RANK_ARENA_STATS WITNESS_RANK_LEAF
|
||||||
#define WITNESS_RANK_DSS WITNESS_RANK_LEAF
|
#define WITNESS_RANK_DSS WITNESS_RANK_LEAF
|
||||||
#define WITNESS_RANK_PROF_ACTIVE WITNESS_RANK_LEAF
|
#define WITNESS_RANK_PROF_ACTIVE WITNESS_RANK_LEAF
|
||||||
|
11
src/arena.c
11
src/arena.c
@ -2042,17 +2042,10 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
|
|||||||
|
|
||||||
/* Initialize bins. */
|
/* Initialize bins. */
|
||||||
for (i = 0; i < NBINS; i++) {
|
for (i = 0; i < NBINS; i++) {
|
||||||
bin_t *bin = &arena->bins[i];
|
bool err = bin_init(&arena->bins[i]);
|
||||||
if (malloc_mutex_init(&bin->lock, "arena_bin",
|
if (err) {
|
||||||
WITNESS_RANK_ARENA_BIN, malloc_mutex_rank_exclusive)) {
|
|
||||||
goto label_error;
|
goto label_error;
|
||||||
}
|
}
|
||||||
bin->slabcur = NULL;
|
|
||||||
extent_heap_new(&bin->slabs_nonfull);
|
|
||||||
extent_list_init(&bin->slabs_full);
|
|
||||||
if (config_stats) {
|
|
||||||
memset(&bin->stats, 0, sizeof(malloc_bin_stats_t));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
arena->base = base;
|
arena->base = base;
|
||||||
|
16
src/bin.c
16
src/bin.c
@ -2,6 +2,7 @@
|
|||||||
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
||||||
|
|
||||||
#include "jemalloc/internal/bin.h"
|
#include "jemalloc/internal/bin.h"
|
||||||
|
#include "jemalloc/internal/witness.h"
|
||||||
|
|
||||||
const bin_info_t bin_infos[NBINS] = {
|
const bin_info_t bin_infos[NBINS] = {
|
||||||
#define BIN_INFO_bin_yes(reg_size, slab_size, nregs) \
|
#define BIN_INFO_bin_yes(reg_size, slab_size, nregs) \
|
||||||
@ -18,4 +19,17 @@ const bin_info_t bin_infos[NBINS] = {
|
|||||||
#undef SC
|
#undef SC
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool
|
||||||
|
bin_init(bin_t *bin) {
|
||||||
|
if (malloc_mutex_init(&bin->lock, "arena_bin", WITNESS_RANK_BIN,
|
||||||
|
malloc_mutex_rank_exclusive)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bin->slabcur = NULL;
|
||||||
|
extent_heap_new(&bin->slabs_nonfull);
|
||||||
|
extent_list_init(&bin->slabs_full);
|
||||||
|
if (config_stats) {
|
||||||
|
memset(&bin->stats, 0, sizeof(malloc_bin_stats_t));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user