// SPDX-License-Identifier: GPL-3.0-or-later
#define NETDATA_RRD_INTERNALS
#include "rrdengine.h"
ARAL page_descr_aral = {
.element_size = sizeof(struct rrdeng_page_descr),
.elements = 20000,
.filename = "page_descriptors",
.cache_dir = &netdata_configured_cache_dir,
.use_mmap = false,
.internal.initialized = false
};
void rrdeng_page_descr_aral_go_singlethreaded(void) {
page_descr_aral.internal.lockless = true;
}
void rrdeng_page_descr_aral_go_multithreaded(void) {
page_descr_aral.internal.lockless = false;
}
struct rrdeng_page_descr *rrdeng_page_descr_mallocz(void) {
struct rrdeng_page_descr *descr;
descr = arrayalloc_mallocz(&page_descr_aral);
return descr;
}
void rrdeng_page_descr_freez(struct rrdeng_page_descr *descr) {
arrayalloc_freez(&page_descr_aral, descr);
}
void rrdeng_page_descr_use_malloc(void) {
if(page_descr_aral.internal.initialized)
error("DBENGINE: cannot change ARAL allocation policy after it has been initialized.");
else
page_descr_aral.use_mmap = false;
}
void rrdeng_page_descr_use_mmap(void) {
if(page_descr_aral.internal.initialized)
error("DBENGINE: cannot change ARAL allocation policy after it has been initialized.");
else
page_descr_aral.use_mmap = true;
}
bool rrdeng_page_descr_is_mmap(void) {
return page_descr_aral.use_mmap;
}
/* Forward declarations */
static int pg_cache_try_evict_one_page_unsafe(struct rrdengine_instance *ctx);
/* always inserts into tail */
static inline void pg_cache_replaceQ_insert_unsafe(struct rrdengine_instance *ctx,
struct rrdeng_page_descr *descr)
{
struct page_cache *pg_cache = &ctx->pg_cache;