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] make ballooning up to maxmem work

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, gcosta@xxxxxxxxxx
Subject: [Xen-devel] [PATCH] make ballooning up to maxmem work
From: Rik van Riel <riel@xxxxxxxxxx>
Date: Tue, 21 Nov 2006 16:00:21 -0500
Delivery-date: Tue, 21 Nov 2006 13:02:12 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.7 (X11/20061004)
Because XENMEM_maximum_reservation is rumored to change meaning in
the future, this patch adds a third amount-of-memory operation to
HYPERVISOR_memory_op() - XENMEM_maximum_memory.

This should make it possible to simply specify the maximum amount
of memory a guest will have in /etc/xen/<guest> instead of having
to pass it on the kernel commandline.

A next step would be to split out the maxmem values into two
different ones in the guest config file and the tools, but I'm
not quite sure what name to use there...

Signed-off-by: Rik van Riel <riel@xxxxxxxxxx>

--
All Rights Reversed
Because XENMEM_maximum_reservation is rumored to change meaning in
the future, this patch adds a third amount-of-memory operation to
HYPERVISOR_memory_op() - XENMEM_maximum_memory.

This should make it possible to simply specify the maximum amount
of memory a guest will have in /etc/xen/<guest> instead of having
to pass it on the kernel commandline.

A next step would be to split out the maxmem values into two
different ones in the guest config file and the tools, but I'm
not quite sure what name to use there...


Signed-off-by: Rik van Riel <riel@xxxxxxxxxx>

diff -r ea457d9d3fb2 linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c        Mon Nov 20 
16:59:07 2006 +0000
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c        Tue Nov 21 
15:58:56 2006 -0500
@@ -583,6 +583,7 @@ void __init setup_memory_region(void)
         * the boot process we know we have plenty slack space.
         */
        struct e820entry map[E820MAX];
+       unsigned long arg = DOMID_SELF;
 
        memmap.nr_entries = E820MAX;
        set_xen_guest_handle(memmap.buffer, map);
@@ -591,7 +592,11 @@ void __init setup_memory_region(void)
        if ( rc == -ENOSYS ) {
                memmap.nr_entries = 1;
                map[0].addr = 0ULL;
-               map[0].size = xen_start_info->nr_pages << PAGE_SHIFT;
+               rc = HYPERVISOR_memory_op(XENMEM_maximum_memory, &arg);
+               if ( rc < 0 )
+                       map[0].size = xen_start_info->nr_pages << PAGE_SHIFT;
+               else
+                       map[0].size = rc << PAGE_SHIFT;
                /* 8MB slack (to balance backend allocations). */
                map[0].size += 8 << 20;
                map[0].type = E820_RAM;
diff -r ea457d9d3fb2 
linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h  Mon Nov 
20 16:59:07 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h  Tue Nov 
21 15:58:56 2006 -0500
@@ -18,6 +18,7 @@ static char * __init machine_specific_me
         * the boot process we know we have plenty slack space.
         */
        struct e820entry map[E820MAX];
+       unsigned long arg = DOMID_SELF;
 
        memmap.nr_entries = E820MAX;
        set_xen_guest_handle(memmap.buffer, map);
@@ -26,7 +27,11 @@ static char * __init machine_specific_me
        if ( rc == -ENOSYS ) {
                memmap.nr_entries = 1;
                map[0].addr = 0ULL;
-               map[0].size = PFN_PHYS(xen_start_info->nr_pages);
+               rc = HYPERVISOR_memory_op(XENMEM_maximum_memory, &arg);
+               if ( rc < 0 )
+                       map[0].size = PFN_PHYS(xen_start_info->nr_pages);
+               else
+                       map[0].size = PFN_PHYS(rc);
                /* 8MB slack (to balance backend allocations). */
                map[0].size += 8ULL << 20;
                map[0].type = E820_RAM;
diff -r ea457d9d3fb2 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Mon Nov 20 16:59:07 2006 +0000
+++ b/xen/arch/x86/mm.c Tue Nov 21 15:58:56 2006 -0500
@@ -2974,6 +2974,8 @@ long arch_memory_op(int op, XEN_GUEST_HA
         break;
     }
 
+    /* When implementing this, make sure to create a map up to the
+     * maximum amount of memory the guest will ever need. */
     case XENMEM_memory_map:
     {
         return -ENOSYS;
diff -r ea457d9d3fb2 xen/common/memory.c
--- a/xen/common/memory.c       Mon Nov 20 16:59:07 2006 +0000
+++ b/xen/common/memory.c       Tue Nov 21 15:58:56 2006 -0500
@@ -588,6 +588,7 @@ long do_memory_op(unsigned long cmd, XEN
 
     case XENMEM_current_reservation:
     case XENMEM_maximum_reservation:
+    case XENMEM_maximum_memory:
         if ( copy_from_guest(&domid, arg, 1) )
             return -EFAULT;
 
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>