Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[L0] fix a deadlock on a recursive event rwlock #1468

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading