[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87v9jy9fzg.fsf@vitty.brq.redhat.com>
Date: Thu, 11 Jun 2020 10:14:11 +0200
From: Vitaly Kuznetsov <vkuznets@...hat.com>
To: Vivek Goyal <vgoyal@...hat.com>
Cc: kvm@...r.kernel.org, Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <sean.j.christopherson@...el.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] KVM: async_pf: Inject 'page ready' event only if 'page not present' was previously injected
Vivek Goyal <vgoyal@...hat.com> writes:
> On Wed, Jun 10, 2020 at 07:55:32PM +0200, Vitaly Kuznetsov wrote:
>> 'Page not present' event may or may not get injected depending on
>> guest's state. If the event wasn't injected, there is no need to
>> inject the corresponding 'page ready' event as the guest may get
>> confused. E.g. Linux thinks that the corresponding 'page not present'
>> event wasn't delivered *yet* and allocates a 'dummy entry' for it.
>> This entry is never freed.
>>
>> Note, 'wakeup all' events have no corresponding 'page not present'
>> event and always get injected.
>>
>> s390 seems to always be able to inject 'page not present', the
>> change is effectively a nop.
>>
>> Suggested-by: Vivek Goyal <vgoyal@...hat.com>
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
>> ---
>> arch/s390/include/asm/kvm_host.h | 2 +-
>> arch/s390/kvm/kvm-s390.c | 4 +++-
>> arch/x86/include/asm/kvm_host.h | 2 +-
>> arch/x86/kvm/x86.c | 7 +++++--
>> include/linux/kvm_host.h | 1 +
>> virt/kvm/async_pf.c | 2 +-
>> 6 files changed, 12 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
>> index 3d554887794e..cee3cb6455a2 100644
>> --- a/arch/s390/include/asm/kvm_host.h
>> +++ b/arch/s390/include/asm/kvm_host.h
>> @@ -978,7 +978,7 @@ bool kvm_arch_can_dequeue_async_page_present(struct kvm_vcpu *vcpu);
>> void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu,
>> struct kvm_async_pf *work);
>>
>> -void kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu,
>> +bool kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu,
>> struct kvm_async_pf *work);
>
> Hi Vitaly,
>
> A minor nit. Using return code to figure out if exception was injected
> or not is little odd. How about we pass a pointer instead as parameter
> and kvm_arch_async_page_not_present() sets it to true if page not
> present exception was injected. This probably will be easier to
> read.
>
> If for some reason you don't like above, atleats it warrants a comment
> explaining what do 0 and 1 mean.
>
I think it's the 'kvm_arch_async_page_not_present' name which is a bit
misleading now, if we rename it to something like
kvm_arch_inject_apf_not_present() then it becomes a bit more clear
what's going on. We may as well write the code as
if (kvm_arch_inject_apf_not_present())
work->notpresent_injected = true;
or change the return type to int so it'll be
if (!kvm_arch_inject_apf_not_present())
work->notpresent_injected = true;
> Otherwise both the patches look good to me. I tested and I can confirm
> that now page ready events are not being delivered to guest if page
> not present was not injected.
Thank you for testing!
--
Vitaly
Powered by blists - more mailing lists