From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH v3 16/19] KVM: MMU: lockless walking shadow page table Date: Thu, 07 Jul 2011 03:26:14 +0800 Message-ID: <4E14B6D6.4020902@cn.fujitsu.com> References: <4E0C3178.2080603@cn.fujitsu.com> <4E0C3337.5040304@cn.fujitsu.com> <20110706180859.GB9820@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Avi Kivity , LKML , KVM To: Marcelo Tosatti Return-path: In-Reply-To: <20110706180859.GB9820@amt.cnet> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 07/07/2011 02:08 AM, Marcelo Tosatti wrote: >> +static void free_pages_rcu(struct rcu_head *head) >> +{ >> + struct kvm_mmu_page *next, *sp; >> + >> + sp = container_of(head, struct kvm_mmu_page, rcu); >> + while (sp) { >> + if (!list_empty(&sp->link)) >> + next = list_first_entry(&sp->link, >> + struct kvm_mmu_page, link); >> + else >> + next = NULL; >> + kvm_mmu_free_page(sp); >> + sp = next; >> + } >> +} > > There is no need for this while loop. > The while loop is needed, since many shadow pages can be freed together in the rcu context, on commit_zap_page path, we only remove the list head, and the shadow page is still listed.