[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c7309380-c7d5-419d-6ba5-25d3243c469b@redhat.com>
Date: Fri, 25 Mar 2022 12:26:56 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>,
Hou Wenlong <houwenlong.hwl@...group.com>
Cc: kvm@...r.kernel.org, Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
Lai Jiangshan <laijs@...ux.alibaba.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: x86/mmu: Don't rebuild page when the page is synced
and no tlb flushing is required
On 3/24/22 21:17, Sean Christopherson wrote:
>> +static int kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
>> struct list_head *invalid_list)
>> {
>> int ret = vcpu->arch.mmu->sync_page(vcpu, sp);
>>
>> - if (ret < 0) {
>> + if (ret < 0)
>> kvm_mmu_prepare_zap_page(vcpu->kvm, sp, invalid_list);
>> - return false;
>> - }
>> -
>> - return !!ret;
>> + return ret;
> Hrm, this creates an oddity in mmu_sync_children(), which does a logical-OR of
> the result into a boolean. It doesn't actually change the functionality since
> kvm_mmu_remote_flush_or_zap() will prioritize invalid_list, but it's weird.
>
> What about checking invalid_list directly and keeping the boolean return? Compile
> tested only.
It's even better to check
flush |= kvm_sync_page(vcpu, sp, &invalid_list) > 0;
in mmu_sync_children. If the returned value is <0, then the page is
added to invalid_list and there is no need to set flush = true, just
like there is no need to call kvm_flush_remote_tlbs() in kvm_mmu_get_page().
Paolo
Powered by blists - more mailing lists