From: "Jan Beulich" Subject: RE: Tmem vs order>0 allocation, workaround RFC Date: Tue, 16 Feb 2010 08:20:35 +0000 Message-ID: <4B7A6363020000780002F93C@vpn.id2.novell.com> References: <2af13319-6b44-44e2-ab62-a0615208cf64@default C79F1B58.A196%keir.fraser@eu.citrix.com 78c49794-4454-4c3b-80a6-72efcbc73fb3@default><78c49794-4454-4c3b-80a6-72efcbc73fb3@default> <057c0f45-9c97-4b8a-8efa-1726fd951e19@default> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <057c0f45-9c97-4b8a-8efa-1726fd951e19@default> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser , xen-devel@lists.xensource.com, Dan Magenheimer Cc: George Dunlap , kurt.hackel@oracle.com, Ian Pratt , Tim Deegan , Patrick Colp , Grzegorz Milos , Andrew Peace List-Id: xen-devel@lists.xenproject.org Besides generally not liking hackery like this (but we all seem to agree = on that part), and besides having an un-explained feeling that there may be other bad effects from this, I also think that on large systems this may not work well: When you have 1Tb, you'd reserve 8G, making Dom0 single-page-below-4G-allocations impossible (unless dom0_mem=3D was used) if I read the logic correctly. Jan >>> Dan Magenheimer 15.02.10 17:36 >>> This version should have zero impact if tmem is not enabled. =3D=3D=3D=3D=3D=3D=3D When tmem is enabled, reserve a fraction of memory for allocations of 0 diff -r 3bb163b74673 xen/common/page_alloc.c --- a/xen/common/page_alloc.c Fri Feb 12 09:24:18 2010 +0000 +++ b/xen/common/page_alloc.c Mon Feb 15 09:28:01 2010 -0700 @@ -223,6 +223,12 @@ static heap_by_zone_and_order_t *_heap[M =20 static unsigned long *avail[MAX_NUMNODES]; static long total_avail_pages; +static long max_total_avail_pages; /* highwater mark */ + +/* reserved for midsize (0=3D 9)) && + (total_avail_pages <=3D midsize_alloc_zone_pages) ) + goto fail; + + /* * Start with requested node, but exhaust all node memory in = requested=20 * zone before failing, only calc new node value if we fail to find = memory=20 * in target node, this avoids needless computation on fast-path. @@ -337,6 +352,7 @@ static struct page_info *alloc_heap_page } =20 /* No suitable memory blocks. Fail the request. */ +fail: spin_unlock(&heap_lock); return NULL; =20 @@ -503,6 +519,11 @@ static void free_heap_pages( =20 avail[node][zone] +=3D 1 << order; total_avail_pages +=3D 1 << order; + if ( total_avail_pages > max_total_avail_pages ) + { + max_total_avail_pages =3D total_avail_pages; + midsize_alloc_zone_pages =3D max_total_avail_pages / MIDSIZE_ALLO= C_FRAC; + } =20 /* Merge chunks as far as possible. */ while ( order < MAX_ORDER ) @@ -842,6 +863,8 @@ static unsigned long avail_heap_pages( =20 unsigned long total_free_pages(void) { + if ( opt_tmem ) + return total_avail_pages - midsize_alloc_zone_pages ; return total_avail_pages; }