wsl/hsakmt: Remove pre-allocation free memory check
This change removes the check for sufficient free memory before allocation. The previous check could cause performance degradation. Reserving a portion of system memory helps prevent system hangs due to insufficient memory. However, if free memory is still insufficient, memory allocation may still lead to system hangs. Signed-off-by: lyndonli <Lyndon.Li@amd.com> Reviewed-by: Flora Cui <flora.cui@amd.com> Part-of: <http://10.67.69.192/wsl/libhsakmt/-/merge_requests/10>
This commit is contained in:
+3
-16
@@ -105,18 +105,6 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtAllocMemory(HSAuint32 PreferredNode,
|
||||
|
||||
#define POWER_OF_2(x) ((x && (!(x & (x - 1)))) ? 1 : 0)
|
||||
|
||||
bool isSystemMemoryAvailable(HSAuint64 SizeInBytes) {
|
||||
struct sysinfo info;
|
||||
if (sysinfo(&info) != 0)
|
||||
return false;
|
||||
return SizeInBytes <= info.freeram;
|
||||
}
|
||||
|
||||
bool isLocalMemoryAvailable(wsl::thunk::WDDMDevice *dev,
|
||||
HSAuint64 SizeInBytes) {
|
||||
return SizeInBytes <= dev->VramAvail();
|
||||
}
|
||||
|
||||
HSAKMT_STATUS HSAKMTAPI hsaKmtAllocMemoryAlign(HSAuint32 PreferredNode,
|
||||
HSAuint64 SizeInBytes,
|
||||
HSAuint64 Alignment,
|
||||
@@ -149,17 +137,16 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtAllocMemoryAlign(HSAuint32 PreferredNode,
|
||||
create_info.va_hint = reinterpret_cast<gpusize>(*MemoryAddress);
|
||||
if ((PreferredNode == 0 && !MemFlags.ui32.NonPaged)
|
||||
|| zfb_support || MemFlags.ui32.GTTAccess) {
|
||||
if (SizeInBytes > max_single_alloc_size)
|
||||
return HSAKMT_STATUS_NO_MEMORY;
|
||||
|
||||
/* If allocate VRAM under ZFB mode */
|
||||
if (zfb_support && MemFlags.ui32.NonPaged == 1)
|
||||
MemFlags.ui32.CoarseGrain = 1;
|
||||
|
||||
create_info.domain = rocr_proxy::AllocDomain::kSystem;
|
||||
if (!MemFlags.ui32.OnlyAddress && !isSystemMemoryAvailable(SizeInBytes))
|
||||
return HSAKMT_STATUS_NO_MEMORY;
|
||||
} else {
|
||||
create_info.domain = rocr_proxy::AllocDomain::kLocal;
|
||||
if (!MemFlags.ui32.OnlyAddress && !isLocalMemoryAvailable(dev, SizeInBytes))
|
||||
return HSAKMT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (!MemFlags.ui32.CoarseGrain)
|
||||
|
||||
مرجع در شماره جدید
Block a user