2019-09-21 10:59:55 +08:00
|
|
|
#ifndef JEMALLOC_INTERNAL_ESET_H
|
|
|
|
#define JEMALLOC_INTERNAL_ESET_H
|
|
|
|
|
|
|
|
#include "jemalloc/internal/atomic.h"
|
|
|
|
#include "jemalloc/internal/bitmap.h"
|
2019-12-10 02:41:25 +08:00
|
|
|
#include "jemalloc/internal/edata.h"
|
2019-09-21 10:59:55 +08:00
|
|
|
#include "jemalloc/internal/mutex.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* An eset ("extent set") is a quantized collection of extents, with built-in
|
|
|
|
* LRU queue.
|
2019-12-13 08:25:24 +08:00
|
|
|
*
|
|
|
|
* This class is not thread-safe; synchronization must be done externally if
|
|
|
|
* there are mutating operations. One exception is the stats counters, which
|
|
|
|
* may be read without any locking.
|
2019-09-21 10:59:55 +08:00
|
|
|
*/
|
|
|
|
typedef struct eset_s eset_t;
|
|
|
|
struct eset_s {
|
2019-12-13 08:25:24 +08:00
|
|
|
/* Quantized per size class heaps of extents. */
|
2019-12-10 06:36:45 +08:00
|
|
|
edata_heap_t heaps[SC_NPSIZES + 1];
|
2019-09-21 10:59:55 +08:00
|
|
|
atomic_zu_t nextents[SC_NPSIZES + 1];
|
|
|
|
atomic_zu_t nbytes[SC_NPSIZES + 1];
|
|
|
|
|
2019-12-13 08:25:24 +08:00
|
|
|
/* Bitmap for which set bits correspond to non-empty heaps. */
|
2019-09-21 10:59:55 +08:00
|
|
|
bitmap_t bitmap[BITMAP_GROUPS(SC_NPSIZES + 1)];
|
|
|
|
|
2019-12-13 08:25:24 +08:00
|
|
|
/* LRU of all extents in heaps. */
|
2020-06-12 06:15:51 +08:00
|
|
|
edata_list_inactive_t lru;
|
2019-09-21 10:59:55 +08:00
|
|
|
|
2019-12-13 08:25:24 +08:00
|
|
|
/* Page sum for all extents in heaps. */
|
2019-09-21 10:59:55 +08:00
|
|
|
atomic_zu_t npages;
|
|
|
|
|
2019-12-13 08:44:49 +08:00
|
|
|
/*
|
|
|
|
* A duplication of the data in the containing ecache. We use this only
|
|
|
|
* for assertions on the states of the passed-in extents.
|
|
|
|
*/
|
2019-09-21 10:59:55 +08:00
|
|
|
extent_state_t state;
|
|
|
|
};
|
|
|
|
|
2019-12-13 08:33:19 +08:00
|
|
|
void eset_init(eset_t *eset, extent_state_t state);
|
2019-09-21 11:37:15 +08:00
|
|
|
|
2019-09-21 11:52:13 +08:00
|
|
|
size_t eset_npages_get(eset_t *eset);
|
|
|
|
/* Get the number of extents in the given page size index. */
|
|
|
|
size_t eset_nextents_get(eset_t *eset, pszind_t ind);
|
|
|
|
/* Get the sum total bytes of the extents in the given page size index. */
|
|
|
|
size_t eset_nbytes_get(eset_t *eset, pszind_t ind);
|
|
|
|
|
2019-12-13 08:25:24 +08:00
|
|
|
void eset_insert(eset_t *eset, edata_t *edata);
|
|
|
|
void eset_remove(eset_t *eset, edata_t *edata);
|
2019-09-22 00:36:22 +08:00
|
|
|
/*
|
|
|
|
* Select an extent from this eset of the given size and alignment. Returns
|
|
|
|
* null if no such item could be found.
|
|
|
|
*/
|
2020-03-15 01:05:12 +08:00
|
|
|
edata_t *eset_fit(eset_t *eset, size_t esize, size_t alignment, bool exact_only,
|
2020-03-15 00:46:09 +08:00
|
|
|
unsigned lg_max_fit);
|
2019-09-22 01:23:12 +08:00
|
|
|
|
2019-09-21 10:59:55 +08:00
|
|
|
#endif /* JEMALLOC_INTERNAL_ESET_H */
|