From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: page table walk in xen_{create, destroy}_contiguous_region Date: Thu, 29 Jun 2006 15:46:18 +0200 Message-ID: <44A3F5CA.76E4.0078.0@novell.com> References: <44A002EC.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartECC906BA.1__=" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartECC906BA.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline >> Is there a particular reason why these functions need to walk the page >> table rather than doing a much cheaper p2m >> translation? vstart is assumed to be in the direct mapping area anyway >> (otherwise the uses of __pa() in the same >> functions wouldn't be valid). >> >> Thanks, Jan > >Looks like the walks are not really needed. Subject: Replace page table walks by simple address calculation Signed-off-by: jbeulich@novell.com Makes the code both smaller and faster. --=__PartECC906BA.1__= Content-Type: text/plain; name="xenlinux-ccr-dcr-no-pgtable-walk.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xenlinux-ccr-dcr-no-pgtable-walk.patch" Index: 2006-06-29/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c =================================================================== --- 2006-06-29.orig/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c 2006-06-29 15:32:32.000000000 +0200 +++ 2006-06-29/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c 2006-06-29 15:32:35.000000000 +0200 @@ -272,10 +272,6 @@ static unsigned long discontig_frames[1< int xen_create_contiguous_region( unsigned long vstart, unsigned int order, unsigned int address_bits) { - pgd_t *pgd; - pud_t *pud; - pmd_t *pmd; - pte_t *pte; unsigned long *in_frames = discontig_frames, out_frame; unsigned long frame, i, flags; long rc; @@ -305,6 +301,9 @@ int xen_create_contiguous_region( if (order > MAX_CONTIG_ORDER) return -ENOMEM; + if (vstart < PAGE_OFFSET || vstart >= (unsigned long)high_memory) + return -EINVAL; + set_xen_guest_handle(exchange.in.extent_start, in_frames); set_xen_guest_handle(exchange.out.extent_start, &out_frame); @@ -314,11 +313,7 @@ int xen_create_contiguous_region( /* 1. Zap current PTEs, remembering MFNs. */ for (i = 0; i < (1UL<> PAGE_SHIFT) + i); if (HYPERVISOR_update_va_mapping(vstart + (i*PAGE_SIZE), __pte_ma(0), 0)) BUG(); @@ -373,10 +368,6 @@ int xen_create_contiguous_region( void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order) { - pgd_t *pgd; - pud_t *pud; - pmd_t *pmd; - pte_t *pte; unsigned long *out_frames = discontig_frames, in_frame; unsigned long frame, i, flags; long rc; @@ -401,6 +392,9 @@ void xen_destroy_contiguous_region(unsig if (order > MAX_CONTIG_ORDER) return; + if (vstart < PAGE_OFFSET || vstart >= (unsigned long)high_memory) + return; + set_xen_guest_handle(exchange.in.extent_start, &in_frame); set_xen_guest_handle(exchange.out.extent_start, out_frames); @@ -411,11 +405,7 @@ void xen_destroy_contiguous_region(unsig contiguous_bitmap_clear(__pa(vstart) >> PAGE_SHIFT, 1UL << order); /* 1. Find start MFN of contiguous extent. */ - pgd = pgd_offset_k(vstart); - pud = pud_offset(pgd, vstart); - pmd = pmd_offset(pud, vstart); - pte = pte_offset_kernel(pmd, vstart); - in_frame = pte_mfn(*pte); + in_frame = pfn_to_mfn(__pa(vstart) >> PAGE_SHIFT); /* 2. Zap current PTEs. */ for (i = 0; i < (1UL<