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

[Xen-devel] [PATCH] don't blindly use xmalloc() for allocating struct do

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] don't blindly use xmalloc() for allocating struct domain instances
From: "Jan Beulich" <jbeulich@xxxxxxxxxx>
Date: Tue, 27 Jan 2009 11:23:50 +0000
Delivery-date: Tue, 27 Jan 2009 03:23:41 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
At least on x86 these structures are greater than a page anyway, and
hence using xmalloc is wasteful here.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- 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)
 
 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)));
 }
 
 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)));
 }
 
 static void __domain_finalise_shutdown(struct domain *d)




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

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