[SWDEV-539721] Show complete process name (#536)
Modified the file used to fetch process name so that complete name with path can be displayed. Changes: amd-smi monitor -q - human readable format will output only the process name - csv and json formats will print the full path amd-smi process - name will always be the full path to the process amd-smi (default output) - name will always be truncated. --------- Signed-off-by: Bindhiya Kanangot Balakrishnan <Bindhiya.KanangotBalakrishnan@amd.com> Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
This commit is contained in:
committed by
GitHub
parent
01a6158c85
commit
514517e536
@@ -228,7 +228,7 @@ class AMDSMILogger():
|
||||
string_process_value = str(process_value)
|
||||
if process_key == "name":
|
||||
# Truncate name if too long
|
||||
process_name = string_process_value[:17]
|
||||
process_name = string_process_value.split('/')[-1][:17]
|
||||
if process_name == "":
|
||||
process_name = "N/A"
|
||||
table_values += process_name.rjust(17)
|
||||
@@ -1079,7 +1079,7 @@ class AMDSMILogger():
|
||||
for process in output['processes']:
|
||||
gpu_id = str(process['gpu']).rjust(4)
|
||||
pid = str(process['pid']).rjust(9)
|
||||
process_name = str(process['name']).ljust(19)
|
||||
process_name = str(process['name']).split('/')[-1].ljust(19)
|
||||
gtt_mem = str(process['gtt']).rjust(8)
|
||||
vram_mem = str(process['vram']).rjust(8)
|
||||
mem_usage = str(process['mem_usage']).rjust(9)
|
||||
|
||||
@@ -126,7 +126,7 @@ amdsmi_status_t gpuvsmi_get_pid_info(const amdsmi_bdf_t &bdf, long int pid,
|
||||
static_cast<uint32_t>(bdf.function_number & 0x7));
|
||||
|
||||
std::string path = "/proc/" + std::to_string(pid) + "/fdinfo/";
|
||||
std::string name_path = "/proc/" + std::to_string(pid) + "/comm";
|
||||
std::string name_path = "/proc/" + std::to_string(pid) + "/exe";
|
||||
std::string cgroup_path = "/proc/" + std::to_string(pid) + "/cgroup";
|
||||
|
||||
if (gpuvsmi_pid_is_gpu(path.c_str(), bdf_str)) {
|
||||
@@ -189,10 +189,9 @@ amdsmi_status_t gpuvsmi_get_pid_info(const amdsmi_bdf_t &bdf, long int pid,
|
||||
|
||||
// Note: If possible at all, try to get the name of the process/container.
|
||||
// In case the other info fail, get at least something.
|
||||
std::ifstream filename(name_path.c_str());
|
||||
std::string name;
|
||||
|
||||
getline(filename, name);
|
||||
char exe_realpath[PATH_MAX] = {0};
|
||||
ssize_t len = readlink(name_path.c_str(), exe_realpath, sizeof(exe_realpath) - 1);
|
||||
std::string name = (len > 0) ? std::string(exe_realpath, len) : "N/A";
|
||||
|
||||
if (name.empty()) return AMDSMI_STATUS_API_FAILED;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user