From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 6/6] KVM: MMU: fast zap all shadow pages Date: Tue, 19 Mar 2013 19:37:37 -0300 Message-ID: <20130319223737.GB18959@amt.cnet> References: <514006AC.2020904@linux.vnet.ibm.com> <514007A0.1040400@linux.vnet.ibm.com> <20130318204601.GA16208@amt.cnet> <5147D63B.4000400@linux.vnet.ibm.com> <20130319144043.GA8767@amt.cnet> <51488642.4060809@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Gleb Natapov , LKML , KVM To: Xiao Guangrong Return-path: Content-Disposition: inline In-Reply-To: <51488642.4060809@linux.vnet.ibm.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Tue, Mar 19, 2013 at 11:37:38PM +0800, Xiao Guangrong wrote: > On 03/19/2013 10:40 PM, Marcelo Tosatti wrote: > > > > > I misunderstood the benefit of your idea (now i got it: zap root > > and flush TLB guarantees vcpus will refault). What i'd like to avoid is > > > > memset(cache, 0, sizeof(*cache)); > > kvm_mmu_init(kvm); > > > > I'd prefer normal operations on those data structures (in mmu_cache). > > And also the page accounting is a problem. > > > > Perhaps you can use a generation number to consider whether shadow pages > > are valid? So: > > > > find_sp(gfn_t gfn) > > lookup hash > > if sp->generation_number != mmu->current_generation_number > > initialize page as if it were just allocated (but keep it in the hash list) > > > > And on kvm_mmu_zap_all() > > spin_lock(mmu_lock) > > for each page > > if page->root_count > > zero sp->spt[] > > > > flush TLB > > mmu->current_generation_number++ > > spin_unlock(mmu_lock) > > > > Then have kvm_mmu_free_all() that actually frees all data. > > > > Hum, not sure if thats any better than your current patchset. > > I also got the idea of generation number like yours which i mentioned > it in the [PATCH 0/6]: > > * TODO > Avoiding Marcelo beat me :), they are some works not attached to make the > patchset more smaller: > (1): batch kvm_reload_remote_mmus for zapping root shadow pages > (2): free shadow pages by using generation-number > (3): remove unneeded kvm_reload_remote_mmus after kvm_mmu_zap_all > (4): drop unnecessary @npages from kvm_arch_create_memslot > (5): rename init_kvm_mmu to init_vcpu_mmu Long patch sets are OK. Problem are unrelated changes in a patchset.