Kernel metrics#77
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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::metricsmodule 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
metricsfeature /osiris_metricscfg). - 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.
thomasw04
requested changes
May 13, 2026
Member
thomasw04
left a comment
There was a problem hiding this comment.
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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
5a1e4c4 to
57b231a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.