From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH 08/12] KVM: MMU: move zap/flush to kvm_mmu_get_page Date: Thu, 25 Feb 2016 15:32:49 +0800 Message-ID: <56CEAE21.90601@linux.intel.com> References: <1456319873-34182-1-git-send-email-pbonzini@redhat.com> <1456319873-34182-9-git-send-email-pbonzini@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: yoshikawa_takuya_b1@lab.ntt.co.jp, mtosatti@redhat.com To: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Return-path: In-Reply-To: <1456319873-34182-9-git-send-email-pbonzini@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 02/24/2016 09:17 PM, Paolo Bonzini wrote: > kvm_mmu_get_page is the only caller of kvm_sync_page_transient > and kvm_sync_pages. Moving the handling of the invalid_list there > removes the need for the underdocumented kvm_sync_page_transient > function. > > Signed-off-by: Paolo Bonzini > --- > Guangrong, at this point I am confused about why > kvm_sync_page_transient didn't clear sp->unsync. Do > you remember? Or perhaps kvm_mmu_get_page could just > call kvm_sync_page now? > It is the optimization to reduce write-protect as changing unsync to sync need to write-protect the page and sync all sptes pointing to the same gfn. However, after syncing the content between unsync-ed spte and guest pte, we can reuse this spte perfectly. > Also, can you explain the need_sync variable in > kvm_mmu_get_page? This is because we need to to protect the semanteme of 'unsync spte' as only the spte on last level (level = 1) can be unsync so that if a spte on the upper level is created we should eliminate all the unsync sptes pointing to the same gfn. As you have already merged this patchset to the kvm tree, i will post a patch to comment these cases to make the code be more understandable.