mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
fix: avoid race when evicting resources
Related-To: NEO-13843 DrmMemoryOperationsHandler::mutex is used for residency handling. However, this mutex is not being locked during eviction when vm bind failed. This is causing races for example when ULLS controller wants to make resources resident, and user thread wants to evict them. Fix is to explicitly obtain lock in problematic path. Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
14a8cbf5a8
commit
f08b32761e
@@ -326,6 +326,7 @@ int BufferObject::pin(BufferObject *const boToPin[], size_t numberOfBos, OsConte
|
||||
auto retVal = 0;
|
||||
|
||||
if (this->drm->isVmBindAvailable()) {
|
||||
auto lock = static_cast<DrmMemoryOperationsHandler *>(this->drm->getRootDeviceEnvironment().memoryOperationsInterface.get())->lockHandlerIfUsed();
|
||||
retVal = bindBOsWithinContext(boToPin, numberOfBos, osContext, vmHandleId, false);
|
||||
} else {
|
||||
StackVec<ExecObject, maxFragmentsCount + 1> execObject(numberOfBos + 1);
|
||||
@@ -339,6 +340,7 @@ int BufferObject::validateHostPtr(BufferObject *const boToPin[], size_t numberOf
|
||||
auto retVal = 0;
|
||||
|
||||
if (this->drm->isVmBindAvailable()) {
|
||||
auto lock = static_cast<DrmMemoryOperationsHandler *>(this->drm->getRootDeviceEnvironment().memoryOperationsInterface.get())->lockHandlerIfUsed();
|
||||
for (size_t i = 0; i < numberOfBos; i++) {
|
||||
retVal = boToPin[i]->bind(osContext, vmHandleId, false);
|
||||
if (retVal) {
|
||||
|
||||
@@ -157,7 +157,7 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::mergeWithResidencyContain
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> DrmMemoryOperationsHandlerBind::lockHandlerIfUsed() {
|
||||
return std::unique_lock<std::mutex>();
|
||||
return std::unique_lock<std::mutex>(mutex);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded) {
|
||||
|
||||
Reference in New Issue
Block a user