diff --git a/core/box/tls_sll_drain_box.h b/core/box/tls_sll_drain_box.h index f0544023..1548dd3a 100644 --- a/core/box/tls_sll_drain_box.h +++ b/core/box/tls_sll_drain_box.h @@ -175,16 +175,23 @@ static inline uint32_t tiny_tls_sll_drain(int class_idx, uint32_t batch_size) { // Call tiny_free_local_box() to: // 1. Push block to slab freelist // 2. Decrement meta->used (THIS IS THE KEY!) - // 3. Check if slab becomes empty (meta->used == 0) - // 4. If empty, release slab → SuperSlab → LRU cache tiny_free_local_box(ss, slab_idx, meta, user_ptr, my_tid); drained++; - // Debug: Log when used reaches 0 (slab becomes empty) - if (g_debug && meta->used == 0) { - fprintf(stderr, "[TLS_SLL_DRAIN] EMPTY: class=%d ss=%p slab=%d (meta->used=0)\n", - class_idx, (void*)ss, slab_idx); + // CRITICAL: Check if slab became empty and release to shared pool + // (This logic is in tiny_superslab_free.inc.h:223-236) + if (meta->used == 0) { + // Debug: Log when used reaches 0 (slab becomes empty) + if (g_debug) { + fprintf(stderr, "[TLS_SLL_DRAIN] EMPTY: class=%d ss=%p slab=%d (meta->used=0) -> releasing to pool\n", + class_idx, (void*)ss, slab_idx); + } + + // Release empty slab to shared pool + // This will eventually free the SuperSlab and add to LRU cache + extern void shared_pool_release_slab(SuperSlab* ss, int slab_idx); + shared_pool_release_slab(ss, slab_idx); } }