amdgpu: fix AMDGPU stats showing 0 due to invalid gpu_metrics data - #2047
Open
lullptr wants to merge 1 commit into
Open
amdgpu: fix AMDGPU stats showing 0 due to invalid gpu_metrics data#2047lullptr wants to merge 1 commit into
lullptr wants to merge 1 commit into
Conversation
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.
Issue: AMDGPU stats displaying 0
Fixes #2028
Fixes #2038
Problem
I understand that the current implementation uses a hybrid model where sysfs values act as the baseline and are overridden by
gpu_metricswhen available.However, the override logic assumes that the presence of the
gpu_metricsfile implies valid and supported data. In practice, this is not always true, the file may exist and be readable even when the kernel/firmware reports unsupported or invalid metrics.As a result, valid sysfs values are unconditionally overwritten by invalid
gpu_metricsdata, leading to GPU statistics incorrectly showing as 0.Fix
Introduce a validity tracking flag for
gpu_metricssampling.The flag is set only when at least one
gpu_metricssample successfully produces valid and usable metric data. This indicatesgpu_metricsis functional on the system and only then isgpu_metricsallowed to override sysfs values.Consideration
This fix preserves the existing hybrid model by allowing
gpu_metricsto override sysfs values once at least one valid sample has been observed.However, it may be worth reconsidering whether a single successful sample is sufficient, or if multiple consecutive valid samples should be required before enabling overrides.
Screenshots
Before patch

After patch
