Skip to content

Commit 0248b53

Browse files
feature: Retrieve vmToTile map information for multi tile eudebug support
Related-To: NEO-11104 Signed-off-by: Jitendra Sharma <[email protected]>
1 parent e8cfb38 commit 0248b53

File tree

5 files changed

+233
-104
lines changed

5 files changed

+233
-104
lines changed

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,62 @@ struct DebugSessionLinux : DebugSessionImp {
197197
apiEventCondition.notify_all();
198198
}
199199

200+
bool isTileWithinDeviceBitfield(uint32_t tileIndex) {
201+
return connectedDevice->getNEODevice()->getDeviceBitfield().test(tileIndex);
202+
}
203+
204+
bool checkAllOtherTileIsaAllocationsPresent(uint32_t tileIndex, uint64_t isaVa) {
205+
bool allInstancesPresent = true;
206+
for (uint32_t i = 0; i < NEO::EngineLimits::maxHandleCount; i++) {
207+
if (i != tileIndex && connectedDevice->getNEODevice()->getDeviceBitfield().test(i)) {
208+
if (getClientConnection(clientHandle)->isaMap[i].find(isaVa) == getClientConnection(clientHandle)->isaMap[i].end()) {
209+
allInstancesPresent = false;
210+
break;
211+
}
212+
}
213+
}
214+
return allInstancesPresent;
215+
}
216+
217+
bool checkAllOtherTileIsaAllocationsRemoved(uint32_t tileIndex, uint64_t isaVa) {
218+
bool allInstancesRemoved = true;
219+
for (uint32_t i = 0; i < NEO::EngineLimits::maxHandleCount; i++) {
220+
if (i != tileIndex && connectedDevice->getNEODevice()->getDeviceBitfield().test(i)) {
221+
if (getClientConnection(clientHandle)->isaMap[i].find(isaVa) != getClientConnection(clientHandle)->isaMap[i].end()) {
222+
allInstancesRemoved = false;
223+
break;
224+
}
225+
}
226+
}
227+
return allInstancesRemoved;
228+
}
229+
230+
bool checkAllOtherTileModuleSegmentsPresent(uint32_t tileIndex, const Module &module) {
231+
bool allInstancesPresent = true;
232+
for (uint32_t i = 0; i < NEO::EngineLimits::maxHandleCount; i++) {
233+
if (i != tileIndex && connectedDevice->getNEODevice()->getDeviceBitfield().test(i)) {
234+
if (module.loadAddresses[i].size() != module.segmentCount) {
235+
allInstancesPresent = false;
236+
break;
237+
}
238+
}
239+
}
240+
return allInstancesPresent;
241+
}
242+
243+
bool checkAllOtherTileModuleSegmentsRemoved(uint32_t tileIndex, const Module &module) {
244+
bool allInstancesRemoved = true;
245+
for (uint32_t i = 0; i < NEO::EngineLimits::maxHandleCount; i++) {
246+
if (i != tileIndex && connectedDevice->getNEODevice()->getDeviceBitfield().test(i)) {
247+
if (module.loadAddresses[i].size() != 0) {
248+
allInstancesRemoved = false;
249+
break;
250+
}
251+
}
252+
}
253+
return allInstancesRemoved;
254+
}
255+
200256
void updateStoppedThreadsAndCheckTriggerEvents(const AttentionEventFields &attention, uint32_t tileIndex, std::vector<EuThread::ThreadId> &threadsWithAttention) override;
201257
virtual void updateContextAndLrcHandlesForThreadsWithAttention(EuThread::ThreadId threadId, const AttentionEventFields &attention) = 0;
202258
virtual uint64_t getVmHandleFromClientAndlrcHandle(uint64_t clientHandle, uint64_t lrcHandle) = 0;

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

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -150,62 +150,6 @@ struct DebugSessionLinuxi915 : DebugSessionLinux {
150150
int threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) override;
151151
void printContextVms();
152152

153-
bool isTileWithinDeviceBitfield(uint32_t tileIndex) {
154-
return connectedDevice->getNEODevice()->getDeviceBitfield().test(tileIndex);
155-
}
156-
157-
bool checkAllOtherTileIsaAllocationsPresent(uint32_t tileIndex, uint64_t isaVa) {
158-
bool allInstancesPresent = true;
159-
for (uint32_t i = 0; i < NEO::EngineLimits::maxHandleCount; i++) {
160-
if (i != tileIndex && connectedDevice->getNEODevice()->getDeviceBitfield().test(i)) {
161-
if (clientHandleToConnection[clientHandle]->isaMap[i].find(isaVa) == clientHandleToConnection[clientHandle]->isaMap[i].end()) {
162-
allInstancesPresent = false;
163-
break;
164-
}
165-
}
166-
}
167-
return allInstancesPresent;
168-
}
169-
170-
bool checkAllOtherTileIsaAllocationsRemoved(uint32_t tileIndex, uint64_t isaVa) {
171-
bool allInstancesRemoved = true;
172-
for (uint32_t i = 0; i < NEO::EngineLimits::maxHandleCount; i++) {
173-
if (i != tileIndex && connectedDevice->getNEODevice()->getDeviceBitfield().test(i)) {
174-
if (clientHandleToConnection[clientHandle]->isaMap[i].find(isaVa) != clientHandleToConnection[clientHandle]->isaMap[i].end()) {
175-
allInstancesRemoved = false;
176-
break;
177-
}
178-
}
179-
}
180-
return allInstancesRemoved;
181-
}
182-
183-
bool checkAllOtherTileModuleSegmentsPresent(uint32_t tileIndex, const Module &module) {
184-
bool allInstancesPresent = true;
185-
for (uint32_t i = 0; i < NEO::EngineLimits::maxHandleCount; i++) {
186-
if (i != tileIndex && connectedDevice->getNEODevice()->getDeviceBitfield().test(i)) {
187-
if (module.loadAddresses[i].size() != module.segmentCount) {
188-
allInstancesPresent = false;
189-
break;
190-
}
191-
}
192-
}
193-
return allInstancesPresent;
194-
}
195-
196-
bool checkAllOtherTileModuleSegmentsRemoved(uint32_t tileIndex, const Module &module) {
197-
bool allInstancesRemoved = true;
198-
for (uint32_t i = 0; i < NEO::EngineLimits::maxHandleCount; i++) {
199-
if (i != tileIndex && connectedDevice->getNEODevice()->getDeviceBitfield().test(i)) {
200-
if (module.loadAddresses[i].size() != 0) {
201-
allInstancesRemoved = false;
202-
break;
203-
}
204-
}
205-
}
206-
return allInstancesRemoved;
207-
}
208-
209153
std::vector<std::unique_ptr<uint64_t[]>> pendingVmBindEvents;
210154

211155
uint32_t i915DebuggerVersion = 0;

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

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,38 @@ void DebugSessionLinuxXe::handleEvent(NEO::EuDebugEvent *event) {
344344
vmBindOpData.vmBindOpMetadataVec.push_back(*vmBindOpMetadata);
345345
vmBindOpData.pendingNumExtensions--;
346346
handleVmBind(vmBindMap[vmBindSeqNo]);
347-
} else if (type == euDebugInterface->getParamValue(NEO::EuDebugParam::eventTypePagefault) ||
348-
type == euDebugInterface->getParamValue(NEO::EuDebugParam::eventTypeExecQueuePlacements)) {
347+
} else if (type == euDebugInterface->getParamValue(NEO::EuDebugParam::eventTypeExecQueuePlacements)) {
348+
NEO::EuDebugEventExecQueuePlacements *execQueuePlacements = reinterpret_cast<NEO::EuDebugEventExecQueuePlacements *>(event);
349+
350+
PRINT_DEBUGGER_INFO_LOG("DRM_XE_EUDEBUG_IOCTL_READ_EVENT type: PRELIM_DRM_XE_EUDEBUG_EVENT_EXEC_QUEUE_PLACEMENTS client_handle = %" SCNx64
351+
" vm_handle = %" SCNx64
352+
" exec_queue_handle = %" SCNx64
353+
" lrc_handle = %" SCNx64
354+
" num_placements = %" SCNx32
355+
"\n ",
356+
static_cast<uint64_t>(execQueuePlacements->clientHandle),
357+
static_cast<uint64_t>(execQueuePlacements->vmHandle),
358+
static_cast<uint64_t>(execQueuePlacements->execQueueHandle), static_cast<uint64_t>(execQueuePlacements->lrcHandle),
359+
static_cast<uint32_t>(execQueuePlacements->numPlacements));
360+
361+
UNRECOVERABLE_IF(execQueuePlacements->numPlacements == 0);
362+
auto engine = reinterpret_cast<NEO::EngineClassInstance *>(&(execQueuePlacements->instances[0]));
363+
NEO::EngineClassInstance engineClassInstance = {engine->engineClass, engine->engineInstance};
364+
auto tileIndex = DrmHelper::getEngineTileIndex(connectedDevice, engineClassInstance);
365+
366+
auto &vmToTile = clientHandleToConnection[execQueuePlacements->clientHandle]->vmToTile;
367+
if (vmToTile.find(execQueuePlacements->vmHandle) != vmToTile.end()) {
368+
if (vmToTile[execQueuePlacements->vmHandle] != tileIndex) {
369+
PRINT_DEBUGGER_ERROR_LOG("vmToTile map: For vm_handle = %lu tileIndex = %u already present. Attempt to overwrite with tileIndex = %u\n",
370+
static_cast<uint64_t>(execQueuePlacements->vmHandle), vmToTile[execQueuePlacements->vmHandle], tileIndex);
371+
DEBUG_BREAK_IF(true);
372+
}
373+
} else {
374+
clientHandleToConnection[execQueuePlacements->clientHandle]->vmToTile[execQueuePlacements->vmHandle] = tileIndex;
375+
PRINT_DEBUGGER_INFO_LOG("clientHandleToConnection[%" SCNx64 "]->vmToTile[%" SCNx64 "] = %u\n",
376+
static_cast<uint64_t>(execQueuePlacements->clientHandle), static_cast<uint64_t>(execQueuePlacements->vmHandle), tileIndex);
377+
}
378+
} else if (type == euDebugInterface->getParamValue(NEO::EuDebugParam::eventTypePagefault)) {
349379
PRINT_DEBUGGER_INFO_LOG("DRM_XE_EUDEBUG_IOCTL_READ_EVENT type: UNHANDLED %u flags = %u len = %lu\n", type, event->flags, event->len);
350380
} else {
351381
additionalEvents(event);
@@ -383,6 +413,10 @@ void DebugSessionLinuxXe::handleVmBind(VmBindData &vmBindData) {
383413
uint64_t isaAddr = 0;
384414
bool triggerModuleLoadEvent = false;
385415

416+
uint32_t tileIndex = 0;
417+
if (connection->vmToTile.find(vmBindData.vmBind.vmHandle) != connection->vmToTile.end()) {
418+
tileIndex = connection->vmToTile[vmBindData.vmBind.vmHandle];
419+
}
386420
for (auto &vmBindOpData : vmBindData.vmBindOpMap) {
387421
auto &vmBindOp = vmBindOpData.second.vmBindOp;
388422
for (const auto &vmBindOpMetadata : vmBindOpData.second.vmBindOpMetadataVec) {
@@ -398,8 +432,8 @@ void DebugSessionLinuxXe::handleVmBind(VmBindData &vmBindData) {
398432
}
399433
if (metaDataEntry.metadata.type == euDebugInterface->getParamValue(NEO::EuDebugParam::metadataModuleArea)) {
400434
isaAddr = vmBindOp.addr;
401-
if (connection->isaMap[0].find(vmBindOp.addr) == connection->isaMap[0].end()) {
402-
auto &isaMap = connection->isaMap[0];
435+
if (connection->isaMap[tileIndex].find(vmBindOp.addr) == connection->isaMap[tileIndex].end()) {
436+
auto &isaMap = connection->isaMap[tileIndex];
403437
auto isa = std::make_unique<IsaAllocation>();
404438
isa->bindInfo = {vmBindOp.addr, vmBindOp.range};
405439
isa->vmHandle = vmBindData.vmBind.vmHandle;
@@ -424,8 +458,8 @@ void DebugSessionLinuxXe::handleVmBind(VmBindData &vmBindData) {
424458

425459
if (metaDataEntry.metadata.type == euDebugInterface->getParamValue(NEO::EuDebugParam::metadataElfBinary)) {
426460
isaAddr = vmBindOp.addr;
427-
if (connection->isaMap[0].find(vmBindOp.addr) == connection->isaMap[0].end()) {
428-
auto &isaMap = connection->isaMap[0];
461+
if (connection->isaMap[tileIndex].find(vmBindOp.addr) == connection->isaMap[tileIndex].end()) {
462+
auto &isaMap = connection->isaMap[tileIndex];
429463
auto &elfMap = connection->elfMap;
430464
auto isa = std::make_unique<IsaAllocation>();
431465
isa->bindInfo = {vmBindOp.addr, vmBindOp.range};
@@ -441,45 +475,45 @@ void DebugSessionLinuxXe::handleVmBind(VmBindData &vmBindData) {
441475
isaMap[vmBindOp.addr]->moduleLoadEventAck = true;
442476
elfHandleInVmBind = vmBindOpMetadata.metadataHandle;
443477
} else {
444-
auto &isa = connection->isaMap[0][vmBindOp.addr];
478+
auto &isa = connection->isaMap[tileIndex][vmBindOp.addr];
445479
isa->validVMs.insert(vmBindData.vmBind.vmHandle);
446480
}
447481
}
448482
if (metaDataEntry.metadata.type == euDebugInterface->getParamValue(NEO::EuDebugParam::metadataProgramModule)) {
449483
auto &module = connection->metaDataToModule[vmBindOpMetadata.metadataHandle];
450-
module.segmentVmBindCounter[0]++;
451-
DEBUG_BREAK_IF(module.loadAddresses[0].size() > module.segmentCount);
484+
module.segmentVmBindCounter[tileIndex]++;
485+
DEBUG_BREAK_IF(module.loadAddresses[tileIndex].size() > module.segmentCount);
452486

453-
bool canTriggerEvent = module.loadAddresses[0].size() == (module.segmentCount - 1);
454-
module.loadAddresses[0].insert(vmBindOp.addr);
487+
bool canTriggerEvent = module.loadAddresses[tileIndex].size() == (module.segmentCount - 1);
488+
module.loadAddresses[tileIndex].insert(vmBindOp.addr);
455489
moduleHandle = vmBindOpMetadata.metadataHandle;
456-
if (canTriggerEvent && module.loadAddresses[0].size() == module.segmentCount) {
490+
if (canTriggerEvent && module.loadAddresses[tileIndex].size() == module.segmentCount) {
457491
triggerModuleLoadEvent = true;
458492
}
459493
}
460494
}
461495
}
462496

463497
if (vmBindOp.base.flags & euDebugInterface->getParamValue(NEO::EuDebugParam::eventBitDestroy)) {
464-
if (connection->isaMap[0].count(vmBindOp.addr)) {
465-
auto &isa = connection->isaMap[0][vmBindOp.addr];
498+
if (connection->isaMap[tileIndex].count(vmBindOp.addr)) {
499+
auto &isa = connection->isaMap[tileIndex][vmBindOp.addr];
466500
if (isa->validVMs.count(vmBindData.vmBind.vmHandle)) {
467501
auto &module = connection->metaDataToModule[isa->moduleHandle];
468-
module.segmentVmBindCounter[0]--;
469-
if (module.segmentVmBindCounter[0] == 0) {
502+
module.segmentVmBindCounter[tileIndex]--;
503+
if (module.segmentVmBindCounter[tileIndex] == 0) {
470504
zet_debug_event_t debugEvent = {};
471505
auto &metaDataEntry = connection->metaDataMap[isa->moduleHandle];
472506
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
473-
auto loadAddress = gmmHelper->canonize(*std::min_element(module.loadAddresses[0].begin(), module.loadAddresses[0].end()));
507+
auto loadAddress = gmmHelper->canonize(*std::min_element(module.loadAddresses[tileIndex].begin(), module.loadAddresses[tileIndex].end()));
474508
debugEvent.type = ZET_DEBUG_EVENT_TYPE_MODULE_UNLOAD;
475509
debugEvent.info.module.format = ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF;
476510
debugEvent.info.module.load = loadAddress;
477511
auto &elfMetadata = connection->metaDataMap[isa->elfHandle];
478512
debugEvent.info.module.moduleBegin = reinterpret_cast<uint64_t>(elfMetadata.data.get());
479513
debugEvent.info.module.moduleEnd = reinterpret_cast<uint64_t>(elfMetadata.data.get()) + elfMetadata.metadata.len;
480514
pushApiEvent(debugEvent, metaDataEntry.metadata.metadataHandle);
481-
module.loadAddresses[0].clear();
482-
module.moduleLoadEventAcked[0] = false;
515+
module.loadAddresses[tileIndex].clear();
516+
module.moduleLoadEventAcked[tileIndex] = false;
483517
}
484518
isa->validVMs.erase(vmBindData.vmBind.vmHandle);
485519
}
@@ -488,7 +522,7 @@ void DebugSessionLinuxXe::handleVmBind(VmBindData &vmBindData) {
488522
}
489523

490524
if (isaAddr && moduleHandle != invalidHandle) {
491-
connection->isaMap[0][isaAddr]->moduleHandle = moduleHandle;
525+
connection->isaMap[tileIndex][isaAddr]->moduleHandle = moduleHandle;
492526
}
493527

494528
if (triggerModuleLoadEvent) {
@@ -497,7 +531,7 @@ void DebugSessionLinuxXe::handleVmBind(VmBindData &vmBindData) {
497531
auto &metaDataEntry = connection->metaDataMap[moduleHandle];
498532
auto &module = connection->metaDataToModule[moduleHandle];
499533
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
500-
auto loadAddress = gmmHelper->canonize(*std::min_element(module.loadAddresses[0].begin(), module.loadAddresses[0].end()));
534+
auto loadAddress = gmmHelper->canonize(*std::min_element(module.loadAddresses[tileIndex].begin(), module.loadAddresses[tileIndex].end()));
501535
PRINT_DEBUGGER_INFO_LOG("Zebin module loaded at: %p, with %u isa allocations", (void *)loadAddress, module.segmentCount);
502536

503537
auto &elfMetadata = connection->metaDataMap[elfHandleInVmBind];
@@ -514,7 +548,7 @@ void DebugSessionLinuxXe::handleVmBind(VmBindData &vmBindData) {
514548
if (vmBindData.vmBind.flags & euDebugInterface->getParamValue(NEO::EuDebugParam::eventVmBindFlagUfence)) {
515549
if (vmBindData.vmBindUfence.base.flags & euDebugInterface->getParamValue(NEO::EuDebugParam::eventBitNeedAck)) {
516550
EventToAck ackEvent(vmBindData.vmBindUfence.base.seqno, vmBindData.vmBindUfence.base.type);
517-
module.ackEvents[0].push_back(ackEvent);
551+
module.ackEvents[tileIndex].push_back(ackEvent);
518552
shouldAckEvent = false;
519553
}
520554
}

0 commit comments

Comments
 (0)