Feat(phase9): Safe removal from legacy list on shared pool free (Task 2)

Added remove_superslab_from_legacy_head to safely unlink SuperSlabs from
legacy g_superslab_heads when freed by shared_pool_release_slab.
This prevents dangling pointers in the legacy backend if fallback allocation was used.
Called after unlocking alloc_lock to avoid lock inversion.
This commit is contained in:
Moe Charm (CI)
2025-11-30 15:21:42 +09:00
parent e3b0fdce57
commit 128883e7a8
3 changed files with 39 additions and 0 deletions

View File

@ -1489,6 +1489,10 @@ shared_pool_release_slab(SuperSlab* ss, int slab_idx)
pthread_mutex_unlock(&g_shared_pool.alloc_lock);
// Remove from legacy backend list (if present) to prevent dangling pointers
extern void remove_superslab_from_legacy_head(SuperSlab* ss);
remove_superslab_from_legacy_head(ss);
// Free SuperSlab:
// 1. Try LRU cache (hak_ss_lru_push) - lazy deallocation
// 2. Or munmap if LRU is full - eager deallocation