[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



> 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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.