Skip to contentSkip to conversation

sub-page anonymous domain memory allocator

RFC PATCH In review Daniel Magenheimer 2 participants 3 messages Aug 29, 2008

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 sub-page anonymous domain memory allocator

This patch uses some #define-and-Makefile trickery to completely leverage common/xmalloc.c to provide a sub-page memory allocator that takes memory from anonymous domain heap instead of xen heap. Note that it is useful only on a 64-bit hypervisor. (Some other #define trickery can be used so that 32-bit hypervisor uses xenheap and 64-bit hypervisor uses adheap.)

Keir says that a goal for 3.4 is to combine xen heap and domain heap on 64-bit hypervisors. This is a step in that direction that I am using today in some work that requires more memory than xenheap can provide (which I'll hopefully post sometime in the next few weeks).

Comments?

xen/common/Makefile +4 -0
diff -r 566ee473fc27 xen/common/Makefile
@@ -27,6 +27,7 @@ obj-y += vsprintf.o
 obj-y += vsprintf.o
 obj-y += xmalloc.o
 obj-y += rcupdate.o
+obj-$(x86_64) += admalloc.o
 
 obj-$(perfc)       += perfc.o
 obj-$(crash_debug) += gdbstub.o
@@ -42,6 +43,9 @@ subdir-$(ia64) += hvm
 
 subdir-y += libelf
 
+admalloc.o: xmalloc.c $(HDRS) Makefile
+	$(CC) -DANON_DOMAIN $(CFLAGS) -c $< -o $@
+
 # Object file contains changeset and compiler information.
 version.o: $(BASEDIR)/include/xen/compile.h
 
xen/common/xmalloc.c +15 -0
diff -r 566ee473fc27 xen/common/xmalloc.c
@@ -35,6 +35,21 @@
 #include <xen/prefetch.h>
 #include <xen/irq.h>
 #include <xen/smp.h>
+
+/*
+ * combined with Makefile trickery, creates xmalloc-equivalent routines
+ * (e.g. admalloc/adfree) that use anonymous domain heap instead
+ * of xen heap... useful only on x86_64
+ */
+#ifdef ANON_DOMAIN
+#include <xen/admalloc.h>
+#define alloc_xenheap_pages(order) alloc_adheap_pages(order)
+#undef alloc_xenheap_page
+#define alloc_xenheap_page() alloc_adheap_pages(0)
+#define xfree adfree
+#define _xmalloc _admalloc
+#define free_xenheap_pages free_adheap_pages
+#endif
 
 /*
  * XMALLOC_DEBUG:
xen/include/xen/admalloc.h new file +48 -0

48 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

You can more simply just have the existing xmalloc interface go at alloc_domheap_pages(NULL) on x86/64. That would just need some #ifdef abstraction within xmalloc.c.

-- Keir

Quoted 18 lines · Daniel Magenheimer

This patch uses some #define-and-Makefile trickery to completely leverage common/xmalloc.c to provide a sub-page memory allocator that takes memory from anonymous domain heap instead of xen heap. Note that it is useful only on a 64-bit hypervisor. (Some other #define trickery can be used so that 32-bit hypervisor uses xenheap and 64-bit hypervisor uses adheap.)

Keir says that a goal for 3.4 is to combine xen heap and domain heap on 64-bit hypervisors. This is a step in that direction that I am using today in some work that requires more memory than xenheap can provide (which I'll hopefully post sometime in the next few weeks).

Comments?
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

True, but this way the new anonymous domain sub-page allocator co-exists with the existing xmalloc mechanism, which I didn't want to mess with right now. In the future, when they are both eating from the same pool of memory, it won't matter.

Related, any suggestions on how to implement a "low-water mark" (for any or all of the heaps/nodes)? I'd like to be know when memory is running low (and maybe "very low"), rather than just have it run out. Especially since alloc_xenheap_pages gets "chatty".

Thanks,
Dan

Quoted 43 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Friday, August 29, 2008 12:19 PM
To: Daniel Magenheimer; xen-devel mailing list
Subject: Re: [Xen-devel] [PATCH][RFC] sub-page anonymous domain memory allocator

You can more simply just have the existing xmalloc interface go at alloc_domheap_pages(NULL) on x86/64. That would just need some #ifdef abstraction within xmalloc.c.

-- Keir

Quoted 13 lines · Daniel Magenheimer

This patch uses some #define-and-Makefile trickery to completely leverage common/xmalloc.c to provide a sub-page memory allocator that takes memory from anonymous domain heap instead of xen heap. Note that it is useful only on a 64-bit hypervisor. (Some other #define trickery can be used so that 32-bit hypervisor uses xenheap and 64-bit hypervisor uses adheap.)

Keir says that a goal for 3.4 is to combine xen heap and domain heap on 64-bit hypervisors. This is a step in that direction that I am using today in some work that requires more memory than xenheap can provide (which I'll hopefully post sometime in the next few weeks).

Quoted 5 lines

Comments?
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel