SWDEV-532479 - Add tracking of hostcall memory allocations (#416)

* SWDEV-532479 - Add tracking of hostcall memory allocations

* SWDEV-532479 - Remove hostcall allocations if request is received

* SWDEV-532479 - Cleanup

* SWDEV-532479 - Naming fix

* SWDEV-532479 - Add new separator after each new function
This commit is contained in:
Arandjelovic, Marko
2025-08-15 00:17:24 +02:00
committad av GitHub
förälder 5f86622adc
incheckning b58faa2f37
3 ändrade filer med 35 tillägg och 1 borttagningar
+24
Visa fil
@@ -807,6 +807,16 @@ Device::~Device() {
delete vaCacheMap_;
}
for (auto memory : hostcall_allocated_memories_) {
if (memory != nullptr) {
amd::MemObjMap::RemoveMemObj(
reinterpret_cast<void*>(memory->getDeviceMemory(*this, false)->virtualAddress()));
memory->release();
}
}
hostcall_allocated_memories_.clear();
delete vaCacheAccess_;
delete settings_;
delete[] info_.extensions_;
@@ -1205,6 +1215,20 @@ bool Device::GetHandleForAddressRange(void* dev_ptr, size_t size, void* handle)
return dev_mem->GetFDHandleForMem(dev_ptr, size, VmmPtr, handle);
}
// ================================================================================================
void Device::TrackHostcallMemory(amd::Memory* memory) {
hostcall_allocated_memories_.push_back(memory);
}
// ================================================================================================
void Device::RemoveHostcallMemory(amd::Memory* memory) {
auto it =
std::find(hostcall_allocated_memories_.begin(), hostcall_allocated_memories_.end(), memory);
if (it != hostcall_allocated_memories_.end()) {
hostcall_allocated_memories_.erase(it);
}
}
} // namespace amd
namespace amd::device {