[SWDEV-516592] Add python interface API for Bad Page Threshold (#141)

- Added python interface APIs for amdsmi_get_gpu_bad_page_threshold()
 - Updated the docs and changelog.

---------

Signed-off-by: Kanangot Balakrishnan, Bindhiya <Bindhiya.KanangotBalakrishnan@amd.com>
Signed-off-by: Arif, Maisam <Maisam.Arif@amd.com>
Cette révision appartient à :
Kanangot Balakrishnan, Bindhiya
2025-04-14 04:19:45 -05:00
révisé par GitHub
Parent 19a4775d32
révision 9d7964dff5
6 fichiers modifiés avec 71 ajouts et 1 suppressions
+15
Voir le fichier
@@ -8,6 +8,21 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr
### Added
- **Added bad page threshold count**.
- Added `amdsmi_get_gpu_bad_page_threshold` to Python API and CLI; root/sudo permissions required to display the count.
### Changed
### Removed
### Optimized
### Resolved issues
### Upcoming changes
### Known issues
- **Added cpu model name for RDC**.
- Added new C and Python API `amdsmi_get_cpu_model_name`
- Not sourced from esmi library.
+5
Voir le fichier
@@ -712,6 +712,7 @@ class AMDSMICommands():
if 'ras' in current_platform_args:
if args.ras:
ras_dict = {"eeprom_version": "N/A",
"bad_page_threshold": "N/A",
"parity_schema" : "N/A",
"single_bit_schema" : "N/A",
"double_bit_schema" : "N/A",
@@ -735,6 +736,10 @@ class AMDSMICommands():
ras_dict.update(ras_info)
except amdsmi_exception.AmdSmiLibraryException as e:
logging.debug("Failed to get ras info for gpu %s | %s", gpu_id, e.get_error_info())
try:
ras_dict["bad_page_threshold"] = amdsmi_interface.amdsmi_get_gpu_bad_page_threshold(args.gpu)
except amdsmi_exception.AmdSmiLibraryException as e:
logging.debug("Failed to get bad page threshold count for gpu %s | %s", gpu_id, e.get_error_info())
try:
ras_states = amdsmi_interface.amdsmi_get_gpu_ras_block_features_enabled(args.gpu)
+2 -1
Voir le fichier
@@ -682,7 +682,8 @@ class AMDSMIParser(argparse.ArgumentParser):
clock_help = f"Show one or more valid clock frequency levels. Available options:\n\t{clk_option_str}"
# Options arguments help text for Hypervisors and Baremetal
ras_help = "Displays RAS features information"
# Might be able to remove Sudo requirement in ROCm 7.0
ras_help = "Displays RAS features information;\n\tSudo may be required for some features"
numa_help = "All numa node information" # Linux Baremetal only
partition_help = "Partition information"
+32
Voir le fichier
@@ -990,6 +990,38 @@ except AmdSmiException as e:
print(e)
```
### amdsmi_get_gpu_bad_page_threshold
Description: Returns bad page threshold for the given GPU; Requires root level access to display bad page threshold count; otherwise will return "N/A".
It is not supported on virtual machine guest
Input parameters:
* `processor_handle` device which to query
Output: Bad page threshold value
Exceptions that can be thrown by `amdsmi_get_gpu_bad_page_threshold` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = amdsmi_get_processor_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
threshold = amdsmi_get_gpu_bad_page_threshold(device)
print(bad_page["threshold"])
except AmdSmiException as e:
print(e)
```
### amdsmi_get_gpu_memory_reserved_pages
Description: Returns reserved memory page info for the given GPU.
+1
Voir le fichier
@@ -109,6 +109,7 @@ from .amdsmi_interface import amdsmi_get_clock_info
from .amdsmi_interface import amdsmi_get_pcie_info
from .amdsmi_interface import amdsmi_get_gpu_bad_page_info
from .amdsmi_interface import amdsmi_get_gpu_bad_page_threshold
from .amdsmi_interface import amdsmi_get_violation_status
from .amdsmi_interface import amdsmi_get_gpu_xgmi_link_status
+16
Voir le fichier
@@ -2214,6 +2214,22 @@ def amdsmi_get_gpu_bad_page_info(
return _format_bad_page_info(bad_pages, num_pages)
def amdsmi_get_gpu_bad_page_threshold(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
) -> Dict[str, Any]:
if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle):
raise AmdSmiParameterException(
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
)
threshold = ctypes.c_uint32()
_check_res(
amdsmi_wrapper.amdsmi_get_gpu_bad_page_threshold(
processor_handle, ctypes.byref(threshold)
)
)
return threshold.value
def amdsmi_get_violation_status(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,