mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-23 01:37:44 +00:00
scheduler: make scheduling based on struct sched_object
use struct sched_object as the main interface of scheduling, then make scheduler as an independent module to vcpu: - add struct sched_object as one field in struct vcpu - define sched_object.thread for switch_to thread - define sched_object.prepare_switch_out/in for prepare_switch before switch_to - move context_switch_out/context_switch_in into vcpu.c as vcpu.sched_obj.prepare_switch_out/in - make default_idle as global idle.thread for idle_thread - make vcpu_thread as vcpu.sched_obj.thread for each vcpu thread - simplify switch_to based on sched_object Tracked-On: #1842 Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <edide.dong@intel.com>
This commit is contained in:
@@ -600,6 +600,34 @@ void resume_vcpu(struct acrn_vcpu *vcpu)
|
||||
release_schedule_lock(vcpu->pcpu_id);
|
||||
}
|
||||
|
||||
static void context_switch_out(struct sched_object *prev)
|
||||
{
|
||||
struct acrn_vcpu *vcpu = list_entry(prev, struct acrn_vcpu, sched_obj);
|
||||
|
||||
/* cancel event(int, gp, nmi and exception) injection */
|
||||
cancel_event_injection(vcpu);
|
||||
|
||||
atomic_store32(&vcpu->running, 0U);
|
||||
/* do prev vcpu context switch out */
|
||||
/* For now, we don't need to invalid ept.
|
||||
* But if we have more than one vcpu on one pcpu,
|
||||
* we need add ept invalid operation here.
|
||||
*/
|
||||
}
|
||||
|
||||
static void context_switch_in(struct sched_object *next)
|
||||
{
|
||||
struct acrn_vcpu *vcpu = list_entry(next, struct acrn_vcpu, sched_obj);
|
||||
|
||||
atomic_store32(&vcpu->running, 1U);
|
||||
/* FIXME:
|
||||
* Now, we don't need to load new vcpu VMCS because
|
||||
* we only do switch between vcpu loop and idle loop.
|
||||
* If we have more than one vcpu on on pcpu, need to
|
||||
* add VMCS load operation here.
|
||||
*/
|
||||
}
|
||||
|
||||
void schedule_vcpu(struct acrn_vcpu *vcpu)
|
||||
{
|
||||
vcpu->state = VCPU_RUNNING;
|
||||
@@ -625,6 +653,9 @@ int32_t prepare_vcpu(struct acrn_vm *vm, uint16_t pcpu_id)
|
||||
set_pcpu_used(pcpu_id);
|
||||
|
||||
INIT_LIST_HEAD(&vcpu->sched_obj.run_list);
|
||||
vcpu->sched_obj.thread = vcpu_thread;
|
||||
vcpu->sched_obj.prepare_switch_out = context_switch_out;
|
||||
vcpu->sched_obj.prepare_switch_in = context_switch_in;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@@ -69,7 +69,7 @@ static void enter_guest_mode(uint16_t pcpu_id)
|
||||
}
|
||||
#endif
|
||||
|
||||
default_idle();
|
||||
switch_to_idle(default_idle);
|
||||
|
||||
/* Control should not come here */
|
||||
cpu_dead();
|
||||
|
Reference in New Issue
Block a user