* [PATCH 1/1] kfdtest: Also detect under-reporting of available memory
@ 2022-10-31 15:08 Daniel Phillips
0 siblings, 0 replies; only message in thread
From: Daniel Phillips @ 2022-10-31 15:08 UTC (permalink / raw)
To: amd-gfx; +Cc: Daniel Phillips, felix.kuehling
Detect under-reporting of available memory by initially attempting to
allocate substantially more than reported available memory, and ensure
that the allocation fails. Continue shrinking the attempted allocation
until it succeeds, then fail the test if the successful allocation is
either too much more than or too much less than reported available.
Signed-off-by: Daniel Phillips <daniel.phillips@amd.com>
Change-Id: Ib418f0aa26e8db80590a6c5f2578da56a4b60f2b
---
tests/kfdtest/src/KFDMemoryTest.cpp | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/tests/kfdtest/src/KFDMemoryTest.cpp b/tests/kfdtest/src/KFDMemoryTest.cpp
index b4cb37a..f6affec 100644
--- a/tests/kfdtest/src/KFDMemoryTest.cpp
+++ b/tests/kfdtest/src/KFDMemoryTest.cpp
@@ -252,23 +252,32 @@ TEST_F(KFDMemoryTest, MemoryAlloc) {
// Basic test for hsaKmtAllocMemory
TEST_F(KFDMemoryTest, MemoryAllocAll) {
TEST_START(TESTPROFILE_RUNALL)
-
int defaultGPUNode = m_NodeInfo.HsaDefaultGPUNode();
HsaMemFlags memFlags = {0};
memFlags.ui32.NonPaged = 1; // sys mem vs vram
HSAuint64 available;
void *object = NULL;
int shrink = 21, success = HSAKMT_STATUS_NO_MEMORY;
-
EXPECT_SUCCESS(hsaKmtAvailableMemory(defaultGPUNode, &available));
LOG() << "Available: " << available << " bytes" << std::endl;
+ HSAuint64 leeway = (10 << shrink), size = available + leeway;
for (int i = 0; i < available >> shrink; i++) {
- HSAuint64 size = available - ((HSAuint64)i << shrink);
if (hsaKmtAllocMemory(defaultGPUNode, size, memFlags, &object) == HSAKMT_STATUS_SUCCESS) {
- LOG() << "Allocated: " << size << " bytes" << std::endl;
success = hsaKmtFreeMemory(object, available);
break;
}
+ size -= (1 << shrink);
+ }
+ if (success == HSAKMT_STATUS_SUCCESS) {
+ LOG() << "Allocated: " << size << " bytes" << std::endl;
+ if (size > available + leeway) {
+ LOG() << "Under-reported available memory!" << std::endl;
+ success = HSAKMT_STATUS_ERROR;
+ }
+ if (size < available - leeway) {
+ LOG() << "Over-reported available memory!" << std::endl;
+ success = HSAKMT_STATUS_NO_MEMORY;
+ }
}
EXPECT_SUCCESS(success);
TEST_END
--
2.35.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-31 15:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-31 15:08 [PATCH 1/1] kfdtest: Also detect under-reporting of available memory Daniel Phillips
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox