fix assertions

This commit is contained in:
daanx 2024-12-03 11:06:07 -08:00
parent 666c089fc8
commit 3fc2c8e279
6 changed files with 8 additions and 10 deletions

View file

@ -676,8 +676,7 @@ static inline bool mi_page_try_claim_ownership(mi_page_t* page) {
static inline void _mi_page_unown(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_owned(page));
mi_assert_internal(mi_page_is_abandoned(page)); mi_assert_internal(mi_page_is_abandoned(page));
mi_assert_internal(mi_page_thread_id(page)==0);
mi_thread_free_t tf_new; mi_thread_free_t tf_new;
mi_thread_free_t tf_old = mi_atomic_load_relaxed(&page->xthread_free); mi_thread_free_t tf_old = mi_atomic_load_relaxed(&page->xthread_free);
do { do {

View file

@ -1120,9 +1120,7 @@ static inline bool mi_bfield_atomic_clear_while_not_busy(_Atomic(mi_bfield_t)*b,
do { do {
if mi_unlikely((old&mask)==mask_busy) { if mi_unlikely((old&mask)==mask_busy) {
old = mi_atomic_load_acquire(b); old = mi_atomic_load_acquire(b);
if ((old&mask)==mask_busy) { if ((old&mask)==mask_busy) { _mi_stat_counter_increase(&_mi_stats_main.pages_unabandon_busy_wait, 1); }
_mi_stat_counter_increase(&_mi_stats_main.pages_unabandon_busy_wait, 1);
}
while ((old&mask)==mask_busy) { // busy wait while ((old&mask)==mask_busy) { // busy wait
mi_atomic_yield(); mi_atomic_yield();
old = mi_atomic_load_acquire(b); old = mi_atomic_load_acquire(b);

View file

@ -155,7 +155,7 @@ void mi_free(void* p) mi_attr_noexcept
static void mi_decl_noinline mi_free_try_reclaim_mt(mi_page_t* page) { static void mi_decl_noinline mi_free_try_reclaim_mt(mi_page_t* page) {
mi_assert_internal(mi_page_is_owned(page)); mi_assert_internal(mi_page_is_owned(page));
mi_assert_internal(mi_page_thread_id(page)==0); mi_assert_internal(mi_page_is_abandoned(page));
#if 1 #if 1
// we own the page now.. // we own the page now..
// safe to collect the thread atomic free list // safe to collect the thread atomic free list

View file

@ -83,7 +83,8 @@ const mi_page_t _mi_page_empty = {
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 } \ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 } \
MI_STAT_COUNT_END_NULL() MI_STAT_COUNT_END_NULL()
// -------------------------------------------------------- // --------------------------------------------------------

View file

@ -811,7 +811,7 @@ static mi_page_t* mi_page_queue_find_free_ex(mi_heap_t* heap, mi_page_queue_t* p
_mi_page_free(page_candidate, pq); _mi_page_free(page_candidate, pq);
page_candidate = page; page_candidate = page;
} }
else if (page->used >= page_candidate->used && !mi_page_is_mostly_used(page)) { else if (page->used >= page_candidate->used) { // && !mi_page_is_mostly_used(page)) {
page_candidate = page; page_candidate = page;
} }
// if we find a non-expandable candidate, or searched for N pages, return with the best candidate // if we find a non-expandable candidate, or searched for N pages, return with the best candidate

View file

@ -45,14 +45,14 @@ static int THREADS = 4;
static int SCALE = 100; static int SCALE = 100;
static int ITER = 10; static int ITER = 10;
#define ALLOW_LARGE false #define ALLOW_LARGE false
#elif 1 #elif 0
static int THREADS = 32; static int THREADS = 32;
static int SCALE = 50; static int SCALE = 50;
static int ITER = 50; static int ITER = 50;
#define ALLOW_LARGE false #define ALLOW_LARGE false
#else #else
static int THREADS = 32; // more repeatable if THREADS <= #processors static int THREADS = 32; // more repeatable if THREADS <= #processors
static int SCALE = 50; // scaling factor static int SCALE = 25; // scaling factor
static int ITER = 50; // N full iterations destructing and re-creating all threads static int ITER = 50; // N full iterations destructing and re-creating all threads
#endif #endif