Pull out edata_t caching into its own module.

This commit is contained in:
David Goldblatt
2019-12-11 11:17:19 -08:00
committed by David Goldblatt
parent a7862df616
commit 7859184179
12 changed files with 106 additions and 60 deletions

View File

@@ -5,6 +5,7 @@
#include "jemalloc/internal/atomic.h"
#include "jemalloc/internal/bin.h"
#include "jemalloc/internal/bitmap.h"
#include "jemalloc/internal/edata_cache.h"
#include "jemalloc/internal/eset.h"
#include "jemalloc/internal/extent_dss.h"
#include "jemalloc/internal/jemalloc_internal_types.h"
@@ -184,15 +185,8 @@ struct arena_s {
pszind_t retain_grow_limit;
malloc_mutex_t extent_grow_mtx;
/*
* Available edata structures that were allocated via
* base_alloc_edata().
*
* Synchronization: edata_avail_mtx.
*/
edata_tree_t edata_avail;
atomic_zu_t edata_avail_cnt;
malloc_mutex_t edata_avail_mtx;
/* The source of edata_t objects. */
edata_cache_t edata_cache;
/*
* bins is used to store heaps of free regions.

View File

@@ -0,0 +1,25 @@
#ifndef JEMALLOC_INTERNAL_EDATA_CACHE_H
#define JEMALLOC_INTERNAL_EDATA_CACHE_H
/*
* A cache of edata_t structures allocated via base_alloc_edata (as opposed to
* the underlying extents they describe). The contents of returned edata_t
* objects are garbage and cannot be relied upon.
*/
typedef struct edata_cache_s edata_cache_t;
struct edata_cache_s {
edata_tree_t avail;
atomic_zu_t count;
malloc_mutex_t mtx;
};
bool edata_cache_init(edata_cache_t *edata_cache);
edata_t *edata_cache_get(tsdn_t *tsdn, edata_cache_t *edata_cache,
base_t *base);
void edata_cache_put(tsdn_t *tsdn, edata_cache_t *edata_cache, edata_t *edata);
void edata_cache_prefork(tsdn_t *tsdn, edata_cache_t *edata_cache);
void edata_cache_postfork_parent(tsdn_t *tsdn, edata_cache_t *edata_cache);
void edata_cache_postfork_child(tsdn_t *tsdn, edata_cache_t *edata_cache);
#endif /* JEMALLOC_INTERNAL_EDATA_CACHE_H */

View File

@@ -26,9 +26,6 @@ extern size_t opt_lg_extent_max_active_fit;
extern rtree_t extents_rtree;
edata_t *extent_alloc(tsdn_t *tsdn, arena_t *arena);
void extent_dalloc(tsdn_t *tsdn, arena_t *arena, edata_t *edata);
edata_t *extents_alloc(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
eset_t *eset, void *new_addr, size_t size, size_t pad, size_t alignment,
bool slab, szind_t szind, bool *zero, bool *commit);

View File

@@ -43,7 +43,7 @@
#define WITNESS_RANK_TCACHE_QL 13U
#define WITNESS_RANK_EXTENT_GROW 14U
#define WITNESS_RANK_EXTENTS 15U
#define WITNESS_RANK_EDATA_AVAIL 16U
#define WITNESS_RANK_EDATA_CACHE 16U
#define WITNESS_RANK_EXTENT_POOL 17U
#define WITNESS_RANK_RTREE 18U