WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] question about memory mapping and balloon

To: tgh <tianguanhua@xxxxxxxxxx>
Subject: Re: [Xen-devel] question about memory mapping and balloon
From: Mark Williamson <mark.williamson@xxxxxxxxxxxx>
Date: Wed, 28 Mar 2007 03:11:15 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 27 Mar 2007 19:10:11 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <4609BACF.9000009@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <d2ad857f0703261348x4dd40b30y71d42f212326a3d6@xxxxxxxxxxxxxx> <4608BDD5.3030401@xxxxxxxxxx> <4609BACF.9000009@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: KMail/1.9.5
> Thank you for your reply

No problems.  We're getting into lower lever stuff than I typically touch on, 
so please bear in mind that my explanations might be bad / incomplete / 
misleading / wrong ;-)  Sorry about that, but I'll try to elaborate on things 
as best I can.

> Mark Williamson 写道:
> >>  In the paravirt case, guestos maintain its own mfn which need m2p and
> >> p2m ,or xen manage these ?
> >
> > The guest is aware of it's mfns.
> >
> > The m2p table is a global machine frame -> pseudophysical frame
> > mapping.  Every guest uses this but is only privileged to update their
> > portions of this.  There's no requirement for it to be global but it
> > saves space this way.
> >
> > The p2m is maintained in the guest's private memory.
>
> I do not understand clearly why does xen maintain m2p table and why
> should the related portion of m2p be exported to the guestOS,and what
> does guestOS do by using m2p

It's not technically necessary for Xen to maintain it; guest OSes could do 
this themselves.  Providing it to guests as a service of Xen is an 
efficiency / simplicity optimisation: guests can index it by mfn and get the 
corresponding pfn out by a simple array access [nb. a side effect is that 
guests can see on another's mfn->pfn mappings].

Because the guests machine memory may be sparse and spread out all over the 
host's RAM, it would not be space efficient for individual guests to maintain 
this mapping as an array - they'd need to use more complex (and slower 
access) data structures instead.  The Xen-provided M2P table allows a simple, 
fast array to be used for this.

The P2M table, on the other hand, can be implemented on a per-guest basis as 
it is densely populated and indexed by the contiguous physical pfns.

The M2P table is used to efficiently map a machine address it needs to operate 
on back to a physical address that the OS core code can understand.  I'm not 
exactly sure where it's used in the code, but I'd guess that page fault / 
swapping code would need to deal with these conversions.

> when a VM boot with memsize=512M ,its p2m maybe only 64M or something
> ,and when guest application request the memory,its virtual memory is
> mapped ,and when the application write some data into that memory,there
> is a page fault araised,and at that time guestOS update p2m and m2p and
> its page table(say virtual-to-machine address) ,is it right? or how do
> xen and guestOS deal with it?

M2P table always contains entries for every machine frame which is currently 
in use on the host.  The P2M mapping is fairly static during the life of the 
guest - as far as I can think of, it only gets changed by ballooning and page 
flipping (i.e. the network driver), so it all gets initialised when the 
domain starts and rarely changes.

Neither the M2P nor the P2m mapping is produced on demand, unlike the way 
pages are typically demand faulted into an address space.

Also: The M2P is machine global and the P2M is domain global, so stuff doesn't 
really happen to those on a per-task basis at all.

HTH,
Cheers,
Mark


-- 
Dave: Just a question. What use is a unicyle with no seat?  And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel