Phase 3: Remove mincore() syscall completely

Problem:
- mincore() was already disabled by default (DISABLE_MINCORE=1)
- Phase 1b/2 registry-based validation made mincore obsolete
- Dead code (~60 lines) remained with complex #ifdef guards

Solution:
Complete removal of mincore() syscall and related infrastructure:

1. Makefile:
   - Removed DISABLE_MINCORE configuration (lines 167-177)
   - Added Phase 3 comment documenting removal rationale

2. core/box/hak_free_api.inc.h:
   - Removed ~60 lines of mincore logic with TLS page cache
   - Simplified to: int is_mapped = 1;
   - Added comprehensive history comment

3. core/box/external_guard_box.h:
   - Simplified external_guard_is_mapped() from 20 lines to 4 lines
   - Always returns 1 (assume mapped)
   - Added Phase 3 comment

Safety:
Trust internal metadata for all validation:
- SuperSlab registry: validates Tiny allocations (Phase 1b/2)
- AllocHeader: validates Mid/Large allocations
- FrontGate classifier: routes external allocations

Testing:
✓ Build: Clean compilation (no warnings)
✓ Stability: 100/100 test iterations passed (0% crash rate)
✓ Performance: No regression (mincore already disabled)

History:
- Phase 9: Used mincore() for safety
- 2025-11-14: Added DISABLE_MINCORE flag (+10.3% perf improvement)
- Phase 1b/2: Registry-based validation (0% crash rate)
- Phase 3: Dead code cleanup (this commit)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-11-29 09:04:32 +09:00
parent ca6e8ecaf1
commit d78baf41ce
3 changed files with 25 additions and 86 deletions

View File

@ -58,26 +58,16 @@ typedef struct {
static __thread external_guard_stats_t g_external_guard_stats = {0};
// Check if pointer is safe to dereference (mincore-based, optional)
// Returns: 1 if mapped, 0 if not mapped
// Phase 3 (2025-11-29): mincore removed - assume all pointers are mapped
// Returns: Always 1 (mapped)
//
// Note: This is a debug/diagnostic function. In production, we rely on:
// - SuperSlab registry for Tiny allocations (Phase 1b/2)
// - Headers for Mid/Large allocations
// - FrontGate classifier for routing
static inline int external_guard_is_mapped(void* ptr) {
if (!external_guard_mincore_enabled()) {
// Fast path: mincore disabled, assume mapped
return 1;
}
g_external_guard_stats.mincore_checks++;
#ifdef __linux__
unsigned char vec;
void* page = (void*)((uintptr_t)ptr & ~0xFFFUL);
if (mincore(page, 1, &vec) == 0) {
return 1; // Mapped
}
#endif
g_external_guard_stats.mincore_failed++;
return 0; // Not mapped
(void)ptr; // Unused
return 1; // Always assume mapped
}
// External guard entry point