[SWDEV-545128] Implement some changes in AMD-SMI to aggregate metric from primary and secondary KFD processes #2554
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.
Motivation
This PR adds support for parsing per-GPU KFD process files that use the _NNNN suffix naming convention (e.g., vram_46775, stats_46775/).
The ROCm kernel driver exposes per-GPU process statistics in /sys/class/kfd/kfd/proc/PID/ with GPU-specific file suffixes.
Without this change, AMD-SMI cannot read process memory usage and statistics on systems using this KFD file structure.
Technical Details
Modified src/rocm_smi_kfd.cc and rocm_smi_kfd.cc to parse files with _NNNN GPU ID suffixes.
Added logic to read cu_occupancy and evicted_ms from stats_NNNN/ subdirectories under each process.
The implementation maintains backward compatibility with older KFD structures while supporting the new per-GPU naming convention.
JIRA ID
Resolves [SWDEV-545128]
Test Plan
Built AMD-SMI from source and ran amd-smi process command with active GPU workloads.
Verified KFD directory structure parsing by inspecting /sys/class/kfd/kfd/proc/PID/ contents.
Tested both text and JSON output formats to confirm correct data retrieval.
Test Result
Process detection working correctly - PID, process name, and memory usage displayed.
Per-GPU stats (cu_occupancy=0, evicted_ms=0) read successfully from stats_46775/ directory.
All tests passed on MI300A GPU with KFD_ID 46775.
Submission Checklist