hv: sched: remove do_switch

Clean up do_swtich and do switch related things in schedule().

Tracked-On: #3813
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Signed-off-by: Yu Wang <yu1.wang@intel.com>
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Shuo A Liu 2019-06-17 17:50:56 +08:00 committed by wenlingz
parent f04c491259
commit 15c6a3e31f

View File

@ -145,20 +145,6 @@ bool need_reschedule(uint16_t pcpu_id)
return bitmap_test(NEED_RESCHEDULE, &ctl->flags); return bitmap_test(NEED_RESCHEDULE, &ctl->flags);
} }
static void do_switch(struct thread_object *prev, struct thread_object *next)
{
if ((prev != NULL) && (prev->switch_out != NULL)) {
prev->switch_out(prev);
}
/* update current object */
get_cpu_var(sched_ctl).curr_obj = next;
if ((next != NULL) && (next->switch_in != NULL)) {
next->switch_in(next);
}
}
void schedule(void) void schedule(void)
{ {
uint16_t pcpu_id = get_pcpu_id(); uint16_t pcpu_id = get_pcpu_id();
@ -177,12 +163,18 @@ void schedule(void)
set_thread_status(prev, THREAD_STS_RUNNABLE); set_thread_status(prev, THREAD_STS_RUNNABLE);
} }
set_thread_status(next, THREAD_STS_RUNNING); set_thread_status(next, THREAD_STS_RUNNING);
ctl->curr_obj = next;
release_schedule_lock(pcpu_id);
if (prev == next) { /* If we picked different sched object, switch context */
release_schedule_lock(pcpu_id); if (prev != next) {
} else { if ((prev != NULL) && (prev->switch_out != NULL)) {
do_switch(prev, next); prev->switch_out(prev);
release_schedule_lock(pcpu_id); }
if ((next != NULL) && (next->switch_in != NULL)) {
next->switch_in(next);
}
arch_switch_to(&prev->host_sp, &next->host_sp); arch_switch_to(&prev->host_sp, &next->host_sp);
} }