hv: vcpu reschedule change to improve performance

Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Jason Chen CJ 2018-07-04 13:49:48 +08:00 committed by Yakui Zhao
parent a0e982ecd4
commit 93001a2a4d
4 changed files with 24 additions and 2 deletions

View File

@ -177,9 +177,13 @@ int start_vcpu(struct vcpu *vcpu)
if (ibrs_type == IBRS_RAW)
msr_write(MSR_IA32_PRED_CMD, PRED_SET_IBPB);
vcpu->in_rootmode = false;
/* Launch the VM */
status = vmx_vmrun(cur_context, VM_LAUNCH, ibrs_type);
vcpu->in_rootmode = true;
/* See if VM launched successfully */
if (status == 0) {
if (is_vcpu_bsp(vcpu)) {
@ -196,8 +200,11 @@ int start_vcpu(struct vcpu *vcpu)
exec_vmwrite(VMX_GUEST_RIP, ((rip + instlen) &
0xFFFFFFFFFFFFFFFF));
vcpu->in_rootmode = false;
/* Resume the VM */
status = vmx_vmrun(cur_context, VM_RESUME, ibrs_type);
vcpu->in_rootmode = true;
}
/* Save guest CR3 register */

View File

@ -88,7 +88,7 @@ static bool vcpu_pending_request(struct vcpu *vcpu)
*/
if (ret != 0) {
/* 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;

View File

@ -88,10 +88,24 @@ static struct vcpu *select_next_vcpu(int pcpu_id)
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)
{
bitmap_set(NEED_RESCHEDULE,
&per_cpu(sched_ctx, vcpu->pcpu_id).flags);
if (reschedule_need_notify_vcpu(vcpu))
send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU);
}

View File

@ -233,6 +233,7 @@ struct vcpu {
struct list_head run_list; /* inserted to schedule runqueue */
unsigned long pending_pre_work; /* any pre work pending? */
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 */
int running; /* vcpu is picked up and run? */
int ioreq_pending; /* ioreq is ongoing or not? */