executor: emit rtos-trace system_idle only at real sleep sites#6502
Open
basil-huber wants to merge 1 commit into
Open
executor: emit rtos-trace system_idle only at real sleep sites#6502basil-huber wants to merge 1 commit into
basil-huber wants to merge 1 commit into
Conversation
Previously, executors would call rtos-trace's system_idle callback after polling. For InterruptExecutors this is incorrect: the executor finishes polling and returns to the preempted (lower-priority) context, so execution continues and the system is not idle. Only the thread-mode executor reaching its wait site means the system is truly idle. This misleads notably SystemView (https://www.segger.com/products/development-tools/systemview/), connected via the systemview-target crate (https://crates.io/crates/systemview-target), which misinterprets the events and produces a corrupted timeline. Stop emitting `system_idle` in `executor_idle`, and add a public `Executor::trace_system_idle()` that each thread-mode run loop calls at its genuine wait site instead. It is a no-op unless a trace feature is enabled, and must not be called from an interrupt executor. The behaviour of the following executors stays the same: - embassy-executor/src/platform/cortex_m.rs: Executor - embassy-executor/src/platform/cortex_ar.rs: Executor - embassy-rp/src/executor.rs: Executor The following executors do NOT call `system_idle` anymore: - embassy-executor/src/platform/cortex_m.rs: InterruptExecutor - embassy-rp/src/executor.rs: InterruptExecutor - embassy-stm32/src/executor.rs: InterruptExecutor - embassy-executor/src/platform/spin.rs: Executor - embassy-executor/src/platform/wasm.rs: Executor The following executors call `system_idle` only before actually idling: - embassy-executor/src/platform/riscv32.rs: Executor - embassy-executor/src/platform/std.rs: Executor - embassy-executor/src/platform/avr.rs: Executor - embassy-stm32/src/executor.rs: Executor - embassy-mcxa/src/executor.rs: Executor Note: these differences only affect the `rtos-trace` feature.
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.
Previously, executors would call rtos-trace's system_idle callback after polling.
For InterruptExecutors this is incorrect: the executor finishes polling and returns to the preempted (lower-priority) context, so execution continues and the system is not idle. Only the thread-mode executor reaching its wait site means the system is truly idle.
This misleads notably SystemView
(https://www.segger.com/products/development-tools/systemview/), connected via the systemview-target crate
(https://crates.io/crates/systemview-target), which misinterprets the events and produces a corrupted timeline.
Stop emitting
system_idleinexecutor_idle, and add a publicExecutor::trace_system_idle()that each thread-mode run loop calls at its genuine wait site instead. It is a no-op unless a trace feature is enabled, and must not be called from an interrupt executor.The behaviour of the following executors stays the same:
The following executors do NOT call
system_idleanymore:The following executors call
system_idleonly before actually idling:Note: these differences only affect the
rtos-tracefeature.