Anthony Liguori wrote:
> Dong, Eddie wrote:
>> Anthony Liguori wrote:
>> 
>>> This should get moved to kvm_resched() since both VT/SVM would
>>> benefit from this. 
>>> 
>>> 
>> I would suggest we just add similar code in SVM side. After we
>> optimize the MSR/VMCS register save/restore to skip for
>> those lightweight VM EXIT (handled by KVM). Giving up preemption
>>  disable in kvm_resched means we need to do a full context
>> restore for host which is architecture specific.
>> 
> 
> The only time we'll give up preemption disable in kvm_resched is if
> need_resched() is true.  This is fine since it's time to lose our time
> slice anyway.
> 
> I was thinking that kvm_resched should look like:
> 
> void kvm_resched(struct kvm_vcpu *vcpu)
> {
>     if (need_resched()) {
>         vcpu_put(vcpu);
>         cond_resched();
>         vcpu_load(vcpu);
>    }
> }

Yes, this is true for today. But if the heavy MSR restore is only be
done for non lightweight VM Exit, that means
 void kvm_resched(struct kvm_vcpu *vcpu)
 {
     if (need_resched()) {
         /* restore host MSR register etc */
         vcpu_put(vcpu);
         cond_resched();
         vcpu_load(vcpu);
    }
 }

Then the whole vmx_vcpu_run will look like:
vmx_vcpu_run()
{
        /* save host MSR register etc. */
again:  /* lightweight VM EXIT loop start here */
        ....
        VM RESUME
kvm_vmx_return: 
        r = kvm_handle_exit()
        if ( r > 0 ) {
                ...
                ...
                if ( !need_resched())  goto again       /* light weight
VM EXIT & no reschedule */
        }
out:    /* heavy weight VM EXIT or need_resched */
        /* restore host MSR register etc. */
        return r;
}

In this case, IOCTL return to Qemu will trigger scheduling at least.

Maybe I miss something.

thx,eddie

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to