mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
fix: add cpu alloc to eviction list only once
Related-To: NEO-12572 Also, before migration to GPU domain, remove it from this list Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9db83b8231
commit
b2fd1972a4
@@ -73,6 +73,7 @@ void PageFaultManager::moveAllocationsWithinUMAllocsManagerToGpuDomain(SVMAllocs
|
||||
inline void PageFaultManager::migrateStorageToGpuDomain(void *ptr, PageFaultData &pageFaultData) {
|
||||
if (pageFaultData.domain == AllocationDomain::cpu) {
|
||||
this->setCpuAllocEvictable(false, ptr, pageFaultData.unifiedMemoryManager);
|
||||
this->allowCPUMemoryEviction(false, ptr, pageFaultData);
|
||||
|
||||
std::chrono::steady_clock::time_point start;
|
||||
std::chrono::steady_clock::time_point end;
|
||||
@@ -117,7 +118,7 @@ void PageFaultManager::transferAndUnprotectMemory(PageFaultManager *pageFaultHan
|
||||
pageFaultHandler->migrateStorageToCpuDomain(allocPtr, pageFaultData);
|
||||
pageFaultHandler->allowCPUMemoryAccess(allocPtr, pageFaultData.size);
|
||||
pageFaultHandler->setCpuAllocEvictable(true, allocPtr, pageFaultData.unifiedMemoryManager);
|
||||
pageFaultHandler->allowCPUMemoryEviction(allocPtr, pageFaultData);
|
||||
pageFaultHandler->allowCPUMemoryEviction(true, allocPtr, pageFaultData);
|
||||
}
|
||||
|
||||
void PageFaultManager::unprotectAndTransferMemory(PageFaultManager *pageFaultHandler, void *allocPtr, PageFaultData &pageFaultData) {
|
||||
|
||||
@@ -57,13 +57,13 @@ class PageFaultManager : public NonCopyableOrMovableClass {
|
||||
virtual bool checkFaultHandlerFromPageFaultManager() = 0;
|
||||
virtual void registerFaultHandler() = 0;
|
||||
virtual void evictMemoryAfterImplCopy(GraphicsAllocation *allocation, Device *device) = 0;
|
||||
virtual void allowCPUMemoryEvictionImpl(void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) = 0;
|
||||
virtual void allowCPUMemoryEvictionImpl(bool evict, void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) = 0;
|
||||
|
||||
MOCKABLE_VIRTUAL bool verifyPageFault(void *ptr);
|
||||
MOCKABLE_VIRTUAL void transferToGpu(void *ptr, void *cmdQ);
|
||||
MOCKABLE_VIRTUAL void setAubWritable(bool writable, void *ptr, SVMAllocsManager *unifiedMemoryManager);
|
||||
MOCKABLE_VIRTUAL void setCpuAllocEvictable(bool evictable, void *ptr, SVMAllocsManager *unifiedMemoryManager);
|
||||
MOCKABLE_VIRTUAL void allowCPUMemoryEviction(void *ptr, PageFaultData &pageFaultData);
|
||||
MOCKABLE_VIRTUAL void allowCPUMemoryEviction(bool evict, void *ptr, PageFaultData &pageFaultData);
|
||||
|
||||
static void transferAndUnprotectMemory(PageFaultManager *pageFaultHandler, void *alloc, PageFaultData &pageFaultData);
|
||||
static void unprotectAndTransferMemory(PageFaultManager *pageFaultHandler, void *alloc, PageFaultData &pageFaultData);
|
||||
|
||||
@@ -97,6 +97,6 @@ void PageFaultManagerLinux::evictMemoryAfterImplCopy(GraphicsAllocation *allocat
|
||||
}
|
||||
}
|
||||
|
||||
void PageFaultManagerLinux::allowCPUMemoryEvictionImpl(void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) {}
|
||||
void PageFaultManagerLinux::allowCPUMemoryEvictionImpl(bool evict, void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) {}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -25,7 +25,7 @@ class PageFaultManagerLinux : public PageFaultManager {
|
||||
void protectCPUMemoryAccess(void *ptr, size_t size) override;
|
||||
|
||||
void evictMemoryAfterImplCopy(GraphicsAllocation *allocation, Device *device) override;
|
||||
void allowCPUMemoryEvictionImpl(void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) override;
|
||||
void allowCPUMemoryEvictionImpl(bool evict, void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) override;
|
||||
|
||||
bool checkFaultHandlerFromPageFaultManager() override;
|
||||
void registerFaultHandler() override;
|
||||
|
||||
@@ -69,7 +69,7 @@ void PageFaultManagerWindows::protectCPUMemoryAccess(void *ptr, size_t size) {
|
||||
|
||||
void PageFaultManagerWindows::evictMemoryAfterImplCopy(GraphicsAllocation *allocation, Device *device) {}
|
||||
|
||||
void PageFaultManagerWindows::allowCPUMemoryEvictionImpl(void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) {
|
||||
void PageFaultManagerWindows::allowCPUMemoryEvictionImpl(bool evict, void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) {
|
||||
NEO::SvmAllocationData *allocData = memoryData[ptr].unifiedMemoryManager->getSVMAlloc(ptr);
|
||||
UNRECOVERABLE_IF(allocData == nullptr);
|
||||
|
||||
@@ -77,7 +77,14 @@ void PageFaultManagerWindows::allowCPUMemoryEvictionImpl(void *ptr, CommandStrea
|
||||
auto &residencyController = static_cast<OsContextWin *>(&csr.getOsContext())->getResidencyController();
|
||||
|
||||
auto lock = residencyController.acquireLock();
|
||||
csr.getEvictionAllocations().push_back(allocData->cpuAllocation);
|
||||
auto &evictContainer = csr.getEvictionAllocations();
|
||||
auto iter = std::find(evictContainer.begin(), evictContainer.end(), allocData->cpuAllocation);
|
||||
auto allocInEvictionList = iter != evictContainer.end();
|
||||
if (evict && !allocInEvictionList) {
|
||||
evictContainer.push_back(allocData->cpuAllocation);
|
||||
} else if (!evict && allocInEvictionList) {
|
||||
evictContainer.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2023 Intel Corporation
|
||||
* Copyright (C) 2019-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -25,7 +25,7 @@ class PageFaultManagerWindows : public PageFaultManager {
|
||||
void protectCPUMemoryAccess(void *ptr, size_t size) override;
|
||||
|
||||
void evictMemoryAfterImplCopy(GraphicsAllocation *allocation, Device *device) override;
|
||||
void allowCPUMemoryEvictionImpl(void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) override;
|
||||
void allowCPUMemoryEvictionImpl(bool evict, void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) override;
|
||||
|
||||
bool checkFaultHandlerFromPageFaultManager() override;
|
||||
void registerFaultHandler() override;
|
||||
|
||||
Reference in New Issue
Block a user