mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 10:17:01 +08:00
Avoid deadlock when evicting unused allocations
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
48f01f28f5
commit
dc9bcb99c9
@@ -151,12 +151,12 @@ int BufferObject::exec(uint32_t used, size_t startOffset, unsigned int flags, bo
|
||||
int ret = this->drm->ioctl(DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
|
||||
|
||||
if (ret != 0) {
|
||||
static_cast<DrmMemoryOperationsHandler *>(this->drm->getRootDeviceEnvironment().memoryOperationsInterface.get())->evictUnusedAllocations(false);
|
||||
static_cast<DrmMemoryOperationsHandler *>(this->drm->getRootDeviceEnvironment().memoryOperationsInterface.get())->evictUnusedAllocations(false, true);
|
||||
ret = this->drm->ioctl(DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
static_cast<DrmMemoryOperationsHandler *>(this->drm->getRootDeviceEnvironment().memoryOperationsInterface.get())->evictUnusedAllocations(true);
|
||||
static_cast<DrmMemoryOperationsHandler *>(this->drm->getRootDeviceEnvironment().memoryOperationsInterface.get())->evictUnusedAllocations(true, true);
|
||||
ret = this->drm->ioctl(DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class DrmMemoryOperationsHandler : public MemoryOperationsHandler {
|
||||
virtual void mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) = 0;
|
||||
virtual std::unique_lock<std::mutex> lockHandlerIfUsed() = 0;
|
||||
|
||||
virtual void evictUnusedAllocations(bool waitForCompletion) = 0;
|
||||
virtual void evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded) = 0;
|
||||
|
||||
static std::unique_ptr<DrmMemoryOperationsHandler> create(Drm &drm, uint32_t rootDeviceIndex);
|
||||
|
||||
|
||||
@@ -110,10 +110,14 @@ std::unique_lock<std::mutex> DrmMemoryOperationsHandlerBind::lockHandlerIfUsed()
|
||||
return std::unique_lock<std::mutex>();
|
||||
}
|
||||
|
||||
void DrmMemoryOperationsHandlerBind::evictUnusedAllocations(bool waitForCompletion) {
|
||||
void DrmMemoryOperationsHandlerBind::evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded) {
|
||||
auto memoryManager = static_cast<DrmMemoryManager *>(this->rootDeviceEnvironment.executionEnvironment.memoryManager.get());
|
||||
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
std::unique_lock<std::mutex> evictLock(mutex, std::defer_lock);
|
||||
if (isLockNeeded) {
|
||||
evictLock.lock();
|
||||
}
|
||||
|
||||
auto allocLock = memoryManager->acquireAllocLock();
|
||||
|
||||
this->evictUnusedAllocationsImpl(memoryManager->getSysMemAllocs(), waitForCompletion);
|
||||
|
||||
@@ -25,7 +25,7 @@ class DrmMemoryOperationsHandlerBind : public DrmMemoryOperationsHandler {
|
||||
void mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) override;
|
||||
std::unique_lock<std::mutex> lockHandlerIfUsed() override;
|
||||
|
||||
void evictUnusedAllocations(bool waitForCompletion) override;
|
||||
void evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded) override;
|
||||
|
||||
protected:
|
||||
void evictImpl(OsContext *osContext, GraphicsAllocation &gfxAllocation, DeviceBitfield deviceBitfield);
|
||||
|
||||
@@ -64,7 +64,7 @@ std::unique_lock<std::mutex> DrmMemoryOperationsHandlerDefault::lockHandlerIfUse
|
||||
return std::unique_lock<std::mutex>();
|
||||
}
|
||||
|
||||
void DrmMemoryOperationsHandlerDefault::evictUnusedAllocations(bool waitForCompletion) {
|
||||
void DrmMemoryOperationsHandlerDefault::evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded) {
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -26,7 +26,7 @@ class DrmMemoryOperationsHandlerDefault : public DrmMemoryOperationsHandler {
|
||||
void mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) override;
|
||||
std::unique_lock<std::mutex> lockHandlerIfUsed() override;
|
||||
|
||||
void evictUnusedAllocations(bool waitForCompletion) override;
|
||||
void evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded) override;
|
||||
|
||||
protected:
|
||||
std::unordered_set<GraphicsAllocation *> residency;
|
||||
|
||||
Reference in New Issue
Block a user