From: Roman Kagan <rkagan@virtuozzo.com>
To: "Mika Penttilä" <mika.penttila@nextfour.com>
Cc: <kvm@vger.kernel.org>
Subject: Re: [PATCH 1/5] kvm/x86: fix inversed check for async_pf MSR
Date: Fri, 2 Dec 2016 20:02:35 +0300 [thread overview]
Message-ID: <20161202170234.GD27461@rkaganb.sw.ru> (raw)
In-Reply-To: <1ec66517-cf27-80fd-a49f-000fd873698e@nextfour.com>
On Fri, Dec 02, 2016 at 05:24:55PM +0200, Mika Penttilä wrote:
> > > > > > --- a/arch/x86/kvm/x86.c
> > > > > > +++ b/arch/x86/kvm/x86.c
> > > > > > @@ -8402,7 +8402,7 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,
> > > > > > bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu)
> > > > > > {
> > > > > > if (!(vcpu->arch.apf.msr_val & KVM_ASYNC_PF_ENABLED))
> > > > > > - return true;
> > > > > > + return false;
> > > > > >
> > > > > >
> > > > > Why do you make this change?
> > >
> > > > Because the code does the opposite of what it's meant to do.
> > >
> > > It could have a better name but returning "true" is right. See below.
> > >
> > > > > I think kvm_arch_async_page_present() is not
> > > > > ever called now and neither kvm_del_async_pf_gfn(vcpu, work->arch.gfn);
> > > > I wonder how you came to such a conclusion? I certainly see them called
> > > > on my test machine (you need to have the guest memory swapped out for
> > > > that, that can be forced e.g. using a memory cgroup).
> > > if !KVM_ASYNC_PF_ENABLED then kvm_check_async_pf_completion(), it's only call site, never calls it.
>
> > How's that? I don't see any check for it in
> > kvm_check_async_pf_completion(). Moreover, that's exactly where it does
> > that check.
>
> void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu)
> {
> struct kvm_async_pf *work;
>
> while (!list_empty_careful(&vcpu->async_pf.done) &&
> kvm_arch_can_inject_async_page_present(vcpu)) {
> spin_lock(&vcpu->async_pf.lock);
>
>
> and you made kvm_arch_can_inject_async_page_present(vcpu) return false if !KVM_ASYNC_PF_ENABLED (i.e. not enabled)
>
>
> > > Maybe you had KVM_ASYNC_PF_ENABLED?
>
> > Of course I did. Not sure I get what you mean...
>
> I mean if the guest support for async pf is not enabled you maybe broke that?
Ah I finally see the light, thank you.
Apparently disabling async_pf by the guest should result in draining all
accumulated async pagefaults but without injecting #PF in the guest.
The latter is taken care of by another check for the msr value in
kvm_arch_async_page_present().
My patch is wrong indeed; I was misled by the "self-explanatory"
function name which was bogus.
I'll cook up another patch renaming the function and putting a comment
there, too.
Thanks,
Roman.
next prev parent reply other threads:[~2016-12-02 18:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-02 15:24 [PATCH 1/5] kvm/x86: fix inversed check for async_pf MSR Mika Penttilä
2016-12-02 17:02 ` Roman Kagan [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-12-02 14:14 Mika Penttilä
2016-12-02 14:31 ` Roman Kagan
[not found] <a237e9b7-8155-5006-81b1-ac77a5efd13d@nextfour.com>
2016-12-02 10:45 ` Mika Penttilä
2016-12-02 12:05 ` Roman Kagan
2016-12-02 8:47 [PATCH 0/5] kvm: avoid delaying async_pf ready delivery Roman Kagan
2016-12-02 8:47 ` [PATCH 1/5] kvm/x86: fix inversed check for async_pf MSR Roman Kagan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161202170234.GD27461@rkaganb.sw.ru \
--to=rkagan@virtuozzo.com \
--cc=kvm@vger.kernel.org \
--cc=mika.penttila@nextfour.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox