Skip to content

Commit

Permalink
Merge pull request #1468 from pbalcer/l0-recursive-event-deadlock
Browse files Browse the repository at this point in the history
[L0] fix a deadlock on a recursive event rwlock
  • Loading branch information
aarongreig authored Mar 25, 2024
2 parents 1f4b703 + 39c0023 commit 8dba1fd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions source/adapters/level_zero/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,15 @@ ur_result_t _ur_ze_event_list_t::createAndRetainUrZeEventList(
}
}

ur_command_list_ptr_t CommandList;
if (Queue && Queue->Device != CurQueue->Device) {
// Get a command list prior to acquiring an event lock.
// This prevents a potential deadlock with recursive
// event locks.
UR_CALL(Queue->Context->getAvailableCommandList(Queue, CommandList,
false, true));
}

std::shared_lock<ur_shared_mutex> Lock(EventList[I]->Mutex);

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

ur_command_list_ptr_t CommandList{};
UR_CALL(Queue->Context->getAvailableCommandList(Queue, CommandList,
false, true));

UR_CALL(createEventAndAssociateQueue(
Queue, &MultiDeviceEvent, EventList[I]->CommandType, CommandList,
IsInternal, IsMultiDevice));
Expand Down

0 comments on commit 8dba1fd

Please sign in to comment.