Repository navigation
telemetry: performance_monitor: cap extended perf data reply - #11477
Open
Shrusti-pk wants to merge 1 commit into
Open
Shrusti-pk wants to merge 1 commit into
Shrusti-pk wants to merge 1 commit into
Conversation
get_extended_performance_data() writes one 48-byte ext_perf_data_item for every enabled core and every occupied performance slot, and never looks at the size of the buffer it writes to. The IPC4 BaseFW LARGE_CONFIG_GET for IPC4_EXTENDED_GLOBAL_PERF_DATA hands it ipc->comp_data, a SOF_IPC_MSG_MAX_SIZE (4096 byte) heap block, which holds 85 items after the count word. A slot is taken for every component the host creates, and while measurements are started it stays taken after the component is freed. CONFIG_SOF_TELEMETRY_MAX_COMP_ENTRIES defaults to 88 (170 without SOF_TELEMETRY_MODULE_RESOURCES), so 85 components on one core are enough for the report to run past the end of comp_data: up to 372 bytes with 5 cores and 88 slots, about 4 KiB with 170 slots. The reply size check in ipc4_get_large_config_module_instance() runs only after the getter has written. Pass the buffer size to get_extended_performance_data() and report only the items that fit, with a warning. Reports that fit are unchanged. The 16-byte global and I/O perf reports cannot exceed the buffer with the configured slot counts.
Shrusti-pk
requested review from
dbaluta,
kv2019i,
lbetlej,
lgirdwood,
mmaka1 and
plbossart
as code owners
November 17, 2026 14:37
Collaborator
|
Can one of the admins verify this patch?
|
Member
|
test this please |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Vendor-config GETs can still overrun the buffer, and capped reports silently omit records without a way to retrieve them.
2 open issues
What changed in this PR
Adds size-aware generation of IPC4 extended performance telemetry replies to prevent oversized reports from overflowing the reply buffer.
Changes:
- Validate destination capacity and cap the number of core and component records written.
- Pass the IPC message-size limit from BaseFW and update the API declaration, disabled stub, and documentation.
| File | Description |
|---|---|
src/kernel/debug/telemetry/performance_monitor.c |
Adds capacity validation and limits emitted performance records. |
src/kernel/audio/base_fw.c |
Supplies the IPC message-size limit to the telemetry function. |
src/include/sof/debug/telemetry/performance_monitor.h |
Updates the function signature, stub, and buffer-size documentation. |
Review effort: Balanced
| struct extended_global_perf_data *perf_data = (struct extended_global_perf_data *)data; | ||
|
|
||
| ret = get_extended_performance_data(perf_data); | ||
| ret = get_extended_performance_data(perf_data, SOF_IPC_MSG_MAX_SIZE); |
Comment on lines
+447
to
+450
| if (slots_count > max_slots) { | ||
| tr_warn(&ipc_tr, "%zu perf items do not fit, reporting %zu", slots_count, | ||
| max_slots); | ||
| slots_count = max_slots; |
Member
|
@Shrusti-pk can you respond/respin to teh review comments. Thanks ! |
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.


get_extended_performance_data() fills the IPC4_EXTENDED_GLOBAL_PERF_DATA reply without knowing the size of the buffer it writes to:
The size comes from base_fw because only the caller knows the buffer. The global and I/O reports use 16-byte items and fit. I could not build the Zephyr image locally, so the change is compile- and run-tested only through that standalone harness.