All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Williamson <mark.williamson@cl.cam.ac.uk>
To: tgh <tianguanhua@ncic.ac.cn>
Cc: xen-devel@lists.xensource.com
Subject: Re: question about memory mapping and balloon
Date: Wed, 28 Mar 2007 03:11:15 +0100	[thread overview]
Message-ID: <200703280311.16089.mark.williamson@cl.cam.ac.uk> (raw)
In-Reply-To: <4609BACF.9000009@ncic.ac.cn>

> 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!

      reply	other threads:[~2007-03-28  2:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-26 20:48 Backend device not found error Adit Ranadive
2007-03-27  1:24 ` Akio Takebe
2007-03-27 16:18   ` Adit Ranadive
2007-03-27 23:58     ` Akio Takebe
2007-03-27  2:34 ` question about memory mapping and balloon tgh
2007-03-27  3:45   ` Mark Williamson
2007-03-27  6:46     ` tgh
2007-03-28  0:46       ` tgh
2007-03-28  2:11         ` Mark Williamson [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=200703280311.16089.mark.williamson@cl.cam.ac.uk \
    --to=mark.williamson@cl.cam.ac.uk \
    --cc=tianguanhua@ncic.ac.cn \
    --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.