From: "Jan Beulich" <jbeulich@novell.com>
To: Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: xen-devel@lists.xensource.com
Subject: Re: page table walk in xen_{create, destroy}_contiguous_region
Date: Thu, 29 Jun 2006 15:46:18 +0200 [thread overview]
Message-ID: <44A3F5CA.76E4.0078.0@novell.com> (raw)
In-Reply-To: <fa1766bdb58a62435375e894772defa7@cl.cam.ac.uk>
[-- Attachment #1: Type: text/plain, Size: 483 bytes --]
>> 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.
[-- Attachment #2: xenlinux-ccr-dcr-no-pgtable-walk.patch --]
[-- Type: text/plain, Size: 2698 bytes --]
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<<order); i++) {
- pgd = pgd_offset_k(vstart + (i*PAGE_SIZE));
- pud = pud_offset(pgd, (vstart + (i*PAGE_SIZE)));
- pmd = pmd_offset(pud, (vstart + (i*PAGE_SIZE)));
- pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE)));
- in_frames[i] = pte_mfn(*pte);
+ in_frames[i] = pfn_to_mfn((__pa(vstart) >> 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<<order); i++) {
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
prev parent reply other threads:[~2006-06-29 13:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-26 13:53 page table walk in xen_{create, destroy}_contiguous_region Jan Beulich
2006-06-26 21:05 ` Keir Fraser
2006-06-29 13:46 ` Jan Beulich [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44A3F5CA.76E4.0078.0@novell.com \
--to=jbeulich@novell.com \
--cc=Keir.Fraser@cl.cam.ac.uk \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.