Skip to content

feat: slab allocator for fixed-size kernel objects#166

Merged
ryanbreen merged 1 commit intomainfrom
feat/slab-allocator
Feb 7, 2026
Merged

feat: slab allocator for fixed-size kernel objects#166
ryanbreen merged 1 commit intomainfrom
feat/slab-allocator

Conversation

@ryanbreen
Copy link
Owner

Summary

  • Add bitmap-based slab allocator (SlabCache + SlabBox<T>) for O(1) alloc/dealloc of fixed-size kernel objects
  • Two slab caches: fd_table (64 slots x 12 KiB) and signal_handlers (64 slots x 2 KiB), targeting the heaviest fork/exec allocation paths
  • Add /proc/slabinfo virtual file with ProcfsFile fd type, readable via cat /proc/slabinfo from userspace shell
  • Initialize procfs on both x86_64 and ARM64 boot paths
  • Add slab allocator and procfs boot POST and memory integration tests

Test plan

  • ARM64 kernel builds cleanly (zero warnings)
  • x86_64 kernel builds cleanly (zero warnings)
  • ARM64 boot test passes (init_shell reached)
  • x86_64 boot test passes
  • cat /proc/slabinfo works from breenix shell
  • cargo test -- memory_tests passes (slab init + procfs init tests)
  • cargo test -- boot_post_test passes (slab allocator POST check)

🤖 Generated with Claude Code

…binfo

Add bitmap-based slab allocator (SlabCache) with SlabBox<T> smart pointer
for O(1) allocation/deallocation of frequently used fixed-size objects.
Two slab caches serve the heaviest allocation paths in fork/exec:

- fd_table: 64 slots x 12288 bytes for FdTable arrays
- signal_handlers: 64 slots x 2048 bytes for SignalAction arrays

SlabBox<T> transparently falls back to the global heap when slabs are full,
so the system degrades gracefully under load rather than failing.

Also adds /proc/slabinfo virtual file accessible via `cat /proc/slabinfo`
from userspace, showing live slab utilization stats. This required adding
the ProcfsFile fd type with open/read/close/fstat/poll support across
both x86_64 and ARM64 syscall paths.

Includes boot POST and memory integration tests for slab initialization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ryanbreen ryanbreen merged commit a9ee958 into main Feb 7, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant