mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 00:24:58 +08:00
fix: mem alloc size tracking safety
Make sure local mem alloc size atomic array is initialized with 0. Add debug breaks to catch possible overflow on unregistering allocations. Related-To: NEO-11356 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a1a13475c7
commit
e9e6cc05e3
@@ -78,6 +78,7 @@ MemoryManager::MemoryManager(ExecutionEnvironment &executionEnvironment) : execu
|
||||
|
||||
auto globalHeap = ApiSpecificConfig::getGlobalBindlessHeapConfiguration(rootDeviceEnvironment.getReleaseHelper());
|
||||
heapAssigners.push_back(std::make_unique<HeapAssigner>(globalHeap));
|
||||
localMemAllocsSize[rootDeviceIndex].store(0u);
|
||||
}
|
||||
|
||||
if (anyLocalMemorySupported) {
|
||||
|
||||
@@ -1569,8 +1569,10 @@ AllocationStatus DrmMemoryManager::registerLocalMemAlloc(GraphicsAllocation *all
|
||||
|
||||
void DrmMemoryManager::unregisterAllocation(GraphicsAllocation *allocation) {
|
||||
if (allocation->isAllocatedInLocalMemoryPool()) {
|
||||
DEBUG_BREAK_IF(allocation->getUnderlyingBufferSize() > localMemAllocsSize[allocation->getRootDeviceIndex()]);
|
||||
localMemAllocsSize[allocation->getRootDeviceIndex()] -= allocation->getUnderlyingBufferSize();
|
||||
} else if (MemoryPool::memoryNull != allocation->getMemoryPool()) {
|
||||
DEBUG_BREAK_IF(allocation->getUnderlyingBufferSize() > sysMemAllocsSize);
|
||||
sysMemAllocsSize -= allocation->getUnderlyingBufferSize();
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(this->allocMutex);
|
||||
|
||||
@@ -787,8 +787,10 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
|
||||
}
|
||||
|
||||
if (gfxAllocation->isAllocatedInLocalMemoryPool()) {
|
||||
DEBUG_BREAK_IF(gfxAllocation->getUnderlyingBufferSize() > localMemAllocsSize[gfxAllocation->getRootDeviceIndex()]);
|
||||
localMemAllocsSize[gfxAllocation->getRootDeviceIndex()] -= gfxAllocation->getUnderlyingBufferSize();
|
||||
} else if (MemoryPool::memoryNull != gfxAllocation->getMemoryPool()) {
|
||||
DEBUG_BREAK_IF(gfxAllocation->getUnderlyingBufferSize() > sysMemAllocsSize);
|
||||
sysMemAllocsSize -= gfxAllocation->getUnderlyingBufferSize();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user