mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-06 12:06:25 +00:00
hv: vcpu reschedule change to improve performance
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
parent
a0e982ecd4
commit
93001a2a4d
@ -177,9 +177,13 @@ int start_vcpu(struct vcpu *vcpu)
|
|||||||
if (ibrs_type == IBRS_RAW)
|
if (ibrs_type == IBRS_RAW)
|
||||||
msr_write(MSR_IA32_PRED_CMD, PRED_SET_IBPB);
|
msr_write(MSR_IA32_PRED_CMD, PRED_SET_IBPB);
|
||||||
|
|
||||||
|
vcpu->in_rootmode = false;
|
||||||
|
|
||||||
/* Launch the VM */
|
/* Launch the VM */
|
||||||
status = vmx_vmrun(cur_context, VM_LAUNCH, ibrs_type);
|
status = vmx_vmrun(cur_context, VM_LAUNCH, ibrs_type);
|
||||||
|
|
||||||
|
vcpu->in_rootmode = true;
|
||||||
|
|
||||||
/* See if VM launched successfully */
|
/* See if VM launched successfully */
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
if (is_vcpu_bsp(vcpu)) {
|
if (is_vcpu_bsp(vcpu)) {
|
||||||
@ -196,8 +200,11 @@ int start_vcpu(struct vcpu *vcpu)
|
|||||||
exec_vmwrite(VMX_GUEST_RIP, ((rip + instlen) &
|
exec_vmwrite(VMX_GUEST_RIP, ((rip + instlen) &
|
||||||
0xFFFFFFFFFFFFFFFF));
|
0xFFFFFFFFFFFFFFFF));
|
||||||
|
|
||||||
|
vcpu->in_rootmode = false;
|
||||||
/* Resume the VM */
|
/* Resume the VM */
|
||||||
status = vmx_vmrun(cur_context, VM_RESUME, ibrs_type);
|
status = vmx_vmrun(cur_context, VM_RESUME, ibrs_type);
|
||||||
|
|
||||||
|
vcpu->in_rootmode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save guest CR3 register */
|
/* Save guest CR3 register */
|
||||||
|
@ -88,7 +88,7 @@ static bool vcpu_pending_request(struct vcpu *vcpu)
|
|||||||
*/
|
*/
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
/* we have pending IRR */
|
/* we have pending IRR */
|
||||||
vcpu_make_request(vcpu, ACRN_REQUEST_EVENT);
|
//vcpu_make_request(vcpu, ACRN_REQUEST_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vcpu->arch_vcpu.pending_req != 0;
|
return vcpu->arch_vcpu.pending_req != 0;
|
||||||
|
@ -88,10 +88,24 @@ static struct vcpu *select_next_vcpu(int pcpu_id)
|
|||||||
return vcpu;
|
return vcpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* here we assume there is no reschedule request will be made after
|
||||||
|
* acrn_handle_pending_request
|
||||||
|
*/
|
||||||
|
static bool reschedule_need_notify_vcpu(struct vcpu *vcpu)
|
||||||
|
{
|
||||||
|
if (vcpu->in_rootmode)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ((int)get_cpu_id() != vcpu->pcpu_id)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
void make_reschedule_request(struct vcpu *vcpu)
|
void make_reschedule_request(struct vcpu *vcpu)
|
||||||
{
|
{
|
||||||
bitmap_set(NEED_RESCHEDULE,
|
bitmap_set(NEED_RESCHEDULE,
|
||||||
&per_cpu(sched_ctx, vcpu->pcpu_id).flags);
|
&per_cpu(sched_ctx, vcpu->pcpu_id).flags);
|
||||||
|
if (reschedule_need_notify_vcpu(vcpu))
|
||||||
send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU);
|
send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,6 +233,7 @@ struct vcpu {
|
|||||||
struct list_head run_list; /* inserted to schedule runqueue */
|
struct list_head run_list; /* inserted to schedule runqueue */
|
||||||
unsigned long pending_pre_work; /* any pre work pending? */
|
unsigned long pending_pre_work; /* any pre work pending? */
|
||||||
bool launched; /* Whether the vcpu is launched on target pcpu */
|
bool launched; /* Whether the vcpu is launched on target pcpu */
|
||||||
|
bool in_rootmode; /* Whether the vcpu is vm exit and under root mode */
|
||||||
unsigned int paused_cnt; /* how many times vcpu is paused */
|
unsigned int paused_cnt; /* how many times vcpu is paused */
|
||||||
int running; /* vcpu is picked up and run? */
|
int running; /* vcpu is picked up and run? */
|
||||||
int ioreq_pending; /* ioreq is ongoing or not? */
|
int ioreq_pending; /* ioreq is ongoing or not? */
|
||||||
|
Loading…
Reference in New Issue
Block a user