Skip to content

Kernel metrics#77

Merged
F42J merged 11 commits into
mainfrom
feature/memory-metrics
May 13, 2026
Merged

Kernel metrics#77
F42J merged 11 commits into
mainfrom
feature/memory-metrics

Conversation

@F42J
Copy link
Copy Markdown
Member

@F42J F42J commented May 11, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 11, 2026 20:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a unified, optionally-enabled kernel metrics surface for observing heap allocator usage and per-thread stack usage, wired through the scheduler and HAL stack abstractions.

Changes:

  • Add a new osiris::metrics module exposing global heap, per-task heap, and per-thread stack metrics APIs.
  • Extend the best-fit allocator and Cortex-M stack implementation to track/report allocator and stack usage metrics (behind metrics feature / osiris_metrics cfg).
  • Add build/config plumbing (OSIRIS_DEBUG_METRICS, feature flags, unexpected_cfgs allowlists) to enable metrics across crates.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/sched/thread.rs Adds per-thread stack metrics accessor (cfg-gated).
src/sched/task.rs Adds per-task heap metrics accessor (cfg-gated).
src/sched.rs Adds scheduler entry points to query per-thread/per-task metrics (cfg-gated).
src/metrics.rs New unified public metrics API module.
src/mem/vmm/nommu.rs Exposes AddressSpace allocator metrics (cfg-gated).
src/mem/alloc/bestfit.rs Adds allocator metrics struct/counters, snapshot method, and tests (cfg-gated).
src/mem.rs Adds global heap metrics snapshot helper (cfg-gated).
src/lib.rs Exposes pub mod metrics behind cfg.
presets/stm32l4r5zi_def.toml Adds OSIRIS_DEBUG_METRICS preset env var.
options.toml Adds a debug.metrics option definition.
machine/cortex-m/src/native/sched.rs Adds stack peak tracking + stack metrics implementation + tests (cfg-gated).
machine/cortex-m/Cargo.toml Adds metrics feature and allows cfg(osiris_metrics) in lints.
machine/cortex-m/build.rs Emits cfg(osiris_metrics) when OSIRIS_DEBUG_METRICS is set.
machine/api/src/stack.rs Adds StackMetrics type + default Stacklike::metrics() (cfg-gated).
machine/api/Cargo.toml Adds metrics feature and allows cfg(osiris_metrics) in lints.
machine/api/build.rs Emits cfg(osiris_metrics) when OSIRIS_DEBUG_METRICS is set.
Cargo.toml Adds top-level metrics feature and allows cfg(osiris_metrics) in lints.
build.rs Emits cfg(osiris_metrics) when OSIRIS_DEBUG_METRICS is set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread machine/cortex-m/src/native/sched.rs
Comment thread machine/cortex-m/src/native/sched.rs
Comment thread src/metrics.rs Outdated
Comment thread src/mem/alloc/bestfit.rs
Copy link
Copy Markdown
Member

@thomasw04 thomasw04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Left a few suggestions and comments. Also: please don't use mod.rs anymore, use the new layout like the rest of the codebase.

Comment thread src/mem/alloc/bestfit.rs Outdated
Comment thread src/sched.rs
Comment thread src/metrics/mod.rs Outdated
Comment thread build.rs Outdated
Comment thread src/mem/alloc/bestfit.rs Outdated
Comment thread src/mem/alloc/bestfit.rs Outdated
@F42J F42J force-pushed the feature/memory-metrics branch 2 times, most recently from 5a1e4c4 to 57b231a Compare May 13, 2026 22:32
@F42J F42J merged commit 85da158 into main May 13, 2026
12 checks passed
@F42J F42J deleted the feature/memory-metrics branch May 13, 2026 22:41
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.

3 participants