Guard madvise ENOMEM and stabilize pool/tiny front v3

This commit is contained in:
Moe Charm (CI)
2025-12-09 21:50:15 +09:00
parent e274d5f6a9
commit a905e0ffdd
45 changed files with 3154 additions and 242 deletions

View File

@ -49,6 +49,7 @@
#include "hakmem_l25_pool.h"
#include "hakmem_config.h"
#include "hakmem_internal.h" // For AllocHeader and HAKMEM_MAGIC
#include "box/ss_os_acquire_box.h"
#include "hakmem_syscall.h" // Phase 6.X P0 Fix: Box 3 syscall layer (bypasses LD_PRELOAD)
#include "box/pagefault_telemetry_box.h" // Box PageFaultTelemetry (PF_BUCKET_L25)
#include "page_arena.h" // Phase 24: PageArena integration for L25
@ -560,7 +561,7 @@ void hak_l25_pool_free_fast(void* user_ptr, uintptr_t site_id) {
// Optional: demand-zero for larger classes
if (g_l25_pool.demand_zero && class_idx >= 3) {
madvise((char*)raw, HEADER_SIZE + g_class_sizes[class_idx], MADV_DONTNEED);
(void)ss_os_madvise_guarded((char*)raw, HEADER_SIZE + g_class_sizes[class_idx], MADV_DONTNEED, "l25_pool_dontneed_class");
}
// Same-thread hint: prefer per-block owner if header present (HDR_LIGHT>=1), else page owner
@ -1118,7 +1119,7 @@ void hak_l25_pool_free(void* ptr, size_t size, uintptr_t site_id) {
if (g_l25_pool.demand_zero) {
int class_idx_dz = hak_l25_pool_get_class_index(size);
if (class_idx_dz >= 3) {
madvise((char*)raw, HEADER_SIZE + size, MADV_DONTNEED);
(void)ss_os_madvise_guarded((char*)raw, HEADER_SIZE + size, MADV_DONTNEED, "l25_pool_dontneed_size");
}
}