Skip to content

Commit 8dba1fd

Browse files
authored
Merge pull request #1468 from pbalcer/l0-recursive-event-deadlock
[L0] fix a deadlock on a recursive event rwlock
2 parents 1f4b703 + 39c0023 commit 8dba1fd

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

source/adapters/level_zero/event.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,15 @@ ur_result_t _ur_ze_event_list_t::createAndRetainUrZeEventList(
13071307
}
13081308
}
13091309

1310+
ur_command_list_ptr_t CommandList;
1311+
if (Queue && Queue->Device != CurQueue->Device) {
1312+
// Get a command list prior to acquiring an event lock.
1313+
// This prevents a potential deadlock with recursive
1314+
// event locks.
1315+
UR_CALL(Queue->Context->getAvailableCommandList(Queue, CommandList,
1316+
false, true));
1317+
}
1318+
13101319
std::shared_lock<ur_shared_mutex> Lock(EventList[I]->Mutex);
13111320

13121321
if (Queue && Queue->Device != CurQueue->Device &&
@@ -1316,10 +1325,6 @@ ur_result_t _ur_ze_event_list_t::createAndRetainUrZeEventList(
13161325
bool IsInternal = true;
13171326
bool IsMultiDevice = true;
13181327

1319-
ur_command_list_ptr_t CommandList{};
1320-
UR_CALL(Queue->Context->getAvailableCommandList(Queue, CommandList,
1321-
false, true));
1322-
13231328
UR_CALL(createEventAndAssociateQueue(
13241329
Queue, &MultiDeviceEvent, EventList[I]->CommandType, CommandList,
13251330
IsInternal, IsMultiDevice));

0 commit comments

Comments
 (0)