From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Mika_Penttil=c3=a4?= Subject: Re: [PATCH 1/5] kvm/x86: fix inversed check for async_pf MSR Date: Fri, 2 Dec 2016 17:24:55 +0200 Message-ID: <1ec66517-cf27-80fd-a49f-000fd873698e@nextfour.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: , Return-path: Received: from mail-he1eur01on0063.outbound.protection.outlook.com ([104.47.0.63]:36112 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750750AbcLBQA5 (ORCPT ); Fri, 2 Dec 2016 11:00:57 -0500 Sender: kvm-owner@vger.kernel.org List-ID: > > > > > --- 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? --Mika