feat(mbr): add PMU-based memory bandwidth throttling with timer support#373
Draft
Diogo21Costa wants to merge 3 commits into
Draft
feat(mbr): add PMU-based memory bandwidth throttling with timer support#373Diogo21Costa wants to merge 3 commits into
Diogo21Costa wants to merge 3 commits into
Conversation
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
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.
Summary
This PR adds PMU-based memory bandwidth throttling for Armv8 platforms, together with the timer and PMU infrastructure required to support it.
At a high level, a VM can now be configured with:
When throttling is enabled, the hypervisor reserves PMU event counters, monitors the configured event, stops a CPU when its budget overflows, and periodically restores the budget using the EL2 physical timer.
This PR also includes ZCU104-specific PMU event and interrupt metadata used to validate the feature with a cache-refill-based workload.
Main changes
1. PMU event counter support
Adds an event-counter abstraction backed by the Arm PMU:
Relevant commit:
feat(armv8/pmu): add event counter support2. EL2 timer support
Adds support for the hypervisor physical timer through a core timer abstraction:
Relevant commit:
feat(armv8/timer): add hypervisor timer support3. Memory bandwidth throttling
Adds the memory throttling mechanism itself:
Relevant commit:
feat(core): add memory bandwidth throttlingValidation artifacts
Validation artifacts and test instructions are available in the following repository:
git@github.com:Diogo21Costa/bao-demos.gitThis repository is based on
bao-demos, which is the Bao demo guide repository used to build and run guest configurations across supported platforms. It extends that flow with support for a baremetal guest that benchmarks memory bandwidth, which makes it possible to observe and analyse the throttling effect directly. The output is something similar to:Validation setup
The current validation targets ZCU104.
For this setup, the throttling event is configured as
L1D_CACHE_REFILL. The baremetal benchmark performs cache-line-sized pointer-chase reads and invalidates the buffer between passes, so each counted refill corresponds approximately to one 64-byte cache line.The expected bandwidth is derived from the configured PMU event budget and throttle window:
Where:
Therefore, the expected bandwidth in MiB/s is:
For these tests,
period_us = 10000, so there are 100 throttle windows per second:Examples:
50000 * 64 * 100 / 1048576 = 305 MiB/s30000 * 64 * 100 / 1048576 = 183 MiB/s10000 * 64 * 100 / 1048576 = 61 MiB/sThe measured results closely follow the expected linear scaling, which validates that:
Notes
This validation uses
L1D_CACHE_REFILLas the accounting event because it maps well to the benchmark used in the artifacts and provides an intuitive approximation of bandwidth on ZCU104.However, this is only one possible configuration. Other PMU events can also be used depending on the platform and on the type of memory activity that should be controlled or observed.
Testing
Please refer to the validation repository for:
For the base platform bring-up flow on ZCU104, the upstream
bao-demosrepository already documents the general image preparation, SD card setup, UART connection, and boot procedure.