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] RFC: Superpage/hugepage performance improvement

To: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
Subject: Re: [Xen-devel] RFC: Superpage/hugepage performance improvement
From: Dave McCracken <dcm@xxxxxxxx>
Date: Tue, 6 Apr 2010 09:12:27 -0500
Cc: Jeremy Fitzhardinge <jeremy@xxxxxxxx>, Xen Developers List <xen-devel@xxxxxxxxxxxxxxxxxxx>, Keir Fraser <Keir.Fraser@xxxxxxxxxxxxx>
Delivery-date: Tue, 06 Apr 2010 07:13:05 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:subject:date :user-agent:cc:references:in-reply-to:mime-version:content-type :content-transfer-encoding:message-id; bh=zMOcb+UEcnPq+kqlo6hVwIYMfBjT33bpw4JmNNxN4PI=; b=xlUOhabJWTQBiy5kWY6t/MjuMnYudZfXPi9CH9Y8M0SndRXCuAfcp5Vx2miNTyZXnp 9JqGw+868+lrSEFxzOl78AvLoSHuh62lS+FtBv9r1+zqkKsOWZAai09660sNftcc4Nap Pu3JU+woif81efsg/f6k4JgwXE3FR+nnxh9bE=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; b=gw+E6ubSQhwnXlWNxAi6Jo3b/+GkHjLSsGdkPXnEb3vsD8o49ARBglebzG1EreVPYc 8MGpZEP/PQCzcPBkyQDEaVTWpxu2lVBvLwXV8Oojcpiup8+qGB9t/vnMXKy1RqKgt5QE DryeH/hmlfG5J1DselL7JWeJGcFSL0JZtpuZY=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20100406092901.GD15578@xxxxxxxxxxxxxxxxxxxxxxx>
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/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <201004051252.29210.dcm@xxxxxxxx> <20100406092901.GD15578@xxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: KMail/1.12.4 (Linux/2.6.32; KDE/4.3.4; x86_64; ; )
On Tuesday 06 April 2010, Tim Deegan wrote:
> At 18:52 +0100 on 05 Apr (1270493549), Dave McCracken wrote:
> > In our testing we found that the superpage/hugepage mapping code is
> > seriously bogged down by the need to maintain the reference count on
> > each of the underlying pages every time a hugepage is mapped.  I came
> > up with a fix where a guest can call into the hypervisor to mark a set
> > of pages as a superpage, thus locking that set of pages to be
> > read/write data pages until the corresponding unmark is call is made.
> 
> Hmm.  That sounds OK, as long as we haven't ended up with a way for a
> guest to manipulate Xen's typecounts (either by double-freeing and
> underflowing them or by leaving typecounts non-zero on domain
> destruction).  How does it work internally?  Does it take a typecount
> on each page and keep a separate flag/refcount per superpage so the
> guest can't double-free?

I do set a flag on the leading page of the superpage, and increment the 
writable typecount on each of the underlying pages.  Then when the page is 
subsequently mapped I only increment the typecount of the leading page.
 
Setting and unsetting the superpage flag can not be nested.  Attempts to double 
free will be rejected.

> How is it synchronized with PTE changes?  e.g. how do we make sure that
> all the superpage PTEs that map an area of memory are are gone before
> the guest can unmark the memory?

Hmm... I don't have a bulletproof solution to that one yet.  It's complicated 
by the fact that on Linux, at least, all free pages may have a writable 
typecount of either 0 or 1, depending on whether they're highmem pages.
 
> And I guess it's up to the guest to make sure that no pagetables,
> decriptor tables, &c end up in that memory.

Yes, that's correct.  This mechanism is fundamentally incompatible with using 
the pages for anything other than writable data.  Their attempts should fail.

> > To make this work I added two mmuext ops, one to mark a superpage and
> > one to unmark it.  This change makes a huge performance difference in
> > the hugepage mapping (on the order of 50 times faster).
> 
> Plus, presumably, some noticeable difference on a macro benchmark. (I
> expect that's the case but I've been wrong before.)

The original reason I came up with this mechanism was that one of our real 
applications would not run due to the poor performance.  They have something 
like a 64G region fully populated with hugepages.  This region has to be 
mapped in the child on every fork.  It was so slow their operations were 
timing out.

Dave McCracken
Oracle Corp.

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

<Prev in Thread] Current Thread [Next in Thread>