2016-03-03 10:42:51

by Suthikulpanit, Suravee

[permalink] [raw]
Subject: Re: [PART1 RFC 5/9] svm: Add VMEXIT handlers for AVIC

Hi

On 02/19/2016 12:18 AM, Paolo Bonzini wrote:
>
>
> On 18/02/2016 17:27, Radim Krčmář wrote:
>> 2016-02-18 16:53+0100, Paolo Bonzini:
>>> Patch 9 is okay, but it is also necessary to clear IsRunning in
>>> kvm_arch_vcpu_blocking and set it in kvm_arch_vcpu_unblocking. In
>>> addition, vcpu_put/vcpu_load should not modify IsRunning between
>>> kvm_arch_vcpu_blocking and kvm_arch_vcpu_unblocking. Do you agree?
>>
>> Yes.
>>
>> I think we don't need to clear IsRunning on preemption, which would
>> simplify the protection. (I haven't thought much about userspace exit,
>> so maybe we could skip that one as well, but we don't need to now.)
>>
>> The reason for that is that KVM knows that the VCPU was scheduled out,
>> so it couldn't do much in the AVIC VMEXIT.
>> (KVM could force scheduler to pritioritize the VCPU, but our kick
>> doesn't do that now and it seems like a bad idea.)
>>
>> Does it seem reasonable?
>
> Yes, and in fact it wouldn't need to clear and set IsRunning on
> vcpu_put/vcpu_load; only on vcpu_blocking/vcpu_unblocking.
>
> The IsRunning flag is more of a IsNotHalted flag, in the end.
>
> Paolo
>

In facts, instead of setting up the vAPIC backing page address when
calling kvm_arch_vcpu_load(), we should be able to do it when calling
kvm_arch_vcpu_sched_in(). This seems more appropriate since the
kvm_arch_vcpu_load() is also called in many unnecessary occasions via
vcpu_load() (in the arch/x86/kvm/x86.c). The same goes for the
kvm_arch_vcpu_put().

However, there is no kvm_arch_vcpu_sched_out(). But that can be added
easily.

What do you think?

Suravee




2016-03-03 10:50:32

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PART1 RFC 5/9] svm: Add VMEXIT handlers for AVIC



On 03/03/2016 11:42, Suravee Suthikulpanit wrote:
> In facts, instead of setting up the vAPIC backing page address when
> calling kvm_arch_vcpu_load(), we should be able to do it when calling
> kvm_arch_vcpu_sched_in(). This seems more appropriate since the
> kvm_arch_vcpu_load() is also called in many unnecessary occasions via
> vcpu_load() (in the arch/x86/kvm/x86.c). The same goes for the
> kvm_arch_vcpu_put().
>
> However, there is no kvm_arch_vcpu_sched_out(). But that can be added
> easily.
>
> What do you think?

How much code is involved? It seems an unnecessary complication...
Unless you can profile a difference, I would leave it in
kvm_arch_vcpu_load()/kvm_arch_vcpu_put().

Note that sched_in and sched_out are not called once per invocation of
KVM_RUN---only through the preempt notifiers. So I'm not sure it is
enough to use sched_in and sched_out.

Paolo