Files
hakmem/hakmem_256.strace
Moe Charm (CI) 1010a961fb Tiny: fix header/stride mismatch and harden refill paths
- Root cause: header-based class indexing (HEADER_CLASSIDX=1) wrote a 1-byte
  header during allocation, but linear carve/refill and initial slab capacity
  still used bare class block sizes. This mismatch could overrun slab usable
  space and corrupt freelists, causing reproducible SEGV at ~100k iters.

Changes
- Superslab: compute capacity with effective stride (block_size + header for
  classes 0..6; class7 remains headerless) in superslab_init_slab(). Add a
  debug-only bound check in superslab_alloc_from_slab() to fail fast if carve
  would exceed usable bytes.
- Refill (non-P0 and P0): use header-aware stride for all linear carving and
  TLS window bump operations. Ensure alignment/validation in tiny_refill_opt.h
  also uses stride, not raw class size.
- Drain: keep existing defense-in-depth for remote sentinel and sanitize nodes
  before splicing into freelist (already present).

Notes
- This unifies the memory layout across alloc/linear-carve/refill with a single
  stride definition and keeps class7 (1024B) headerless as designed.
- Debug builds add fail-fast checks; release builds remain lean.

Next
- Re-run Tiny benches (256/1024B) in debug to confirm stability, then in
  release. If any remaining crash persists, bisect with HAKMEM_TINY_P0_BATCH_REFILL=0
  to isolate P0 batch carve, and continue reducing branch-miss as planned.
2025-11-09 18:55:50 +09:00

65 lines
3.4 KiB
Plaintext

[hakmem] [Whale] Initialized (capacity=8, threshold=2 MB)
[hakmem] EVO sampling disabled (HAKMEM_EVO_SAMPLE not set or 0)
[hakmem] Baseline: soft_pf=173, hard_pf=0, rss=2176 KB
[hakmem] Initialized (PoC version)
[hakmem] Sampling rate: 1/1
[hakmem] Max sites: 256
[hakmem] Invalid free mode: skip check (default)
[Pool] hak_pool_init() called for the first time
[Pool] hak_pool_init_impl() EXECUTING - Bridge class fix applied
[Pool] Initialized (L2 Hybrid Pool) - Bridge classes SHOULD be enabled
[Pool] Class 5 (40KB): 40960
[Pool] Class 6 (52KB): 53248
[hakmem] [Pool] Initialized (L2 Hybrid Pool)
[hakmem] [Pool] Class configuration:
[hakmem] Class 0: 2 KB (ENABLED)
[hakmem] Class 1: 4 KB (ENABLED)
[hakmem] Class 2: 8 KB (ENABLED)
[hakmem] Class 3: 16 KB (ENABLED)
[hakmem] Class 4: 32 KB (ENABLED)
[hakmem] Class 5: 40 KB (ENABLED)
[hakmem] Class 6: 52 KB (ENABLED)
[hakmem] [Pool] Page size: 64 KB
[hakmem] [Pool] Shards: 64 (site-based)
[Pool] Pre-allocated 4 pages for Bridge class 5 (40 KB) - Critical for 33KB allocs
[Pool] Pre-allocated 4 pages for Bridge class 6 (52 KB)
[hakmem] [L2.5] Initialized (LargePool)
[hakmem] [L2.5] Classes: 64KB, 128KB, 256KB, 512KB, 1MB
[hakmem] [L2.5] Page size: 64 KB
[hakmem] [L2.5] Shards: 64 (site-based)
[hakmem] [BigCache] Initialized (Phase 2c: Dynamic hash table)
[hakmem] [BigCache] Initial capacity: 256 buckets, max: 65536 buckets
[hakmem] [BigCache] Load factor: 0.75, min size: 512 KB
[ELO] Initialized 12 strategies (thresholds: 512KB-32MB)
[Batch] Initialized (threshold=8 MB, min_size=64 KB, bg=on)
[ADAPTIVE] Adaptive sizing initialized (initial_cap=64, min=16, max=2048)
[ACE] ACE disabled (HAKMEM_ACE_ENABLED=0)
[SUPERSLAB_MMAP] #1: class=0 size=2097152 (total SuperSlab mmaps so far)
[HAKMEM] Initialized SuperSlabHead for class 0: 1 initial chunks
[BATCH_CARVE] cls=0 slab=1 used=0 cap=8192 batch=16 base=0x7758d3610000 bs=8
[SUPERSLAB_MMAP] #2: class=1 size=2097152 (total SuperSlab mmaps so far)
[HAKMEM] Initialized SuperSlabHead for class 1: 1 initial chunks
[SUPERSLAB_MMAP] #3: class=2 size=2097152 (total SuperSlab mmaps so far)
[HAKMEM] Initialized SuperSlabHead for class 2: 1 initial chunks
[SUPERSLAB_MMAP] #4: class=3 size=2097152 (total SuperSlab mmaps so far)
[HAKMEM] Initialized SuperSlabHead for class 3: 1 initial chunks
[SUPERSLAB_MMAP] #5: class=4 size=2097152 (total SuperSlab mmaps so far)
[HAKMEM] Initialized SuperSlabHead for class 4: 1 initial chunks
[SUPERSLAB_MMAP] #6: class=5 size=2097152 (total SuperSlab mmaps so far)
[HAKMEM] Initialized SuperSlabHead for class 5: 1 initial chunks
[SUPERSLAB_MMAP] #7: class=6 size=2097152 (total SuperSlab mmaps so far)
[HAKMEM] Initialized SuperSlabHead for class 6: 1 initial chunks
[SUPERSLAB_MMAP] #8: class=7 size=2097152 (total SuperSlab mmaps so far)
[SUPERSLAB_INIT] class 7 slab 0: usable_size=63488 block_size=1024 capacity=62
[SUPERSLAB_INIT] Expected: 63488 / 1024 = 62 blocks
[HAKMEM] Initialized SuperSlabHead for class 7: 1 initial chunks
[hakmem] TLS cache pre-warmed for 8 classes
[Pool] hak_pool_try_alloc FIRST CALL EVER!
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
50.21 0.000117 3 36 mmap
48.07 0.000112 10 11 munmap
1.72 0.000004 4 1 madvise
------ ----------- ----------- --------- --------- ----------------
100.00 0.000233 4 48 total