mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
Fix module load events
- report load address in canonical form Related-To: NEO-6997 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
49a27c3755
commit
f7dc958163
@@ -769,8 +769,6 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
auto &isaMap = connection->isaMap;
|
||||
auto &elfMap = connection->elfMap;
|
||||
|
||||
auto loadAddress = vmBind->va_start;
|
||||
|
||||
auto isa = std::make_unique<IsaAllocation>();
|
||||
isa->bindInfo = {vmBind->va_start, vmBind->va_length};
|
||||
isa->vmHandle = vmHandle;
|
||||
@@ -803,6 +801,9 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
PRINT_DEBUGGER_ERROR_LOG("No ELF provided by application\n", "");
|
||||
}
|
||||
|
||||
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
|
||||
auto loadAddress = gmmHelper->canonize(vmBind->va_start);
|
||||
|
||||
zet_debug_event_t debugEvent = {};
|
||||
debugEvent.type = ZET_DEBUG_EVENT_TYPE_MODULE_LOAD;
|
||||
debugEvent.info.module.format = ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF;
|
||||
@@ -813,6 +814,9 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
std::unique_lock<std::mutex> memLock(asyncThreadMutex);
|
||||
isaMap[vmBind->va_start] = std::move(isa);
|
||||
|
||||
// Expect non canonical va_start
|
||||
DEBUG_BREAK_IF(gmmHelper->decanonize(vmBind->va_start) != vmBind->va_start);
|
||||
|
||||
// If ACK flag is not set when triggering MODULE LOAD event, auto-ack immediately
|
||||
if ((vmBind->base.flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK) == 0) {
|
||||
connection->isaMap[vmBind->va_start]->moduleLoadEventAck = true;
|
||||
@@ -844,9 +848,12 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
|
||||
zet_debug_event_t debugEvent = {};
|
||||
|
||||
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
|
||||
auto loadAddress = gmmHelper->canonize(isa->bindInfo.gpuVa);
|
||||
|
||||
debugEvent.type = ZET_DEBUG_EVENT_TYPE_MODULE_UNLOAD;
|
||||
debugEvent.info.module.format = ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF;
|
||||
debugEvent.info.module.load = isa->bindInfo.gpuVa;
|
||||
debugEvent.info.module.load = loadAddress;
|
||||
debugEvent.info.module.moduleBegin = isa->moduleBegin;
|
||||
debugEvent.info.module.moduleEnd = isa->moduleEnd;
|
||||
|
||||
@@ -873,7 +880,8 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
module.loadAddresses.insert(vmBind->va_start);
|
||||
|
||||
if (canTriggerEvent && module.loadAddresses.size() == module.segmentCount) {
|
||||
loadAddress = *std::min_element(module.loadAddresses.begin(), module.loadAddresses.end());
|
||||
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
|
||||
loadAddress = gmmHelper->canonize(*std::min_element(module.loadAddresses.begin(), module.loadAddresses.end()));
|
||||
PRINT_DEBUGGER_INFO_LOG("Zebin module loaded at: %p, with %u isa allocations", (void *)loadAddress, module.segmentCount);
|
||||
|
||||
zet_debug_event_t debugEvent = {};
|
||||
@@ -894,7 +902,8 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
|
||||
|
||||
zet_debug_event_t debugEvent = {};
|
||||
|
||||
auto loadAddress = *std::min_element(module.loadAddresses.begin(), module.loadAddresses.end());
|
||||
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
|
||||
auto loadAddress = gmmHelper->canonize(*std::min_element(module.loadAddresses.begin(), module.loadAddresses.end()));
|
||||
debugEvent.type = ZET_DEBUG_EVENT_TYPE_MODULE_UNLOAD;
|
||||
debugEvent.info.module.format = ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF;
|
||||
debugEvent.info.module.load = loadAddress;
|
||||
@@ -1379,7 +1388,10 @@ ze_result_t DebugSessionLinux::acknowledgeEvent(const zet_debug_event_t *event)
|
||||
bool perKernelIsaAcked = false;
|
||||
if (event->type == ZET_DEBUG_EVENT_TYPE_MODULE_LOAD) {
|
||||
auto connection = clientHandleToConnection[clientHandle].get();
|
||||
auto isa = connection->isaMap.find(event->info.module.load);
|
||||
|
||||
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
|
||||
auto isaVaStart = gmmHelper->decanonize(event->info.module.load);
|
||||
auto isa = connection->isaMap.find(isaVaStart);
|
||||
|
||||
if (isa != connection->isaMap.end()) {
|
||||
for (auto &event : isa->second->ackEvents) {
|
||||
|
||||
@@ -4069,7 +4069,7 @@ TEST_F(DebugApiLinuxVmBindTest, GivenVmBindDestroyEventForIsaWhenHandlingEventTh
|
||||
}
|
||||
|
||||
TEST_F(DebugApiLinuxVmBindTest, GivenVmBindEventForIsaWhenReadingEventThenModuleLoadEventIsReturned) {
|
||||
uint64_t isaGpuVa = 0x345000;
|
||||
uint64_t isaGpuVa = device->getHwInfo().capabilityTable.gpuAddressSpace - 0x3000;
|
||||
uint64_t isaSize = 0x2000;
|
||||
uint64_t vmBindIsaData[sizeof(prelim_drm_i915_debug_event_vm_bind) / sizeof(uint64_t) + 3 * sizeof(typeOfUUID)];
|
||||
prelim_drm_i915_debug_event_vm_bind *vmBindIsa = reinterpret_cast<prelim_drm_i915_debug_event_vm_bind *>(&vmBindIsaData);
|
||||
@@ -4090,8 +4090,14 @@ TEST_F(DebugApiLinuxVmBindTest, GivenVmBindEventForIsaWhenReadingEventThenModule
|
||||
|
||||
memcpy(uuids, uuidsTemp, sizeof(uuidsTemp));
|
||||
|
||||
auto &isaMap = session->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->isaMap;
|
||||
EXPECT_EQ(0u, isaMap.size());
|
||||
|
||||
session->handleEvent(&vmBindIsa->base);
|
||||
|
||||
EXPECT_EQ(1u, isaMap.size());
|
||||
EXPECT_EQ(isaGpuVa, isaMap[isaGpuVa]->bindInfo.gpuVa);
|
||||
|
||||
// No event to ACK if vmBind doesn't have ACK flag
|
||||
EXPECT_EQ(0u, session->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->eventsToAck.size());
|
||||
|
||||
@@ -4100,8 +4106,13 @@ TEST_F(DebugApiLinuxVmBindTest, GivenVmBindEventForIsaWhenReadingEventThenModule
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(ZET_DEBUG_EVENT_TYPE_MODULE_LOAD, event.type);
|
||||
EXPECT_EQ(0u, event.flags);
|
||||
EXPECT_EQ(isaGpuVa, event.info.module.load);
|
||||
|
||||
auto gmmHelper = neoDevice->getGmmHelper();
|
||||
EXPECT_EQ(gmmHelper->canonize(isaGpuVa), event.info.module.load);
|
||||
|
||||
if (Math::log2(device->getHwInfo().capabilityTable.gpuAddressSpace + 1) >= 48) {
|
||||
EXPECT_NE(isaGpuVa, event.info.module.load);
|
||||
}
|
||||
auto elf = session->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->uuidMap[elfUUID].ptr;
|
||||
auto elfSize = session->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->uuidMap[elfUUID].dataSize;
|
||||
EXPECT_EQ(elf, event.info.module.moduleBegin);
|
||||
@@ -4109,7 +4120,7 @@ TEST_F(DebugApiLinuxVmBindTest, GivenVmBindEventForIsaWhenReadingEventThenModule
|
||||
}
|
||||
|
||||
TEST_F(DebugApiLinuxVmBindTest, GivenVmBindCreateAndDestroyEventsForIsaWhenReadingEventsThenModuleLoadAndUnloadEventsReturned) {
|
||||
uint64_t isaGpuVa = 0x345000;
|
||||
uint64_t isaGpuVa = device->getHwInfo().capabilityTable.gpuAddressSpace - 0x3000;
|
||||
uint64_t isaSize = 0x2000;
|
||||
uint64_t vmBindIsaData[sizeof(prelim_drm_i915_debug_event_vm_bind) / sizeof(uint64_t) + 3 * sizeof(typeOfUUID)];
|
||||
prelim_drm_i915_debug_event_vm_bind *vmBindIsa = reinterpret_cast<prelim_drm_i915_debug_event_vm_bind *>(&vmBindIsaData);
|
||||
@@ -4129,26 +4140,34 @@ TEST_F(DebugApiLinuxVmBindTest, GivenVmBindCreateAndDestroyEventsForIsaWhenReadi
|
||||
uuidsTemp[2] = static_cast<typeOfUUID>(elfUUID);
|
||||
|
||||
memcpy(uuids, uuidsTemp, sizeof(uuidsTemp));
|
||||
|
||||
auto &isaMap = session->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->isaMap;
|
||||
EXPECT_EQ(0u, isaMap.size());
|
||||
|
||||
session->handleEvent(&vmBindIsa->base);
|
||||
|
||||
EXPECT_EQ(1u, isaMap.size());
|
||||
EXPECT_EQ(isaGpuVa, isaMap[isaGpuVa]->bindInfo.gpuVa);
|
||||
|
||||
vmBindIsa->base.flags = PRELIM_DRM_I915_DEBUG_EVENT_DESTROY;
|
||||
session->handleEvent(&vmBindIsa->base);
|
||||
|
||||
auto &isaMap = session->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->isaMap;
|
||||
EXPECT_EQ(0u, isaMap.size());
|
||||
|
||||
zet_debug_event_t event = {};
|
||||
ze_result_t result = zetDebugReadEvent(session->toHandle(), 0, &event);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(ZET_DEBUG_EVENT_TYPE_MODULE_LOAD, event.type);
|
||||
EXPECT_EQ(isaGpuVa, event.info.module.load);
|
||||
|
||||
auto gmmHelper = neoDevice->getGmmHelper();
|
||||
EXPECT_EQ(gmmHelper->canonize(isaGpuVa), event.info.module.load);
|
||||
|
||||
memset(&event, 0, sizeof(zet_debug_event_t));
|
||||
result = zetDebugReadEvent(session->toHandle(), 0, &event);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(ZET_DEBUG_EVENT_TYPE_MODULE_UNLOAD, event.type);
|
||||
|
||||
EXPECT_EQ(isaGpuVa, event.info.module.load);
|
||||
EXPECT_EQ(gmmHelper->canonize(isaGpuVa), event.info.module.load);
|
||||
|
||||
auto elf = session->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->uuidMap[elfUUID].ptr;
|
||||
auto elfSize = session->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->uuidMap[elfUUID].dataSize;
|
||||
|
||||
Reference in New Issue
Block a user