From 4066dcd542ac4ec7f49359fb1e61c61388e172d5 Mon Sep 17 00:00:00 2001 From: Philip Yang Date: Thu, 13 Jun 2019 15:46:05 -0400 Subject: [PATCH] kfdtest: increase BigBufStressTest timeout and avoid VM fault If TTM eviction and restore happens, it may takes very long time if retry, the longest time is 5 minutes during my test. There is chance packet is submited to queue while eviction, we have to increase the Wait4PacketConsumption timeout. The queue will continue to execute after eviction and restore. If we upmap the memory from GPU while queue is evicted, this will cause VM fault. Change to unmap memory after queue is destroyed. Change-Id: I1b44e2274ea7b83398b2e3293578dad6947cb5af Signed-off-by: Philip Yang --- tests/kfdtest/src/KFDMemoryTest.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/kfdtest/src/KFDMemoryTest.cpp b/tests/kfdtest/src/KFDMemoryTest.cpp index bc076f73f1..99f53563cd 100644 --- a/tests/kfdtest/src/KFDMemoryTest.cpp +++ b/tests/kfdtest/src/KFDMemoryTest.cpp @@ -879,10 +879,11 @@ TEST_F(KFDMemoryTest, BigBufferStressTest) { HSAuint64 block_size_mb = 128; HSAuint64 block_size = block_size_mb * 1024 * 1024; PM4Queue queue; - ASSERT_SUCCESS(queue.Create(defaultGPUNode)); /* Test 4 times to see if there is any memory leak.*/ for (int repeat = 1; repeat < 5; repeat++) { + ASSERT_SUCCESS(queue.Create(defaultGPUNode)); + for (i = 0; i < ARRAY_ENTRIES; i++) { ret = hsaKmtAllocMemory(0 /* system */, block_size, m_MemoryFlags, reinterpret_cast(&pDb_array[i])); @@ -904,20 +905,23 @@ TEST_F(KFDMemoryTest, BigBufferStressTest) { allocationCount = i; EXPECT_GE(i, allocationCount) << "There might be memory leak!" << std::endl; - while (i--) { + for (int j = 0; j < i; j++) { /* To see if GPU can access the memory correctly*/ - unsigned int *begin = pDb_array[i]; + unsigned int *begin = pDb_array[j]; *begin = 0; queue.PlaceAndSubmitPacket( PM4WriteDataPacket(begin, 0xdeadbeaf)); - queue.Wait4PacketConsumption(); + queue.Wait4PacketConsumption(NULL, 300000); EXPECT_TRUE(WaitOnValue(begin, 0xdeadbeaf)); + } - EXPECT_SUCCESS(hsaKmtUnmapMemoryToGPU(pDb_array[i])); - EXPECT_SUCCESS(hsaKmtFreeMemory(pDb_array[i], block_size)); + EXPECT_SUCCESS(queue.Destroy()); + + for (int j = 0; j < i; j++) { + EXPECT_SUCCESS(hsaKmtUnmapMemoryToGPU(pDb_array[j])); + EXPECT_SUCCESS(hsaKmtFreeMemory(pDb_array[j], block_size)); } } - EXPECT_SUCCESS(queue.Destroy()); /* Reset to run on all task nodes */ NumaNodeBind("all");