[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200610195725.GA263462@redhat.com>
Date: Wed, 10 Jun 2020 15:57:25 -0400
From: Vivek Goyal <vgoyal@...hat.com>
To: Sean Christopherson <sean.j.christopherson@...el.com>
Cc: Vitaly Kuznetsov <vkuznets@...hat.com>, kvm@...r.kernel.org,
Paolo Bonzini <pbonzini@...hat.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
On Wed, Jun 10, 2020 at 12:47:38PM -0700, Sean Christopherson wrote:
> On Wed, Jun 10, 2020 at 03:32:11PM -0400, Vivek Goyal wrote:
> > 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.
> >
> > 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.
>
> Why does kvm_arch_async_page_not_present() need to "return" anything? It
> has access to @work, e.g. simply replace "return true" with
> "work->notpresent_injected = true".
We could do it and I thought about it. But modifying work->notpresent_injected
inside kvm_arch_async_page_not_present() again feels very unintuitive.
I personally find it better that initialization of
work->notpresent_injected is very explicit at the site where this
structure has been allocated and being initialized. (Instead of a
a callee function silently initializing a filed of this structure).
Thanks
Vivek
Powered by blists - more mailing lists