Commit d9aeec4c authored by Sean Keely's avatar Sean Keely Committed by Oded Gabbay

drm/amdkfd: Fix scheduler race in kfd_wait_on_events sleep loop

Signed-off-by: default avatarSean Keely <sean.keely@amd.com>
Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Acked-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
parent 1f9d09be
...@@ -806,6 +806,17 @@ int kfd_wait_on_events(struct kfd_process *p, ...@@ -806,6 +806,17 @@ int kfd_wait_on_events(struct kfd_process *p,
break; break;
} }
/* Set task state to interruptible sleep before
* checking wake-up conditions. A concurrent wake-up
* will put the task back into runnable state. In that
* case schedule_timeout will not put the task to
* sleep and we'll get a chance to re-check the
* updated conditions almost immediately. Otherwise,
* this race condition would lead to a soft hang or a
* very long sleep.
*/
set_current_state(TASK_INTERRUPTIBLE);
if (test_event_condition(all, num_events, event_waiters)) { if (test_event_condition(all, num_events, event_waiters)) {
if (copy_signaled_event_data(num_events, if (copy_signaled_event_data(num_events,
event_waiters, events)) event_waiters, events))
...@@ -820,7 +831,7 @@ int kfd_wait_on_events(struct kfd_process *p, ...@@ -820,7 +831,7 @@ int kfd_wait_on_events(struct kfd_process *p,
break; break;
} }
timeout = schedule_timeout_interruptible(timeout); timeout = schedule_timeout(timeout);
} }
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment