From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: mm_pages_next() question Date: Tue, 31 Mar 2009 13:18:31 -0300 Message-ID: <20090331161831.GA4131@amt.cnet> References: <49CF6868.7040205@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: KVM list To: Avi Kivity Return-path: Received: from mx2.redhat.com ([66.187.237.31]:42370 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754039AbZCaQSj (ORCPT ); Tue, 31 Mar 2009 12:18:39 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n2VGIbM2001990 for ; Tue, 31 Mar 2009 12:18:37 -0400 Content-Disposition: inline In-Reply-To: <49CF6868.7040205@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, Mar 29, 2009 at 03:24:08PM +0300, Avi Kivity wrote: >> static int mmu_pages_next(struct kvm_mmu_pages *pvec, >> struct mmu_page_path *parents, >> int i) >> { >> int n; >> >> for (n = i+1; n < pvec->nr; n++) { >> struct kvm_mmu_page *sp = pvec->page[n].sp; >> >> if (sp->role.level == PT_PAGE_TABLE_LEVEL) { >> parents->idx[0] = pvec->page[n].idx; >> return n; >> } >> >> parents->parent[sp->role.level-2] = sp; >> parents->idx[sp->role.level-1] = pvec->page[n].idx; >> } >> >> return n; >> } > > Do we need to break out of the loop if we switch parents during the loop > (since that will give us a different mmu_page_path)? Or are callers > careful to only pass pvecs which belong to the same shadow page? This function builds mmu_page_path for a number of pagetable (leaf) pages. Whenever the path changes, mmu_page_path will be rebuilt. The pages in the pvec must be organized as follows: level4, level3, level2, level1, level1, level1, ...., level3, level2, level1, level1, ... So you don't have to repeat higher levels for a number of leaf pages.