small fixes

This commit is contained in:
daanx 2024-12-04 00:14:56 -08:00
parent bc7fe399b1
commit 45f7fb559a
3 changed files with 12 additions and 4 deletions

View file

@ -487,7 +487,7 @@ static inline mi_page_t* _mi_checked_ptr_page(const void* p) {
}
static inline mi_page_t* _mi_ptr_page(const void* p) {
#if 1 // MI_DEBUG
#if MI_DEBUG
return _mi_checked_ptr_page(p);
#else
return _mi_ptr_page_ex(p,NULL);
@ -638,6 +638,13 @@ static inline bool mi_page_is_mostly_used(const mi_page_t* page) {
return (page->reserved - page->used <= frac);
}
// is less than 1/n'th of a page free?
static inline bool mi_page_is_used_at_frac(const mi_page_t* page, uint16_t n) {
if (page==NULL) return true;
uint16_t frac = page->reserved / n;
return (page->reserved - page->used <= frac);
}
static inline bool mi_page_is_abandoned(const mi_page_t* page) {
// note: the xheap field of an abandoned heap is set to the subproc (for fast reclaim-on-free)
return (mi_atomic_load_acquire(&page->xthread_id) <= 1);
@ -692,7 +699,7 @@ static inline bool mi_page_try_claim_ownership(mi_page_t* page) {
static inline void _mi_page_unown(mi_page_t* page) {
mi_assert_internal(mi_page_is_owned(page));
mi_assert_internal(mi_page_is_abandoned(page));
mi_assert_internal(mi_page_is_abandoned(page));
mi_thread_free_t tf_new;
mi_thread_free_t tf_old = mi_atomic_load_relaxed(&page->xthread_free);
do {

View file

@ -51,8 +51,9 @@ typedef uint32_t mi_cmap_t;
typedef mi_decl_align(MI_BITMAP_CHUNK_SIZE) struct mi_bitmap_s {
_Atomic(size_t) chunk_map_count;
_Atomic(size_t) chunk_count;
size_t padding[MI_BITMAP_CHUNK_SIZE/MI_SIZE_SIZE - 2]; // suppress warning on msvc
_Atomic(mi_chunkmap_t) chunk_maps[MI_BITMAP_MAX_CHUNKMAPS];
// padding
mi_bitmap_chunk_t chunks[MI_BITMAP_MIN_BIT_COUNT]; // or more, up to MI_BITMAP_MAX_CHUNK_COUNT
} mi_bitmap_t;

View file

@ -45,7 +45,7 @@ static int THREADS = 1;
static int SCALE = 100;
static int ITER = 10;
#define ALLOW_LARGE false
#elif 0
#elif 1
static int THREADS = 32;
static int SCALE = 50;
static int ITER = 50;