From d531e84d3209eea44ac7db27ff39ecf1b81cb239 Mon Sep 17 00:00:00 2001 From: Conghui Chen Date: Thu, 30 Jul 2020 11:34:44 +0000 Subject: [PATCH] hv: fix deadloop in sleep_thread_sync As we only set BLOCKED status in context switch_out, which means, only running thread can be changed to BLOCKED, but runnable thread can not. This lead to the deadloop in sleep_thread_sync. To solve the problem, in sleep_thread, we set the status to BLOCKED directly when the original thread status is RUNNABLE. Tracked-On: #5115 Signed-off-by: Conghui Chen --- hypervisor/common/schedule.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hypervisor/common/schedule.c b/hypervisor/common/schedule.c index 8dee0f41a..c9443866f 100644 --- a/hypervisor/common/schedule.c +++ b/hypervisor/common/schedule.c @@ -203,8 +203,10 @@ void sleep_thread(struct thread_object *obj) } else { make_reschedule_request(pcpu_id, DEL_MODE_IPI); } + obj->be_blocking = true; + } else { + set_thread_status(obj, THREAD_STS_BLOCKED); } - obj->be_blocking = true; release_schedule_lock(pcpu_id, rflag); }