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

@ -4,6 +4,8 @@
// Date: 2025-11-28
#include "hakmem_tiny_superslab_internal.h"
#include "box/ss_os_acquire_box.h"
#include <stdbool.h>
#include <stdlib.h>
// ============================================================================
@ -33,8 +35,11 @@ _Atomic uint64_t g_final_fallback_mmap_count = 0;
_Atomic uint64_t g_ss_os_alloc_calls = 0;
_Atomic uint64_t g_ss_os_free_calls = 0;
_Atomic uint64_t g_ss_os_madvise_calls = 0;
_Atomic uint64_t g_ss_os_madvise_fail_enomem = 0;
_Atomic uint64_t g_ss_os_madvise_fail_other = 0;
_Atomic uint64_t g_ss_os_huge_alloc_calls = 0;
_Atomic uint64_t g_ss_os_huge_fail_calls = 0;
_Atomic bool g_ss_madvise_disabled = false;
// Superslab/slab observability (Tiny-only; relaxed updates)
_Atomic uint64_t g_ss_live_by_class[8] = {0};
@ -224,10 +229,14 @@ static void ss_os_stats_dump(void) {
return;
}
fprintf(stderr,
"[SS_OS_STATS] alloc=%llu free=%llu madvise=%llu mmap_total=%llu fallback_mmap=%llu huge_alloc=%llu huge_fail=%llu\n",
"[SS_OS_STATS] alloc=%llu free=%llu madvise=%llu madvise_enomem=%llu madvise_other=%llu madvise_disabled=%d "
"mmap_total=%llu fallback_mmap=%llu huge_alloc=%llu huge_fail=%llu\n",
(unsigned long long)atomic_load_explicit(&g_ss_os_alloc_calls, memory_order_relaxed),
(unsigned long long)atomic_load_explicit(&g_ss_os_free_calls, memory_order_relaxed),
(unsigned long long)atomic_load_explicit(&g_ss_os_madvise_calls, memory_order_relaxed),
(unsigned long long)atomic_load_explicit(&g_ss_os_madvise_fail_enomem, memory_order_relaxed),
(unsigned long long)atomic_load_explicit(&g_ss_os_madvise_fail_other, memory_order_relaxed),
atomic_load_explicit(&g_ss_madvise_disabled, memory_order_relaxed) ? 1 : 0,
(unsigned long long)atomic_load_explicit(&g_ss_mmap_count, memory_order_relaxed),
(unsigned long long)atomic_load_explicit(&g_final_fallback_mmap_count, memory_order_relaxed),
(unsigned long long)atomic_load_explicit(&g_ss_os_huge_alloc_calls, memory_order_relaxed),