Improve mmap logic in createAllocWithAlignment

Unmap trailing extra memory right away.

Related-To: NEO-6417

Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2022-01-19 18:51:35 +00:00
committed by Compute-Runtime-Automation
parent a7455b5767
commit 170fd00d24
3 changed files with 6 additions and 5 deletions

View File

@ -964,7 +964,7 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenAlignmentAndSizeWhenMmapReturnsU
auto allocation = memoryManager->createAllocWithAlignment(allocationData, MemoryConstants::pageSize, MemoryConstants::pageSize64k, MemoryConstants::pageSize64k, 0u);
EXPECT_EQ(alignUp(reinterpret_cast<void *>(0x12345678), MemoryConstants::pageSize64k), allocation->getMmapPtr());
EXPECT_EQ(0u, munmapCalledCount);
EXPECT_EQ(1u, munmapCalledCount);
memoryManager->freeGraphicsMemory(allocation);
EXPECT_EQ(3u, munmapCalledCount);
munmapCalledCount = 0u;
@ -999,10 +999,10 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenAlignmentAndSizeWhenMmapReturnsA
};
munmapCalledCount = 0u;
auto allocation = memoryManager->createAllocWithAlignment(allocationData, MemoryConstants::pageSize, 1u, MemoryConstants::pageSize64k, 0u);
auto allocation = memoryManager->createAllocWithAlignment(allocationData, MemoryConstants::pageSize, 4u, MemoryConstants::pageSize64k, 0u);
EXPECT_EQ(reinterpret_cast<void *>(0x12345678), allocation->getMmapPtr());
EXPECT_EQ(0u, munmapCalledCount);
EXPECT_EQ(1u, munmapCalledCount);
memoryManager->freeGraphicsMemory(allocation);
EXPECT_EQ(2u, munmapCalledCount);
munmapCalledCount = 0u;