From 6a144e6e3e635759ea22885198620402c0b2d66b Mon Sep 17 00:00:00 2001 From: Shuo A Liu Date: Tue, 18 Jun 2019 18:15:12 +0800 Subject: [PATCH] hv: sched: add yield support Add yield support for schedule, which can give up pcpu proactively. Tracked-On: #4178 Signed-off-by: Jason Chen CJ Signed-off-by: Yu Wang Signed-off-by: Shuo A Liu Acked-by: Eddie Dong --- hypervisor/common/schedule.c | 5 +++++ hypervisor/include/common/schedule.h | 1 + 2 files changed, 6 insertions(+) diff --git a/hypervisor/common/schedule.c b/hypervisor/common/schedule.c index 847bafd03..d9dc619fc 100644 --- a/hypervisor/common/schedule.c +++ b/hypervisor/common/schedule.c @@ -240,6 +240,11 @@ void kick_thread(const struct thread_object *obj) release_schedule_lock(pcpu_id, rflag); } +void yield_current(void) +{ + make_reschedule_request(get_pcpu_id(), DEL_MODE_IPI); +} + void run_thread(struct thread_object *obj) { uint64_t rflag; diff --git a/hypervisor/include/common/schedule.h b/hypervisor/include/common/schedule.h index 5179b5243..9d7c9d398 100644 --- a/hypervisor/include/common/schedule.h +++ b/hypervisor/include/common/schedule.h @@ -109,6 +109,7 @@ void run_thread(struct thread_object *obj); void sleep_thread(struct thread_object *obj); void wake_thread(struct thread_object *obj); void kick_thread(const struct thread_object *obj); +void yield_current(void); void schedule(void); void arch_switch_to(void *prev_sp, void *next_sp);