← Back to Pull requests

P1.4: kernel heap — linked_list_allocator behind the kernel lock, alloc enabled #73

Closed
unknown closed this pull request without merging on Sep 27, 2026 14:09 UTC
View on GitHub
unknown unknown commented on Sep 27, 2026 13:44 UTC
Author

Summary

Plan task P1.4: a kernel heap so alloc (Vec, Box, BTreeMap, …) works inside chisel.

Design


  • kernel::mm::heap: at boot, after paging, 256 fresh frames are mapped at KERNEL_DYNAMIC_BASE + 256 MiB (1 MiB, clear of the test/stack pages near the region's base) and handed to linked_list_allocator::Heap.

  • The crate is used with default-features = false (no spinning_top): the heap sits behind the kernel's own SpinLock, and every alloc/dealloc runs under without_interrupts, so an interrupt handler can never deadlock against an allocation in progress.

  • heap::stats() reports allocator usage and a bytes-in-use counter (sum of live layout sizes), the hook for Budget accounting in P2.4 (CLAUDE.md: every allocation path must charge a Budget — nothing to charge yet).

  • Boot prints heap: 1024 KiB at 0xffff900010000000 (… bytes used by the allocator itself).

  • Out-of-memory: an explicit #[alloc_error_handler] reports kernel heap exhausted: allocation of N bytes (align A) failed; <heap stats> and takes the panic path; oom-test on the cmdline and the new oom smoke scenario prove it (7 smoke scenarios now).

  • Growth is deferred: 1 MiB is plenty until user space exists; the map loop is the obvious place to extend.
  • Tests (AC: Vec/Box/BTreeMap work in kernel tests)


  • heap_vec_box_and_btreemap_work: 10 000-element Vec with checksum, 4 KiB Box, BTreeMap ordering and lookup.

  • heap_returns_memory_after_drop: 200 rounds of small + 32 KiB allocations; allocator used and bytes-in-use return exactly to baseline.
  • Verification


    test summary:
      PASS  host unit tests: passed
      PASS  in-kernel tests (QEMU): chisel-test: 12 passed; 0 failed
      PASS  boot smoke (UEFI, BIOS, panic, double fault, page fault, stack overflow, OOM): 7 scenarios passed
    perf: all budgets met (kernel 65.2 KiB, ISO 3.88 MiB, boot 1755 ms)
    

    fmt, clippy (host + kernel), cargo deny check (new dependency: MIT/Apache-2.0, no transitive deps), docs-gate clean. PLAN §11 updated (P1.4 done, next P1.5).

    Closes #50
    task: P1.4

    🤖 Generated with Claude Code

    Diff: 268 lines (+201 / -67) across 3 files Reviewer: garrickdabbs Review duration: 25m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.44) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.44 · 268 lines diff across 3 files
    0.44
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.335
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #73"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.4% (MEDIUM) · Higher = larger blast radius
    44.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.5% · Safe to merge
    17.5%