diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 926748f20..5635d716d 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -218,8 +218,6 @@ void init_pcpu_post(uint16_t pcpu_id) pr_fatal("Please apply the latest CPU uCode patch!"); } - init_scheduler(); - /* Initialize interrupts */ init_interrupt(BOOT_CPU_ID); @@ -258,6 +256,8 @@ void init_pcpu_post(uint16_t pcpu_id) wait_sync_change(&pcpu_sync, 0UL); } + init_sched(pcpu_id); + setup_clos(pcpu_id); enable_smep(); diff --git a/hypervisor/common/schedule.c b/hypervisor/common/schedule.c index df252036c..0d2de9322 100644 --- a/hypervisor/common/schedule.c +++ b/hypervisor/common/schedule.c @@ -27,19 +27,13 @@ uint16_t sched_get_pcpuid(const struct thread_object *obj) return obj->pcpu_id; } -void init_scheduler(void) +void init_sched(uint16_t pcpu_id) { - struct sched_control *ctl; - uint32_t i; - uint16_t pcpu_nums = get_pcpu_nums(); + struct sched_control *ctl = &per_cpu(sched_ctl, pcpu_id); - for (i = 0U; i < pcpu_nums; i++) { - ctl = &per_cpu(sched_ctl, i); - - spinlock_init(&ctl->scheduler_lock); - ctl->flags = 0UL; - ctl->curr_obj = NULL; - } + spinlock_init(&ctl->scheduler_lock); + ctl->flags = 0UL; + ctl->curr_obj = NULL; } void get_schedule_lock(uint16_t pcpu_id) diff --git a/hypervisor/include/common/schedule.h b/hypervisor/include/common/schedule.h index 9b7baded9..0228ac9c6 100644 --- a/hypervisor/include/common/schedule.h +++ b/hypervisor/include/common/schedule.h @@ -39,7 +39,7 @@ bool is_idle_thread(const struct thread_object *obj); uint16_t sched_get_pcpuid(const struct thread_object *obj); struct thread_object *sched_get_current(uint16_t pcpu_id); -void init_scheduler(void); +void init_sched(uint16_t pcpu_id); void switch_to_idle(thread_entry_t idle_thread); void get_schedule_lock(uint16_t pcpu_id); void release_schedule_lock(uint16_t pcpu_id);