From 7a310f2e9167272182e43a5ff7435826d9a1b465 Mon Sep 17 00:00:00 2001 From: Shweta Khatri Date: Mon, 5 Feb 2024 12:55:13 -0500 Subject: [PATCH] Set max_alloc to 95%,reduce by 1% on fail Prevents OOM-Killer trigger,if all physical and swap mem gets fully used Change-Id: I70d558fa9c06fe6217e62d57e11aec6a089aa0bb [ROCm/ROCR-Runtime commit: 13800cc6d56c9f3d5dda0cf6c73593cb5e8f8be1] --- .../rocrtst/suites/functional/memory_basic.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/projects/rocr-runtime/rocrtst/suites/functional/memory_basic.cc b/projects/rocr-runtime/rocrtst/suites/functional/memory_basic.cc index 24f2c94da1..3fab9add05 100644 --- a/projects/rocr-runtime/rocrtst/suites/functional/memory_basic.cc +++ b/projects/rocr-runtime/rocrtst/suites/functional/memory_basic.cc @@ -233,7 +233,10 @@ void MemoryTest::MaxSingleAllocationTest(hsa_agent_t ag, std::min(pool_sz, info.totalram / gran_sz) : pool_sz; - uint64_t upper_bound = pool_sz; + // Reduce upper_bound by 5% for system-RAM. Otherwise Linux OOM-Killer app can be triggered, + // if system has allocated all available physical memory and swap space, and so killing this + // process. + uint64_t upper_bound = (ag_type == HSA_DEVICE_TYPE_CPU) ? (pool_sz * 0.95) : pool_sz; uint64_t lower_bound = 0; auto max_alloc_size = upper_bound; @@ -247,7 +250,8 @@ void MemoryTest::MaxSingleAllocationTest(hsa_agent_t ag, } else if (err == HSA_STATUS_ERROR_OUT_OF_RESOURCES || err == HSA_STATUS_ERROR_INVALID_ALLOCATION) { upper_bound = max_alloc_size; - max_alloc_size -= 1; + max_alloc_size = + static_cast(max_alloc_size * 0.99); // Reduce by 1% in each iteration } ASSERT_GT(upper_bound, lower_bound);