kfdtest: Full TearDown and SetUp in child process

With the next patch, child processes need to fully reinitialize the
topology in order to recreate the process apertures. Just calling
hsaKmtOpenKFD is no longer sufficient. Tests based on
KFDMultiProcessTest already did this correctly (KFDHWSTest, eviction
tests). This patch fixes KFDExceptionTest and KFDIPCTest.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Change-Id: Iaad24e88ddd29c1105bf791a77891cc55a6072ff


[ROCm/ROCR-Runtime commit: 412b24137e]
Этот коммит содержится в:
Felix Kuehling
2022-07-14 16:45:12 -04:00
родитель 93e7565163
Коммит 7ccda4ba26
3 изменённых файлов: 20 добавлений и 24 удалений
+10 -20
Просмотреть файл
@@ -184,11 +184,8 @@ TEST_F(KFDExceptionTest, AddressFault) {
m_ChildPid = fork();
if (m_ChildPid == 0) {
m_ChildStatus = hsaKmtOpenKFD();
if (m_ChildStatus != HSAKMT_STATUS_SUCCESS) {
WARN() << "KFD open failed in child process" << std::endl;
return;
}
KFDBaseComponentTest::TearDown();
KFDBaseComponentTest::SetUp();
HsaMemoryBuffer srcBuffer(PAGE_SIZE, defaultGPUNode, false);
@@ -228,11 +225,8 @@ TEST_F(KFDExceptionTest, PermissionFault) {
m_ChildPid = fork();
if (m_ChildPid == 0) {
m_ChildStatus = hsaKmtOpenKFD();
if (m_ChildStatus != HSAKMT_STATUS_SUCCESS) {
WARN() << "KFD open failed in child process" << std::endl;
return;
}
KFDBaseComponentTest::TearDown();
KFDBaseComponentTest::SetUp();
HsaMemoryBuffer readOnlyBuffer(PAGE_SIZE, defaultGPUNode, false /*zero*/,
false /*isLocal*/, true /*isExec*/,
@@ -278,11 +272,8 @@ TEST_F(KFDExceptionTest, FaultStorm) {
m_ChildPid = fork();
if (m_ChildPid == 0) {
m_ChildStatus = hsaKmtOpenKFD();
if (m_ChildStatus != HSAKMT_STATUS_SUCCESS) {
WARN() << "KFD open failed in child process" << std::endl;
return;
}
KFDBaseComponentTest::TearDown();
KFDBaseComponentTest::SetUp();
TestMemoryException(defaultGPUNode, 0x12345678, 0x76543210, 1024, 1024, 1);
} else {
@@ -321,11 +312,10 @@ TEST_F(KFDExceptionTest, SdmaQueueException) {
if (m_ChildPid == 0) {
unsigned int* pDb = NULL;
unsigned int *nullPtr = NULL;
m_ChildStatus = hsaKmtOpenKFD();
if (m_ChildStatus != HSAKMT_STATUS_SUCCESS) {
WARN() << "KFD open failed in child process" << std::endl;
return;
}
KFDBaseComponentTest::TearDown();
KFDBaseComponentTest::SetUp();
m_MemoryFlags.ui32.NonPaged = 1;
ASSERT_SUCCESS(hsaKmtAllocMemory(defaultGPUNode, PAGE_SIZE, m_MemoryFlags,
reinterpret_cast<void**>(&pDb)));
+4 -1
Просмотреть файл
@@ -42,8 +42,11 @@ class KFDExceptionTest : public KFDBaseComponentTest {
* child process finishes, gtest assumes the test has finished and
* starts the next test while the parent is still active.
*/
if (m_ChildPid == 0)
if (m_ChildPid == 0) {
if (!m_ChildStatus && HasFatalFailure())
m_ChildStatus = HSAKMT_STATUS_ERROR;
exit(m_ChildStatus);
}
}
protected:
+6 -3
Просмотреть файл
@@ -70,8 +70,8 @@ void KFDIPCTest::BasicTestChildProcess(int defaultGPUNode, int *pipefd, HsaMemFl
/* Open KFD device for child process. This needs to called before
* any memory definitions
*/
if (HSAKMT_STATUS_SUCCESS != hsaKmtOpenKFD())
exit(1);
TearDown();
SetUp();
SDMAQueue sdmaQueue;
HsaSharedMemoryHandle sharedHandleLM;
@@ -635,7 +635,10 @@ TEST_F(KFDIPCTest, CrossMemoryAttachTest) {
/* Create a child process and share the above Local Memory with it */
m_ChildPid = fork();
if (m_ChildPid == 0 && hsaKmtOpenKFD() == HSAKMT_STATUS_SUCCESS) {
if (m_ChildPid == 0) {
TearDown();
SetUp();
/* Child Process */
status = CrossMemoryAttachChildProcess(defaultGPUNode, pipeCtoP[1],
pipePtoC[0], CMA_READ_TEST);