2019-08-02 09:37:36

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [RFC PATCH v2 10/19] RISC-V: KVM: Handle WFI exits for VCPU

On 02/08/19 09:47, Anup Patel wrote:
> + if (!kvm_riscv_vcpu_has_interrupt(vcpu)) {

This can be kvm_arch_vcpu_runnable instead, since kvm_vcpu_block will
check it anyway before sleeping.

Paolo

> + kvm_vcpu_block(vcpu);
> + kvm_clear_request(KVM_REQ_UNHALT, vcpu);
> + }


2019-08-05 07:13:40

by Anup Patel

[permalink] [raw]
Subject: Re: [RFC PATCH v2 10/19] RISC-V: KVM: Handle WFI exits for VCPU

On Fri, Aug 2, 2019 at 2:33 PM Paolo Bonzini <[email protected]> wrote:
>
> On 02/08/19 09:47, Anup Patel wrote:
> > + if (!kvm_riscv_vcpu_has_interrupt(vcpu)) {
>
> This can be kvm_arch_vcpu_runnable instead, since kvm_vcpu_block will
> check it anyway before sleeping.

I think we can skip this check here because kvm_vcpu_block() is
checking it anyway. Agree ??

Regards,
Anup

2019-08-05 07:15:43

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [RFC PATCH v2 10/19] RISC-V: KVM: Handle WFI exits for VCPU

On 05/08/19 09:12, Anup Patel wrote:
> On Fri, Aug 2, 2019 at 2:33 PM Paolo Bonzini <[email protected]> wrote:
>>
>> On 02/08/19 09:47, Anup Patel wrote:
>>> + if (!kvm_riscv_vcpu_has_interrupt(vcpu)) {
>>
>> This can be kvm_arch_vcpu_runnable instead, since kvm_vcpu_block will
>> check it anyway before sleeping.
>
> I think we can skip this check here because kvm_vcpu_block() is
> checking it anyway. Agree ??

Yes, but it's quite a bit faster to do this outside the call. There's a
bunch of setup before kvm_vcpu_block reaches that point, and it includes
mfences too once you add srcu_read_unlock/lock here.

Paolo

2019-08-05 07:20:41

by Anup Patel

[permalink] [raw]
Subject: Re: [RFC PATCH v2 10/19] RISC-V: KVM: Handle WFI exits for VCPU

On Mon, Aug 5, 2019 at 12:44 PM Paolo Bonzini <[email protected]> wrote:
>
> On 05/08/19 09:12, Anup Patel wrote:
> > On Fri, Aug 2, 2019 at 2:33 PM Paolo Bonzini <[email protected]> wrote:
> >>
> >> On 02/08/19 09:47, Anup Patel wrote:
> >>> + if (!kvm_riscv_vcpu_has_interrupt(vcpu)) {
> >>
> >> This can be kvm_arch_vcpu_runnable instead, since kvm_vcpu_block will
> >> check it anyway before sleeping.
> >
> > I think we can skip this check here because kvm_vcpu_block() is
> > checking it anyway. Agree ??
>
> Yes, but it's quite a bit faster to do this outside the call. There's a
> bunch of setup before kvm_vcpu_block reaches that point, and it includes
> mfences too once you add srcu_read_unlock/lock here.

No problem, I will use kvm_arch_vcpu_runnable() here.

Regards,
Anup