Introduce PAI: Page allocator interface
This commit is contained in:
committed by
David Goldblatt
parent
3cf19c6e5e
commit
1b5f632e0f
@@ -7,6 +7,7 @@
|
||||
#include "jemalloc/internal/edata_cache.h"
|
||||
#include "jemalloc/internal/emap.h"
|
||||
#include "jemalloc/internal/lockedint.h"
|
||||
#include "jemalloc/internal/pai.h"
|
||||
|
||||
enum pa_decay_purge_setting_e {
|
||||
PA_DECAY_PURGE_ALWAYS,
|
||||
@@ -110,6 +111,13 @@ struct pa_shard_s {
|
||||
*/
|
||||
atomic_zu_t nactive;
|
||||
|
||||
/*
|
||||
* An interface for page allocation from the ecache framework (i.e. a
|
||||
* cascade of ecache_dirty, ecache_muzzy, ecache_retained). Right now
|
||||
* this is the *only* pai, but we'll soon grow another.
|
||||
*/
|
||||
pai_t ecache_pai;
|
||||
|
||||
/*
|
||||
* Collections of extents that were previously allocated. These are
|
||||
* used when allocating extents, in an attempt to re-use address space.
|
||||
|
45
include/jemalloc/internal/pai.h
Normal file
45
include/jemalloc/internal/pai.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef JEMALLOC_INTERNAL_PAI_H
|
||||
#define JEMALLOC_INTERNAL_PAI_H
|
||||
|
||||
/* An interface for page allocation. */
|
||||
|
||||
typedef struct pai_s pai_t;
|
||||
struct pai_s {
|
||||
/* Returns NULL on failure. */
|
||||
edata_t *(*alloc)(tsdn_t *tsdn, pai_t *self, size_t size,
|
||||
size_t alignment, bool zero);
|
||||
bool (*expand)(tsdn_t *tsdn, pai_t *self, edata_t *edata,
|
||||
size_t old_size, size_t new_size, bool zero);
|
||||
bool (*shrink)(tsdn_t *tsdn, pai_t *self, edata_t *edata,
|
||||
size_t old_size, size_t new_size);
|
||||
void (*dalloc)(tsdn_t *tsdn, pai_t *self, edata_t *edata);
|
||||
};
|
||||
|
||||
/*
|
||||
* These are just simple convenience functions to avoid having to reference the
|
||||
* same pai_t twice on every invocation.
|
||||
*/
|
||||
|
||||
static inline edata_t *
|
||||
pai_alloc(tsdn_t *tsdn, pai_t *self, size_t size, size_t alignment, bool zero) {
|
||||
return self->alloc(tsdn, self, size, alignment, zero);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
pai_expand(tsdn_t *tsdn, pai_t *self, edata_t *edata, size_t old_size,
|
||||
size_t new_size, bool zero) {
|
||||
return self->expand(tsdn, self, edata, old_size, new_size, zero);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
pai_shrink(tsdn_t *tsdn, pai_t *self, edata_t *edata, size_t old_size,
|
||||
size_t new_size) {
|
||||
return self->shrink(tsdn, self, edata, old_size, new_size);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pai_dalloc(tsdn_t *tsdn, pai_t *self, edata_t *edata) {
|
||||
self->dalloc(tsdn, self, edata);
|
||||
}
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_PAI_H */
|
Reference in New Issue
Block a user