Handle un-readable kfd properties files
Some systems have kfd sysfs properties entries that are unreadable--for example, when a multi-gpu system is dividing the gpus among containers, each container may only be able to access certain gpus. Previously, all kfd topology node properties entries were assumed to be valid. Now, we check for readability before declaring them "valid". Fixes SWDEV-240169 Also: * remove an assertion that would happen when no pcie device identifier files are found on the system. * fix cpplint issues Change-Id: I74321b685159dd2628c890b33c39ad82988cb9dd
This commit is contained in:
@@ -1545,9 +1545,6 @@ static rsmi_status_t get_dev_name_from_id(uint32_t dv_ind, char *name,
|
||||
}
|
||||
|
||||
if (val_str.size() == 0) {
|
||||
// We should have already returned if we were looking for
|
||||
// device or subdivce
|
||||
assert(typ == NAME_STR_VENDOR);
|
||||
return get_backup_name(vendor_id, name, len);
|
||||
}
|
||||
size_t ct = val_str.copy(name, len);
|
||||
|
||||
+23
-1
@@ -154,6 +154,22 @@ static int OpenKFDNodeFile(uint32_t dev_id, std::string node_file,
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool KFDNodeSupported(uint32_t node_indx) {
|
||||
std::ifstream fs;
|
||||
bool ret = true;
|
||||
int err;
|
||||
err = OpenKFDNodeFile(node_indx, "properties", &fs);
|
||||
|
||||
if (err == ENOENT) {
|
||||
return false;
|
||||
}
|
||||
if (fs.peek() == std::ifstream::traits_type::eof()) {
|
||||
ret = false;
|
||||
}
|
||||
fs.close();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ReadKFDDeviceProperties(uint32_t kfd_node_id,
|
||||
std::vector<std::string> *retVec) {
|
||||
std::string line;
|
||||
@@ -175,7 +191,7 @@ int ReadKFDDeviceProperties(uint32_t kfd_node_id,
|
||||
|
||||
if (retVec->size() == 0) {
|
||||
fs.close();
|
||||
return 0;
|
||||
return ENOENT;
|
||||
}
|
||||
// Remove any *trailing* empty (whitespace) lines
|
||||
while (retVec->back().find_first_not_of(" \t\n\v\f\r") == std::string::npos) {
|
||||
@@ -471,6 +487,12 @@ int DiscoverKFDNodes(std::map<uint64_t, std::shared_ptr<KFDNode>> *nodes) {
|
||||
}
|
||||
|
||||
node_indx = std::stoi(dentry->d_name);
|
||||
|
||||
if (!KFDNodeSupported(node_indx)) {
|
||||
dentry = readdir(kfd_node_dir);
|
||||
continue;
|
||||
}
|
||||
|
||||
node = std::shared_ptr<KFDNode>(new KFDNode(node_indx));
|
||||
|
||||
node->Initialize();
|
||||
|
||||
@@ -293,6 +293,18 @@ RocmSMI::Initialize(uint64_t flags) {
|
||||
|
||||
std::shared_ptr<amd::smi::Device> dev;
|
||||
|
||||
// Remove any drm nodes that don't have a corresponding readable kfd node.
|
||||
// kfd nodes will not be added if their properties file is not readable.
|
||||
auto dev_iter = monitor_devices_.begin();
|
||||
while (dev_iter != monitor_devices_.end()) {
|
||||
uint64_t bdfid = (*dev_iter)->bdfid();
|
||||
if (tmp_map.find(bdfid) == tmp_map.end()) {
|
||||
dev_iter = monitor_devices_.erase(dev_iter);
|
||||
continue;
|
||||
}
|
||||
dev_iter++;
|
||||
}
|
||||
|
||||
// 1. construct kfd_node_map_ with gpu_id as key and *Device as value
|
||||
// 2. for each kfd node, write the corresponding dv_ind
|
||||
// 3. for each amdgpu device, write the corresponding gpu_id
|
||||
|
||||
Reference in New Issue
Block a user