From: "Jan Beulich" Subject: [PATCH] linux/balloon: prefer using pages from balloon in alloc_empty_pages_and_pagevec() Date: Wed, 16 Dec 2009 15:13:38 +0000 Message-ID: <4B2907320200007800026472@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: 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: xen-devel@lists.xensource.com Cc: Jeremy Fitzhardinge List-Id: xen-devel@lists.xenproject.org This is both faster and less demanding on kernel resources. Likely also something that could be done in the pv-ops tree (though it would need some adjustment to deal with the balloon_order!=3D0 case). Signed-off-by: Jan Beulich --- head-2009-12-07.orig/drivers/xen/balloon/balloon.c 2009-12-15 = 09:37:50.000000000 +0100 +++ head-2009-12-07/drivers/xen/balloon/balloon.c 2009-12-15 = 09:47:04.000000000 +0100 @@ -607,6 +607,17 @@ struct page **alloc_empty_pages_and_page return NULL; =20 for (i =3D 0; i < nr_pages; i++) { + balloon_lock(flags); + page =3D balloon_first_page(); + if (page && !PageHighMem(page)) { + UNLIST_PAGE(page); + bs.balloon_low--; + balloon_unlock(flags); + pagevec[i] =3D page; + continue; + } + balloon_unlock(flags); + page =3D pagevec[i] =3D alloc_page(GFP_KERNEL|__GFP_COLD); if (page =3D=3D NULL) goto err;