server-skynet-source-3rd-je.../include/jemalloc/internal/pa.h

99 lines
2.9 KiB
C
Raw Normal View History

#ifndef JEMALLOC_INTERNAL_PA_H
#define JEMALLOC_INTERNAL_PA_H
#include "jemalloc/internal/decay.h"
2020-03-09 04:08:15 +08:00
#include "jemalloc/internal/ecache.h"
#include "jemalloc/internal/edata_cache.h"
2020-03-10 01:40:37 +08:00
#include "jemalloc/internal/lockedint.h"
2020-03-09 04:08:15 +08:00
/*
* The page allocator; responsible for acquiring pages of memory for
* allocations.
*/
typedef struct pa_shard_decay_stats_s pa_shard_decay_stats_t;
struct pa_shard_decay_stats_s {
/* Total number of purge sweeps. */
locked_u64_t npurge;
/* Total number of madvise calls made. */
locked_u64_t nmadvise;
/* Total number of pages purged. */
locked_u64_t purged;
};
2020-03-10 02:26:15 +08:00
/*
* The stats for a particular pa_shard. Because of the way the ctl module
* handles stats epoch data collection (it has its own arena_stats, and merges
* the stats from each arena into it), this needs to live in the arena_stats_t;
* hence we define it here and let the pa_shard have a pointer (rather than the
* more natural approach of just embedding it in the pa_shard itself).
*
* We follow the arena_stats_t approach of marking the derived fields. These
* are the ones that are not maintained on their own; instead, their values are
* derived during those stats merges.
*/
2020-03-09 04:08:15 +08:00
typedef struct pa_shard_stats_s pa_shard_stats_t;
struct pa_shard_stats_s {
2020-03-10 01:40:37 +08:00
pa_shard_decay_stats_t decay_dirty;
pa_shard_decay_stats_t decay_muzzy;
2020-03-10 03:06:19 +08:00
/*
* Number of bytes currently mapped, excluding retained memory.
*
* Partially derived -- we maintain our own counter, but add in the
* base's own counter at merge.
*/
locked_zu_t mapped;
2020-03-09 04:08:15 +08:00
/* VM space had to be leaked (undocumented). Normally 0. */
atomic_zu_t abandoned_vm;
};
2020-03-09 01:35:56 +08:00
typedef struct pa_shard_s pa_shard_t;
struct pa_shard_s {
/*
* Collections of extents that were previously allocated. These are
* used when allocating extents, in an attempt to re-use address space.
*
* Synchronization: internal.
*/
ecache_t ecache_dirty;
ecache_t ecache_muzzy;
ecache_t ecache_retained;
2020-03-09 02:41:19 +08:00
/* The source of edata_t objects. */
edata_cache_t edata_cache;
2020-03-09 04:08:15 +08:00
2020-03-09 04:47:02 +08:00
/* The grow info for the retained ecache. */
ecache_grow_t ecache_grow;
/* Extent serial number generator state. */
atomic_zu_t extent_sn_next;
2020-03-10 03:06:19 +08:00
malloc_mutex_t *stats_mtx;
2020-03-09 04:08:15 +08:00
pa_shard_stats_t *stats;
/*
* Decay-based purging state, responsible for scheduling extent state
* transitions.
*
* Synchronization: internal.
*/
decay_t decay_dirty; /* dirty --> muzzy */
decay_t decay_muzzy; /* muzzy --> retained */
2020-03-09 01:35:56 +08:00
};
2020-03-10 03:06:19 +08:00
static inline void
pa_shard_stats_mapped_add(tsdn_t *tsdn, pa_shard_t *shard, size_t size) {
LOCKEDINT_MTX_LOCK(tsdn, *shard->stats_mtx);
locked_inc_zu(tsdn, LOCKEDINT_MTX(*shard->stats_mtx),
&shard->stats->mapped, size);
LOCKEDINT_MTX_UNLOCK(tsdn, *shard->stats_mtx);
}
2020-03-09 02:19:41 +08:00
/* Returns true on error. */
2020-03-09 04:08:15 +08:00
bool pa_shard_init(tsdn_t *tsdn, pa_shard_t *shard, base_t *base, unsigned ind,
2020-03-10 03:06:19 +08:00
pa_shard_stats_t *stats, malloc_mutex_t *stats_mtx);
size_t pa_shard_extent_sn_next(pa_shard_t *shard);
2020-03-09 02:19:41 +08:00
#endif /* JEMALLOC_INTERNAL_PA_H */