From 95ec7d5c27929ac7cd0c2c79e8e91cd268899306 Mon Sep 17 00:00:00 2001 From: tiancyin Date: Fri, 9 May 2025 14:50:34 +0800 Subject: [PATCH] wsl/libhsakmt: remove suballocator's lock Signed-off-by: tiancyin Reviewed-by: Flora Cui Part-of: --- memory.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/memory.cpp b/memory.cpp index 57b7710fc7..2436776ee0 100644 --- a/memory.cpp +++ b/memory.cpp @@ -136,16 +136,12 @@ void BlockAllocator::free(void* ptr, size_t length) const { } static wsl::SimpleHeap fragment_allocator_; -static std::unique_ptr fragment_allocator_lock_ = std::make_unique(); void reset_suballocator(void) { - fragment_allocator_lock_ = std::make_unique(); - std::lock_guard lock(*fragment_allocator_lock_); fragment_allocator_.reset(); } void trim_suballocator(void) { - std::lock_guard lock(*fragment_allocator_lock_); fragment_allocator_.trim(); } @@ -223,8 +219,6 @@ HSAKMT_STATUS hsaKmtAllocMemoryAlignInternal(HSAuint32 PreferredNode, /* Only allow using the suballocator for ordinary VRAM.*/ bool trim_safe = false; if (!SkipSubAlloc && create_info.domain == thunk_proxy::AllocDomain::kLocal) { - std::lock_guard gard(*fragment_allocator_lock_); - /* just quickly skip SA if size is bigger than SA block size.*/ gpusize real_size; if (create_info.size > GPU_HUGE_PAGE_SIZE) @@ -262,7 +256,6 @@ after_trim: return HSAKMT_STATUS_SUCCESS; } else if (trim_safe) { /* attempt to release memory from the block allocator and retry */ - std::lock_guard gard(*fragment_allocator_lock_); fragment_allocator_.trim(); trim_safe = false; goto after_trim; @@ -291,7 +284,6 @@ HSAKMT_STATUS hsaKmtFreeMemoryInternal(void *MemoryAddress, return HSAKMT_STATUS_INVALID_PARAMETER; if (!SkipSubAlloc) { - std::lock_guard gard(*fragment_allocator_lock_); if (fragment_allocator_.free(MemoryAddress)) return HSAKMT_STATUS_SUCCESS; } @@ -645,7 +637,6 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtMapMemoryToGPU(void *MemoryAddress, size_t aligned_size = end - start; { - std::lock_guard gard(*fragment_allocator_lock_); if (nullptr != fragment_allocator_.block_base(aligned_ptr)) return HSAKMT_STATUS_SUCCESS; } @@ -755,7 +746,6 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtUnmapMemoryToGPU(void *MemoryAddress) { pr_debug("address %p\n", MemoryAddress); { - std::lock_guard gard(*fragment_allocator_lock_); if (nullptr != fragment_allocator_.block_base(MemoryAddress)) return HSAKMT_STATUS_SUCCESS; }