mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
fix(sysman): fixes multithread access issue with FSAccess
Related-To: NEO-9720 Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a2994e9b29
commit
b33d9955a1
@@ -45,7 +45,6 @@ void FdCacheInterface::eraseLeastUsedEntryFromCache() {
|
||||
}
|
||||
|
||||
int FdCacheInterface::getFd(std::string file) {
|
||||
std::unique_lock<std::mutex> lock(fdMutex);
|
||||
int fd = -1;
|
||||
if (fdMap.find(file) == fdMap.end()) {
|
||||
fd = NEO::SysCalls::open(file.c_str(), O_RDONLY);
|
||||
@@ -72,6 +71,7 @@ FdCacheInterface::~FdCacheInterface() {
|
||||
|
||||
template <typename T>
|
||||
ze_result_t FsAccessInterface::readValue(const std::string file, T &val) {
|
||||
auto lock = this->obtainMutex();
|
||||
|
||||
std::string readVal(64, '\0');
|
||||
int fd = pFdCacheInterface->getFd(file);
|
||||
@@ -303,6 +303,10 @@ bool FsAccessInterface::directoryExists(const std::string path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> FsAccessInterface::obtainMutex() {
|
||||
return std::unique_lock<std::mutex>(this->fsMutex);
|
||||
}
|
||||
|
||||
// Procfs Access
|
||||
ProcFsAccessInterface::ProcFsAccessInterface() = default;
|
||||
ProcFsAccessInterface::~ProcFsAccessInterface() = default;
|
||||
|
||||
@@ -32,7 +32,6 @@ class FdCacheInterface {
|
||||
std::map<std::string, std::pair<int, uint32_t>> fdMap = {};
|
||||
|
||||
private:
|
||||
std::mutex fdMutex{};
|
||||
void eraseLeastUsedEntryFromCache();
|
||||
};
|
||||
|
||||
@@ -65,11 +64,13 @@ class FsAccessInterface {
|
||||
|
||||
protected:
|
||||
FsAccessInterface();
|
||||
MOCKABLE_VIRTUAL std::unique_lock<std::mutex> obtainMutex();
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
ze_result_t readValue(const std::string file, T &val);
|
||||
std::unique_ptr<FdCacheInterface> pFdCacheInterface = nullptr;
|
||||
std::mutex fsMutex{};
|
||||
};
|
||||
|
||||
class ProcFsAccessInterface : private FsAccessInterface {
|
||||
|
||||
Reference in New Issue
Block a user