fix: [SWDEV-466302] [rocm/amd_smi_lib]
Fixes `amdsmi_get_gpu_process_list` now requires sudo to access pid and memory information Code changes related to the following: * amdsmi_get_gpu_process_list() * CLI Change-Id: I72b154c220276b354c350fcc067c9a7c32e6c173 Signed-off-by: Oliveira, Daniel <daniel.oliveira@amd.com>
このコミットが含まれているのは:
@@ -2631,8 +2631,6 @@ class AMDSMICommands():
|
||||
try:
|
||||
process_list = amdsmi_interface.amdsmi_get_gpu_process_list(args.gpu)
|
||||
except amdsmi_exception.AmdSmiLibraryException as e:
|
||||
if e.get_error_code() == amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_NO_PERM:
|
||||
raise PermissionError('Command requires elevation') from e
|
||||
logging.debug("Failed to get process list for gpu %s | %s", gpu_id, e.get_error_info())
|
||||
raise e
|
||||
|
||||
|
||||
+6
-11
@@ -4830,10 +4830,6 @@ amdsmi_get_gpu_vram_usage(amdsmi_processor_handle processor_handle, amdsmi_vram_
|
||||
* Holding a copy of max_process before it is passed in will be helpful for monitoring
|
||||
* the allocations done upon each call since the max_process will permanently be changed
|
||||
* to reflect the actual number of processes running.
|
||||
* Note: For the specific cases where the return status is AMDSMI_STATUS_NO_PERM only.
|
||||
* The list of process and size are AMDSMI_STATUS_SUCCESS, however there are
|
||||
* processes details not fully retrieved due to permissions.
|
||||
*
|
||||
*
|
||||
* @param[out] list Reference to a user-provided buffer where the process
|
||||
* list will be returned. This buffer must contain at least
|
||||
@@ -4841,17 +4837,16 @@ amdsmi_get_gpu_vram_usage(amdsmi_processor_handle processor_handle, amdsmi_vram_
|
||||
* by user.
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success,
|
||||
* | ::AMDSMI_STATUS_NO_PERM on success, but not all details from process retrieved,
|
||||
* | ::AMDSMI_STATUS_OUT_OF_RESOURCES, filled list buffer with data, but number of
|
||||
* actual running processes is larger than the size provided.
|
||||
*
|
||||
*/
|
||||
// Note: If the reserved size for processes is smaller than the number of
|
||||
// actual processes running. The AMDSMI_STATUS_OUT_OF_RESOURCES is
|
||||
// an indication the caller should handle the situation (resize).
|
||||
// The max_processes is always changed to reflect the actual size of
|
||||
// list of processes running, so the caller knows where it is at.
|
||||
//
|
||||
// Note: If the reserved size for processes is smaller than the number of
|
||||
// actual processes running. The AMDSMI_STATUS_OUT_OF_RESOURCES is
|
||||
// an indication the caller should handle the situation (resize).
|
||||
// The max_processes is always changed to reflect the actual size of
|
||||
// list of processes running, so the caller knows where it is at.
|
||||
//
|
||||
amdsmi_status_t
|
||||
amdsmi_get_gpu_process_list(amdsmi_processor_handle processor_handle, uint32_t *max_processes, amdsmi_proc_info_t *list);
|
||||
|
||||
|
||||
@@ -1889,15 +1889,9 @@ amdsmi_get_gpu_process_list(amdsmi_processor_handle processor_handle, uint32_t *
|
||||
|
||||
const auto max_processes_original_size(*max_processes);
|
||||
auto idx = uint32_t(0);
|
||||
auto is_required_previlegies_required(false);
|
||||
for (auto& process : compute_process_list) {
|
||||
if (idx < *max_processes) {
|
||||
list[idx++] = static_cast<amdsmi_proc_info_t>(process.second);
|
||||
// Note: If we could not read the process info for an existing process,
|
||||
// that is likely a permission error.
|
||||
if (!is_required_previlegies_required && std::string(process.second.name).empty()) {
|
||||
is_required_previlegies_required = true;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -1910,11 +1904,9 @@ amdsmi_get_gpu_process_list(amdsmi_processor_handle processor_handle, uint32_t *
|
||||
// list of processes running, so the caller knows where it is at.
|
||||
// Holding a copy of max_process before it is passed in will be helpful
|
||||
// for the caller.
|
||||
status_code = is_required_previlegies_required
|
||||
? amdsmi_status_t::AMDSMI_STATUS_NO_PERM : AMDSMI_STATUS_SUCCESS;
|
||||
*max_processes = static_cast<uint32_t>(compute_process_list.size());
|
||||
return (max_processes_original_size >= static_cast<uint32_t>(compute_process_list.size()))
|
||||
? status_code : amdsmi_status_t::AMDSMI_STATUS_OUT_OF_RESOURCES;
|
||||
? AMDSMI_STATUS_SUCCESS : amdsmi_status_t::AMDSMI_STATUS_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
amdsmi_status_t
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする