P1.3: Add meta->active for TLS SLL tracking
Add active field to TinySlabMeta to track blocks currently held by users (not in TLS SLL or freelist caches). This enables accurate empty slab detection that accounts for TLS SLL cached blocks. Changes: - superslab_types.h: Add _Atomic uint16_t active field - ss_allocation_box.c, hakmem_tiny_superslab.c: Initialize active=0 - tiny_free_fast_v2.inc.h: Decrement active on TLS SLL push - tiny_alloc_fast.inc.h: Add tiny_active_track_alloc() helper, increment active on TLS SLL pop (all code paths) - ss_hot_cold_box.h: ss_is_slab_empty() uses active when enabled All tracking is ENV-gated: HAKMEM_TINY_ACTIVE_TRACK=1 to enable. Default is off for zero performance impact. Invariant: active = used - tls_cached (active <= used) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -429,6 +429,7 @@ void superslab_init_slab(SuperSlab* ss, int slab_idx, size_t block_size, uint32_
|
||||
TinySlabMeta* meta = &ss->slabs[slab_idx];
|
||||
meta->freelist = NULL; // NULL = linear allocation mode
|
||||
meta->used = 0;
|
||||
meta->active = 0; // P1.3: blocks in use by user (starts at 0)
|
||||
meta->capacity = capacity;
|
||||
meta->carved = 0;
|
||||
// Store bits 8-15 of owner_tid (low 8 bits are 0 for glibc pthread IDs)
|
||||
|
||||
Reference in New Issue
Block a user