Files
hakmem/core/hakmem_syscall.h
Moe Charm (CI) 52386401b3 Debug Counters Implementation - Clean History
Major Features:
- Debug counter infrastructure for Refill Stage tracking
- Free Pipeline counters (ss_local, ss_remote, tls_sll)
- Diagnostic counters for early return analysis
- Unified larson.sh benchmark runner with profiles
- Phase 6-3 regression analysis documentation

Bug Fixes:
- Fix SuperSlab disabled by default (HAKMEM_TINY_USE_SUPERSLAB)
- Fix profile variable naming consistency
- Add .gitignore patterns for large files

Performance:
- Phase 6-3: 4.79 M ops/s (has OOM risk)
- With SuperSlab: 3.13 M ops/s (+19% improvement)

This is a clean repository without large log files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 12:31:14 +09:00

59 lines
2.0 KiB
C

// hakmem_syscall.h - System call wrapper (bypasses LD_PRELOAD)
//
// Purpose: Direct libc access via dlsym to avoid LD_PRELOAD recursion
//
// Box Theory - Layer 3 (Syscall Layer):
// This module implements "Box 3" in the 3-layer architecture:
// Box 1 (API) → Box 2 (Core) → Box 3 (Syscall - THIS MODULE)
// ↑ Bypasses LD_PRELOAD!
//
// Design Philosophy:
// - Use dlsym(RTLD_NEXT, "malloc") to get real libc functions
// - Completely bypass LD_PRELOAD wrappers (no recursion possible)
// - No guard needed (g_in_internal_malloc removed!)
// - Called ONLY by Box 2 (hakmem core) for internal allocations
//
// Usage:
// - Slab/Page allocation in Tiny/Mid/Large pools
// - Learner policy allocation
// - Any hakmem internal structure
//
// Safety:
// - Must call hkm_syscall_init() BEFORE any allocation
// - Will abort() if dlsym fails
//
// License: MIT
// Date: 2025-10-24
#ifndef HAKMEM_SYSCALL_H
#define HAKMEM_SYSCALL_H
#include <stddef.h>
// Initialize syscall layer (dlsym to get real libc functions)
// Must be called from hak_init() before any allocation
// This function is idempotent (safe to call multiple times)
void hkm_syscall_init(void);
// Direct libc malloc (bypasses LD_PRELOAD completely)
// Returns: Pointer to allocated memory, or NULL on failure
// Usage: Internal allocations ONLY (Slab/Page/Learner)
//
// Example:
// TinySlab* slab = (TinySlab*)hkm_libc_malloc(sizeof(TinySlab));
void* hkm_libc_malloc(size_t size);
// Direct libc calloc (bypasses LD_PRELOAD completely)
// Returns: Pointer to zero-initialized memory, or NULL on failure
void* hkm_libc_calloc(size_t nmemb, size_t size);
// Direct libc free (bypasses LD_PRELOAD completely)
// Args: ptr - pointer to free (can be NULL)
void hkm_libc_free(void* ptr);
// Direct libc realloc (bypasses LD_PRELOAD completely)
// Returns: Pointer to reallocated memory, or NULL on failure
void* hkm_libc_realloc(void* ptr, size_t size);
#endif // HAKMEM_SYSCALL_H