Skip to content

Commit 52133e6

Browse files
L0Debug - per tile isa and modules in debug session
Related-To: NEO-5784 Signed-off-by: Mateusz Hoppe <[email protected]>
1 parent eb8cd33 commit 52133e6

File tree

3 files changed

+74
-70
lines changed

3 files changed

+74
-70
lines changed

level_zero/tools/source/debug/linux/prelim/debug_session.cpp

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ void DebugSessionLinux::handleEvent(prelim_drm_i915_debug_event *event) {
454454
bool create = event->flags & PRELIM_DRM_I915_DEBUG_EVENT_CREATE;
455455

456456
if (destroy && clientHandleToConnection[uuid->client_handle]->uuidMap[uuid->handle].classIndex == NEO::DrmResourceClass::L0ZebinModule) {
457-
DEBUG_BREAK_IF(clientHandleToConnection[uuid->client_handle]->uuidToModule[uuid->handle].segmentVmBindCounter != 0 ||
458-
clientHandleToConnection[uuid->client_handle]->uuidToModule[uuid->handle].loadAddresses.size() > 0);
457+
DEBUG_BREAK_IF(clientHandleToConnection[uuid->client_handle]->uuidToModule[uuid->handle].segmentVmBindCounter[0] != 0 ||
458+
clientHandleToConnection[uuid->client_handle]->uuidToModule[uuid->handle].loadAddresses[0].size() > 0);
459459

460460
clientHandleToConnection[uuid->client_handle]->uuidToModule.erase(uuid->handle);
461461
}
@@ -542,7 +542,10 @@ void DebugSessionLinux::handleEvent(prelim_drm_i915_debug_event *event) {
542542

543543
auto &newModule = connection->uuidToModule[handle];
544544
newModule.segmentCount = 0;
545-
newModule.segmentVmBindCounter = 0;
545+
for (uint32_t i = 0; i < NEO::EngineLimits::maxHandleCount; i++) {
546+
newModule.segmentVmBindCounter[i] = 0;
547+
newModule.loadAddresses[i].clear();
548+
}
546549
}
547550
extractUuidData(uuid->client_handle, uuidData);
548551
}
@@ -706,6 +709,7 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
706709
uint32_t index = 0;
707710
auto connection = clientHandleToConnection[vmBind->client_handle].get();
708711
const auto uuid = vmBind->uuids[index];
712+
const auto tileIndex = 0;
709713

710714
if (connection->uuidMap.find(uuid) == connection->uuidMap.end()) {
711715
PRINT_DEBUGGER_ERROR_LOG("Unknown UUID handle = %llu\n", (uint64_t)uuid);
@@ -754,9 +758,9 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
754758
}
755759
}
756760

757-
if (connection->isaMap.find(vmBind->va_start) == connection->isaMap.end() && createEvent) {
761+
if (connection->isaMap[tileIndex].find(vmBind->va_start) == connection->isaMap[tileIndex].end() && createEvent) {
758762

759-
auto &isaMap = connection->isaMap;
763+
auto &isaMap = connection->isaMap[tileIndex];
760764
auto &elfMap = connection->elfMap;
761765

762766
auto isa = std::make_unique<IsaAllocation>();
@@ -806,7 +810,7 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
806810

807811
// If ACK flag is not set when triggering MODULE LOAD event, auto-ack immediately
808812
if ((vmBind->base.flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK) == 0) {
809-
connection->isaMap[vmBind->va_start]->moduleLoadEventAck = true;
813+
isaMap[vmBind->va_start]->moduleLoadEventAck = true;
810814
}
811815
memLock.unlock();
812816

@@ -818,20 +822,20 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
818822

819823
if (createEvent) {
820824
std::unique_lock<std::mutex> lock(asyncThreadMutex);
821-
if (!connection->isaMap[vmBind->va_start]->moduleLoadEventAck && perKernelModules) {
825+
if (!connection->isaMap[tileIndex][vmBind->va_start]->moduleLoadEventAck && perKernelModules) {
822826
PRINT_DEBUGGER_INFO_LOG("Add event to ack, seqno = %llu", (uint64_t)vmBind->base.seqno);
823-
connection->isaMap[vmBind->va_start]->ackEvents.push_back(vmBind->base);
827+
connection->isaMap[tileIndex][vmBind->va_start]->ackEvents.push_back(vmBind->base);
824828
shouldAckEvent = false;
825829
}
826830

827-
connection->isaMap[vmBind->va_start]->vmBindCounter++;
831+
connection->isaMap[tileIndex][vmBind->va_start]->vmBindCounter++;
828832
}
829833

830-
if (destroyEvent && connection->isaMap.find(vmBind->va_start) != connection->isaMap.end()) {
831-
DEBUG_BREAK_IF(connection->isaMap[vmBind->va_start]->vmBindCounter == 0);
832-
connection->isaMap[vmBind->va_start]->vmBindCounter--;
833-
if (connection->isaMap[vmBind->va_start]->vmBindCounter == 0) {
834-
const auto &isa = connection->isaMap[vmBind->va_start];
834+
if (destroyEvent && connection->isaMap[tileIndex].find(vmBind->va_start) != connection->isaMap[tileIndex].end()) {
835+
DEBUG_BREAK_IF(connection->isaMap[tileIndex][vmBind->va_start]->vmBindCounter == 0);
836+
connection->isaMap[tileIndex][vmBind->va_start]->vmBindCounter--;
837+
if (connection->isaMap[tileIndex][vmBind->va_start]->vmBindCounter == 0) {
838+
const auto &isa = connection->isaMap[tileIndex][vmBind->va_start];
835839

836840
zet_debug_event_t debugEvent = {};
837841

@@ -848,7 +852,7 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
848852
pushApiEvent(debugEvent, nullptr);
849853
}
850854
std::unique_lock<std::mutex> memLock(asyncThreadMutex);
851-
connection->isaMap.erase(vmBind->va_start);
855+
connection->isaMap[tileIndex].erase(vmBind->va_start);
852856
memLock.unlock();
853857
}
854858
}
@@ -860,15 +864,15 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
860864
auto &module = connection->uuidToModule[vmBind->uuids[uuidIter]];
861865

862866
if (createEvent) {
863-
module.segmentVmBindCounter++;
867+
module.segmentVmBindCounter[tileIndex]++;
864868

865-
DEBUG_BREAK_IF(module.loadAddresses.size() > module.segmentCount);
866-
bool canTriggerEvent = module.loadAddresses.size() == (module.segmentCount - 1);
867-
module.loadAddresses.insert(vmBind->va_start);
869+
DEBUG_BREAK_IF(module.loadAddresses[tileIndex].size() > module.segmentCount);
870+
bool canTriggerEvent = module.loadAddresses[tileIndex].size() == (module.segmentCount - 1);
871+
module.loadAddresses[tileIndex].insert(vmBind->va_start);
868872

869-
if (canTriggerEvent && module.loadAddresses.size() == module.segmentCount) {
873+
if (canTriggerEvent && module.loadAddresses[tileIndex].size() == module.segmentCount) {
870874
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
871-
loadAddress = gmmHelper->canonize(*std::min_element(module.loadAddresses.begin(), module.loadAddresses.end()));
875+
loadAddress = gmmHelper->canonize(*std::min_element(module.loadAddresses[tileIndex].begin(), module.loadAddresses[tileIndex].end()));
872876
PRINT_DEBUGGER_INFO_LOG("Zebin module loaded at: %p, with %u isa allocations", (void *)loadAddress, module.segmentCount);
873877

874878
zet_debug_event_t debugEvent = {};
@@ -883,22 +887,22 @@ void DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
883887
}
884888
} else { // destroyEvent
885889

886-
module.segmentVmBindCounter--;
890+
module.segmentVmBindCounter[tileIndex]--;
887891

888-
if (module.segmentVmBindCounter == 0) {
892+
if (module.segmentVmBindCounter[tileIndex] == 0) {
889893

890894
zet_debug_event_t debugEvent = {};
891895

892896
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
893-
auto loadAddress = gmmHelper->canonize(*std::min_element(module.loadAddresses.begin(), module.loadAddresses.end()));
897+
auto loadAddress = gmmHelper->canonize(*std::min_element(module.loadAddresses[tileIndex].begin(), module.loadAddresses[tileIndex].end()));
894898
debugEvent.type = ZET_DEBUG_EVENT_TYPE_MODULE_UNLOAD;
895899
debugEvent.info.module.format = ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF;
896900
debugEvent.info.module.load = loadAddress;
897901
debugEvent.info.module.moduleBegin = connection->uuidMap[module.elfUuidHandle].ptr;
898902
debugEvent.info.module.moduleEnd = connection->uuidMap[module.elfUuidHandle].ptr + connection->uuidMap[module.elfUuidHandle].dataSize;
899903

900904
pushApiEvent(debugEvent, nullptr);
901-
module.loadAddresses.clear();
905+
module.loadAddresses[tileIndex].clear();
902906
}
903907
}
904908
}
@@ -1174,7 +1178,7 @@ ze_result_t DebugSessionLinux::interruptImp(uint32_t deviceIndex) {
11741178

11751179
ze_result_t DebugSessionLinux::getISAVMHandle(const zet_debug_memory_space_desc_t *desc, size_t size, uint64_t &vmHandle) {
11761180
auto accessVA = desc->address;
1177-
auto &isaMap = clientHandleToConnection[clientHandle]->isaMap;
1181+
auto &isaMap = clientHandleToConnection[clientHandle]->isaMap[0];
11781182
ze_result_t status = ZE_RESULT_ERROR_UNINITIALIZED;
11791183
vmHandle = invalidHandle;
11801184

@@ -1380,9 +1384,9 @@ ze_result_t DebugSessionLinux::acknowledgeEvent(const zet_debug_event_t *event)
13801384

13811385
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
13821386
auto isaVaStart = gmmHelper->decanonize(event->info.module.load);
1383-
auto isa = connection->isaMap.find(isaVaStart);
1387+
auto isa = connection->isaMap[0].find(isaVaStart);
13841388

1385-
if (isa != connection->isaMap.end()) {
1389+
if (isa != connection->isaMap[0].end()) {
13861390
for (auto &event : isa->second->ackEvents) {
13871391
prelim_drm_i915_debug_event_ack eventToAck = {};
13881392
eventToAck.type = event.type;

level_zero/tools/source/debug/linux/prelim/debug_session.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ struct DebugSessionLinux : DebugSessionImp {
114114
};
115115

116116
struct Module {
117-
std::unordered_set<uint64_t> loadAddresses;
117+
std::unordered_set<uint64_t> loadAddresses[NEO::EngineLimits::maxHandleCount];
118118
uint64_t elfUuidHandle;
119119
uint32_t segmentCount;
120-
int segmentVmBindCounter;
120+
int segmentVmBindCounter[NEO::EngineLimits::maxHandleCount];
121121
};
122122

123123
static bool apiEventCompare(const zet_debug_event_t &event1, const zet_debug_event_t &event2) {
@@ -137,7 +137,7 @@ struct DebugSessionLinux : DebugSessionImp {
137137
std::unordered_map<uint64_t, BindInfo> vmToStateBaseAreaBindInfo;
138138
std::unordered_map<uint64_t, uint32_t> vmToTile;
139139

140-
std::unordered_map<uint64_t, std::unique_ptr<IsaAllocation>> isaMap;
140+
std::unordered_map<uint64_t, std::unique_ptr<IsaAllocation>> isaMap[NEO::EngineLimits::maxHandleCount];
141141
std::unordered_map<uint64_t, uint64_t> elfMap;
142142
std::unordered_map<uint64_t, ContextHandle> lrcToContextHandle;
143143

0 commit comments

Comments
 (0)