From: Dan Magenheimer Subject: [PATCH] tmem: fix to 20945 "When tmem is enabled, reserve a fraction of memory" Date: Tue, 16 Feb 2010 10:30:22 -0800 (PST) Message-ID: <4f9cade6-4b13-41fd-bc34-7443fb06ece3@default> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: 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 Cc: Jan Beulich List-Id: xen-devel@lists.xenproject.org (Sorry, I was testing with this tweak to my previously posted patch but had neglected to post it before the patch was taken.) With tmem enabled, when available memory is scarce, don't allow order=3D=3D0 pages to be taken from the "midsize alloc zone" but DO attempt to relinquish a page from tmem. Else many things fail when tmem has absorbed nearly all system memory. Signed-off-by: Dan Magenheimer diff -r 364001067e26 xen/common/page_alloc.c --- a/xen/common/page_alloc.c=09Tue Feb 16 11:55:21 2010 +0000 +++ b/xen/common/page_alloc.c=09Tue Feb 16 10:19:39 2010 -0700 @@ -311,9 +311,13 @@ static struct page_info *alloc_heap_page * TMEM: When available memory is scarce, allow only mid-size allocati= ons * to avoid worst of fragmentation issues. */ - if ( opt_tmem && ((order =3D=3D 0) || (order >=3D 9)) && - (total_avail_pages <=3D midsize_alloc_zone_pages) ) - goto fail; + if ( opt_tmem && (total_avail_pages <=3D midsize_alloc_zone_pages) ) + { + if ( order =3D=3D 0) + goto try_tmem; + if ( order >=3D 9) + goto fail; + } =20 /* * Start with requested node, but exhaust all node memory in requested= =20 @@ -341,6 +345,7 @@ static struct page_info *alloc_heap_page } =20 /* Try to free memory from tmem */ +try_tmem: if ( (pg =3D tmem_relinquish_pages(order,memflags)) !=3D NULL ) { /* reassigning an already allocated anonymous heap page */