From 7602304692d33a69ab1a5f34b8e9e07869a682c2 Mon Sep 17 00:00:00 2001 From: Shuo A Liu Date: Mon, 3 Aug 2020 10:53:35 +0800 Subject: [PATCH] hv: Fix thread status mess if wake_thread() happens in transition stage 2abbb99f6ac5 ("hv: make thread status more accurate") introduced a transition stage, marked as var be_blocking, between RUNNING->BLOCKED of thread status. wake_thread() does not work in this transition stage because it only checks thread->status. Need to check thread->be_blocking as well in wake_thread(). When wake_thread() happens in the transition stage, the previous sleep operation rolled back. Tracked-On: #5190 Fixes: 2abbb99f6ac5 ("hv: make thread status more accurate") Signed-off-by: Conghui Chen Signed-off-by: Shuo A Liu --- hypervisor/common/schedule.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hypervisor/common/schedule.c b/hypervisor/common/schedule.c index c9443866f..2986718be 100644 --- a/hypervisor/common/schedule.c +++ b/hypervisor/common/schedule.c @@ -225,13 +225,16 @@ void wake_thread(struct thread_object *obj) uint64_t rflag; obtain_schedule_lock(pcpu_id, &rflag); - if (is_blocked(obj)) { + if (is_blocked(obj) || obj->be_blocking) { scheduler = get_scheduler(pcpu_id); if (scheduler->wake != NULL) { scheduler->wake(obj); } - set_thread_status(obj, THREAD_STS_RUNNABLE); - make_reschedule_request(pcpu_id, DEL_MODE_IPI); + if (is_blocked(obj)) { + set_thread_status(obj, THREAD_STS_RUNNABLE); + make_reschedule_request(pcpu_id, DEL_MODE_IPI); + } + obj->be_blocking = false; } release_schedule_lock(pcpu_id, rflag); }