Refactor deferral constants into corresponding headers.

Currently there are deferral-relevant constants in arena.c and
background_thread.c. This commit moves them out into corresponding PAC
and HPA headers. Those commonly needed by both are put into a new header
deferral.h where the contract of deferral are clearly stated.
This commit is contained in:
guangli-dai
2026-06-28 15:00:03 -07:00
committed by Guangli Dai
parent 7f52ac7af3
commit e16ebfe27e
11 changed files with 65 additions and 31 deletions

View File

@@ -6,6 +6,7 @@
#include "jemalloc/internal/background_thread.h"
#include "jemalloc/internal/background_thread_inlines.h"
#include "jemalloc/internal/ctl.h"
#include "jemalloc/internal/deferral.h"
#include "jemalloc/internal/jemalloc_internal_inlines_a.h"
#include "jemalloc/internal/malloc_io.h"
#include "jemalloc/internal/mutex.h"
@@ -298,7 +299,7 @@ background_thread_pause_check(tsdn_t *tsdn, background_thread_info_t *info) {
static inline void
background_work_sleep_once(
tsdn_t *tsdn, background_thread_info_t *info, unsigned ind) {
uint64_t ns_until_deferred = BACKGROUND_THREAD_DEFERRED_MAX;
uint64_t ns_until_deferred = DEFERRED_WORK_MAX;
unsigned narenas = narenas_total_get();
bool slept_indefinitely = background_thread_indefinite_sleep(info);
@@ -327,7 +328,7 @@ background_work_sleep_once(
}
uint64_t sleep_ns;
if (ns_until_deferred == BACKGROUND_THREAD_DEFERRED_MAX) {
if (ns_until_deferred == DEFERRED_WORK_MAX) {
sleep_ns = BACKGROUND_THREAD_INDEFINITE_SLEEP;
} else {
sleep_ns = (ns_until_deferred