xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: George Dunlap <George.Dunlap@eu.citrix.com>
To: James Harper <james.harper@bendigoit.com.au>
Cc: Tim Deegan <Tim.Deegan@eu.citrix.com>,
	Paul Durrant <Paul.Durrant@citrix.com>,
	xen devel <xen-devel@lists.xensource.com>
Subject: Re: what happens when a PoD page is touched?
Date: Tue, 17 May 2011 14:00:47 +0100	[thread overview]
Message-ID: <BANLkTinN-1sxKT5kbSbHG-gOMipundQSRQ@mail.gmail.com> (raw)
In-Reply-To: <AEC6C66638C05B468B556EA548C1A77D01D5714A@trantor>

On Tue, May 17, 2011 at 10:37 AM, James Harper
<james.harper@bendigoit.com.au> wrote:
> I still can't quite get my head around why this happens at all... I
> thought it would go like this:
>
> 1. Allocate 1MB of memory
> 2. Still under our limit so xen populates the pages when Windows clears
> them
> 3. Hand them back to xen
> 4. Repeat
>
> I'm doing that in a tight loop very early in boot. If I keep handing
> back pages (and thus reducing my populated page count) why am I hitting
> any PoD limit at all and invoking the page scavenging code? Windows
> isn't doing anything else at this point, and even if it was, I'm the
> boot driver so it has to wait for me before the boot can progress so
> it's not like it would be consuming gigabytes of memory.

Suppose for simplicity we're using 1G pages and not splintering them.

Suppose we boot a VM with 8G maxmem, 4G memory.

* Domain built
pages 0-7 are PoD, 4 pages in PoD pool.

* HVMLoader loaded into memory
Page 0 populated; 1-7 PoD, 3 pages in PoD pool

* Windows boots, starts scrubbing (from top of memory)
 + page 7 populated, 2 pages in PoD pool.
 + Page 6 populated, 1 page in PoD pool
 + Page 5 populated, 0 pages in PoD pool
 + Page 4 touched
  - emergency sweep marks page 7 PoD; page 4 populated
 + Page 3 touched
  - emergency sweep marks page 6 PoD; page 3 populated
 etc
 + page 1 touched
  - emergency sweep marks page 5 PoD; page 1 populated
 + Result at the end: pages 0-4 populated, 5-7 PoD, no pages in PoD pool


* Balloon driver starts.
 Let's suppose Windows happens to do all allocation from the PoD region.
 + Asks windows for 1 page
  - Windows chooses page 6, scrubs it.
  - emergency sweep marks page 4 PoD, populates page 6
  - Balloon driver hands page 6 back to Xen
  - page 5 marked empty; page put in PoD pool
 + Asks Windows for 1 more page
  - Windows chooses page 5, scrubs it.
  - Xen fills page 5 with the page in the PoD pool; PoD now empty
  - Balloon driver hands page 5 back to Xen
  - page 5 marked empty; page put in PoD pool
 + Repeat previous

So in theory, once you get your initial allocation from Windows, you
shouldn't have to do any sweeps.

The exception to this would be the case where you're allocating N
pages, where N > (used_pages - total allocation).

I guess try allocating fewer pages before returning them to Xen, and
seeing if that helps at all.

Hmm -- looks like I didn't upstream my PoD tracing patch, otherwise we
could see what was going on.  If you're interested in taking a look at
what's happening at a PoD level, I can try to dig it up and send it to
you.  (Probably need some porting because of the p2m restructuring Tim
Deegan has been doing.)

Peace,
 -George

  reply	other threads:[~2011-05-17 13:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-15 10:16 what happens when a PoD page is touched? James Harper
2011-05-16  8:39 ` Tim Deegan
2011-05-16  9:16   ` Paul Durrant
2011-05-16  9:21     ` James Harper
2011-05-16  9:17   ` James Harper
2011-05-16  9:39     ` Tim Deegan
2011-05-16  9:21   ` Paul Durrant
2011-05-16  9:22     ` James Harper
2011-05-16  9:27       ` Paul Durrant
2011-05-16 23:39         ` James Harper
2011-05-17  9:28           ` Paul Durrant
2011-05-17  9:37             ` James Harper
2011-05-17 13:00               ` George Dunlap [this message]
2011-05-18  4:52                 ` James Harper
2011-05-18  5:20                   ` James Harper
2011-05-18 10:23                   ` Jan Beulich
2011-05-17 11:32             ` George Dunlap
2011-05-16 10:05       ` George Dunlap
2011-05-16 23:42         ` James Harper

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=BANLkTinN-1sxKT5kbSbHG-gOMipundQSRQ@mail.gmail.com \
    --to=george.dunlap@eu.citrix.com \
    --cc=Paul.Durrant@citrix.com \
    --cc=Tim.Deegan@eu.citrix.com \
    --cc=james.harper@bendigoit.com.au \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).