23 lines
978 B
C
23 lines
978 B
C
|
|
#include "free_remote_box.h"
|
||
|
|
#include "free_publish_box.h"
|
||
|
|
#include "hakmem_tiny.h"
|
||
|
|
|
||
|
|
int tiny_free_remote_box(SuperSlab* ss, int slab_idx, TinySlabMeta* meta, void* ptr, uint32_t my_tid) {
|
||
|
|
extern _Atomic uint64_t g_free_remote_box_calls;
|
||
|
|
atomic_fetch_add_explicit(&g_free_remote_box_calls, 1, memory_order_relaxed);
|
||
|
|
if (!(ss && ss->magic == SUPERSLAB_MAGIC)) return 0;
|
||
|
|
if (slab_idx < 0 || slab_idx >= ss_slabs_capacity(ss)) return 0;
|
||
|
|
(void)my_tid;
|
||
|
|
|
||
|
|
// BUGFIX: Decrement used BEFORE remote push to maintain visibility consistency
|
||
|
|
// Remote push uses memory_order_release, so drainer must see updated used count
|
||
|
|
meta->used--;
|
||
|
|
int transitioned = ss_remote_push(ss, slab_idx, ptr); // ss_active_dec_one() called inside
|
||
|
|
// ss_active_dec_one(ss); // REMOVED: Already called inside ss_remote_push()
|
||
|
|
if (transitioned) {
|
||
|
|
tiny_free_publish_remote_transition((int)ss->size_class, ss, slab_idx);
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
return 0;
|
||
|
|
}
|