From: "Jan Beulich" Subject: [PATCH] don't blindly use xmalloc() for allocating struct domain instances Date: Tue, 27 Jan 2009 11:23:50 +0000 Message-ID: <497EFCD6.76E4.0078.0@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 List-Id: xen-devel@lists.xenproject.org At least on x86 these structures are greater than a page anyway, and hence using xmalloc is wasteful here. Signed-off-by: Jan Beulich --- 2009-01-27.orig/xen/common/domain.c 2009-01-08 10:30:05.000000000 = +0100 +++ 2009-01-27/xen/common/domain.c 2009-01-27 11:47:22.000000000 = +0100 @@ -104,12 +104,17 @@ int current_domain_id(void) =20 static struct domain *alloc_domain_struct(void) { - return xmalloc(struct domain); + if (sizeof(struct domain) < PAGE_SIZE) + return xmalloc(struct domain); + return alloc_xenheap_pages(get_order_from_bytes(sizeof(struct = domain))); } =20 static void free_domain_struct(struct domain *d) { - xfree(d); + if (sizeof(*d) < PAGE_SIZE) + xfree(d); + else + free_xenheap_pages(d, get_order_from_bytes(sizeof(*d))); } =20 static void __domain_finalise_shutdown(struct domain *d)