Skip to contentSkip to conversation

PATCH: Hugepage support for Domains booting with 4KB pages

DISCUSSION Keshav Darak 2 participants 4 messages Mar 21, 2011 – Mar 22, 2011 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

have corrected few mistakes in previously attached xen patch file. Please review it.

--- On Sun, 3/20/11, Keshav Darak <[email protected]> wrote:

From: Keshav Darak <[email protected]>
Subject: [Xen-devel] PATCH: Hugepage support for Domains booting with 4KB pages
To: [email protected]
Cc: [email protected], [email protected]
Date: Sunday, March 20, 2011, 10:34 PM

We have implemented hugepage support for guests in following manner

In
our implementation we added a parameter hugepage_num which is specified
in the config file of the DomU. It is the number of hugepages that the
guest is guaranteed to receive whenever the kernel asks for hugepage by
using its boot time parameter or reserving after booting (eg. Using echo
XX > /proc/sys/vm/nr_hugepages). During creation of the domain we
reserve MFN's for these hugepages and store them in the list. The
listhead of this list is inside the domain structure with name "hugepage_list". When the domain is booting, at that time the memory
seen by the kernel is allocated memory  less the amount required for hugepages. The function reserve_hugepage_range is called as a initcall. Before this function the
xen_extra_mem_start points to this apparent end of the memory. In this
function we reserve the PFN range for the hugepages which are going to
be allocated by kernel by incrementing the xen_extra_mem_start. We
maintain these PFNs as pages in "xen_hugepfn_list" in the kernel.

Now
before the kernel requests for hugepages, it makes a hypercall
HYPERVISOR_memory_op  to get count of hugepages allocated to it and accordingly reserves the pfn range.
then whenever kernel requests for
hugepages it again make hypercall HYPERVISOR_memory_op to get the
preallocated hugepage and according makes the p2m mapping on both sides (xen as well as kernel side)

The approach can be better explained using the presentation attached.

--
Keshav Darak
Kaustubh Kabra
Ashwin Vasani
Aditya Gadre

-----Inline Attachment Follows-----

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

tools/libxc/xc_dom.h +1 -0
diff -r 4e108cf56d07 tools/libxc/xc_dom.h
@@ -113,6 +113,7 @@
     domid_t guest_domid;
     int8_t vhpt_size_log2; /* for IA64 */
     int8_t superpages;
+    int hugepage_num;
     int shadow_enabled;
 
     int xen_version;
tools/libxc/xc_dom_core.c +14 -0
diff -r 4e108cf56d07 tools/libxc/xc_dom_core.c
@@ -699,6 +699,20 @@
 
     page_shift = XC_DOM_PAGE_SHIFT(dom);
     nr_pages = mem_mb << (20 - page_shift);
+    
+    //a2k2
+    if(dom->hugepage_num && dom->superpages!=1)
+        {
+
+            nr_pages-=dom->hugepage_num*512;
+
+    }
+    if(nr_pages<=0)
+        {
+            xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, "%s: Allocated memory less than required for hugepages",
+                     __FUNCTION__);
+        return -1;
+        }
 
     DOMPRINTF("%s: mem %d MB, pages 0x%" PRIpfn " pages, %dk each",
                __FUNCTION__, mem_mb, nr_pages, 1 << (page_shift-10));
tools/libxc/xc_dom_x86.c +9 -0
diff -r 4e108cf56d07 tools/libxc/xc_dom_x86.c
@@ -747,9 +747,18 @@
             for ( j = 0; j < SUPERPAGE_NR_PFNS; j++, pfn++ )
                 dom->p2m_host[pfn] = mfn + j;
         }
+
     }
     else
     {
+        /*a2k2 setting up hugepages pool for domain in xen from its mem_size not allocated as free pages to domain. */
+        if(dom->hugepage_num)
+        {
+            rc = xc_domain_populate_hugemap(
+                dom->xch, dom->guest_domid, dom->hugepage_num,
+                9, 0, &dom->p2m_host[0]);
+
+        }
         /* setup initial p2m */
         for ( pfn = 0; pfn < dom->total_pages; pfn++ )
             dom->p2m_host[pfn] = pfn;
tools/libxc/xc_domain.c +28 -0
diff -r 4e108cf56d07 tools/libxc/xc_domain.c
@@ -729,6 +729,34 @@
     return do_memory_op(xch, XENMEM_add_to_physmap, &xatp, sizeof(xatp));
 }
 
+int xc_domain_populate_hugemap(xc_interface *xch,
+                               uint32_t domid,
+                               unsigned long nr_extents,
+                               unsigned int extent_order,
+                               unsigned int mem_flags,
+                               xen_pfn_t *extent_start)
+{
+    int err;
+    DECLARE_HYPERCALL_BOUNCE(extent_start, nr_extents * sizeof(*extent_start), XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    struct xen_memory_reservation reservation = {
+        .nr_extents   = nr_extents,
+        .extent_order = extent_order,
+        .mem_flags    = mem_flags,
+        .domid        = domid
+    };
+
+    if ( xc_hypercall_bounce_pre(xch, extent_start) )
+    {
+        PERROR("Could not bounce memory for XENMEM_populate_physmap hypercall");
+        return -1;
+    }
+    set_xen_guest_handle(reservation.extent_start, extent_start);
+
+    err = do_memory_op(xch, XENMEM_populate_hugemap, &reservation, sizeof(reservation));
+
+    xc_hypercall_bounce_post(xch, extent_start);
+    return err;
+}
 int xc_domain_populate_physmap(xc_interface *xch,
                                uint32_t domid,
                                unsigned long nr_extents,
tools/libxc/xenctrl.h +7 -0
diff -r 4e108cf56d07 tools/libxc/xenctrl.h
@@ -1006,6 +1006,13 @@
                                unsigned int mem_flags,
                                xen_pfn_t *extent_start);
 
+int xc_domain_populate_hugemap(xc_interface *xch,
+                               uint32_t domid,
+                               unsigned long nr_extents,
+                               unsigned int extent_order,
+                               unsigned int mem_flags,
+                               xen_pfn_t *extent_start);
+
 int xc_domain_populate_physmap_exact(xc_interface *xch,
                                      uint32_t domid,
                                      unsigned long nr_extents,
tools/python/xen/lowlevel/xc/xc.c +6 -4
diff -r 4e108cf56d07 tools/python/xen/lowlevel/xc/xc.c
@@ -455,6 +455,7 @@
     int store_evtchn, console_evtchn;
     int vhpt = 0;
     int superpages = 0;
+    int hugepage_num = 0;
     unsigned int mem_mb;
     unsigned long store_mfn = 0;
     unsigned long console_mfn = 0;
@@ -467,14 +468,14 @@
                                 "console_evtchn", "image",
                                 /* optional */
                                 "ramdisk", "cmdline", "flags",
-                                "features", "vhpt", "superpages", NULL };
-
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssisii", kwd_list,
+                                "features", "vhpt", "superpages","hugepage_num", NULL };
+
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssisiii", kwd_list,
                                       &domid, &store_evtchn, &mem_mb,
                                       &console_evtchn, &image,
                                       /* optional */
                                       &ramdisk, &cmdline, &flags,
-                                      &features, &vhpt, &superpages) )
+                                      &features, &vhpt, &superpages,&hugepage_num) )
         return NULL;
 
     xc_dom_loginit(self->xc_handle);
@@ -484,6 +485,7 @@
     /* for IA64 */
     dom->vhpt_size_log2 = vhpt;
 
+  dom->hugepage_num=hugepage_num;
     dom->superpages = superpages;
 
     if ( xc_dom_linux_build(self->xc_handle, dom, domid, mem_mb, image,
tools/python/xen/xend/XendConfig.py +7 -0
diff -r 4e108cf56d07 tools/python/xen/xend/XendConfig.py
@@ -244,6 +244,7 @@
     'memory_sharing': int,
     'pool_name' : str,
     'Description': str,
+    'hugepage_num':int,
 }
 
 # List of legacy configuration keys that have no equivalent in the
@@ -423,6 +424,7 @@
             'pool_name' : 'Pool-0',
             'superpages': 0,
             'description': '',
+            'hugepage_num':0,
         }
         
         return defaults
@@ -2135,6 +2137,8 @@
             image.append(['args', self['PV_args']])
         if self.has_key('superpages'):
             image.append(['superpages', self['superpages']])
+	if self.has_key('hugepage_num'):
+            image.append(['hugepage_num', self['hugepage_num']])
 
         for key in XENAPI_PLATFORM_CFG_TYPES.keys():
             if key in self['platform']:
@@ -2179,6 +2183,9 @@
         val = sxp.child_value(image_sxp, 'superpages')
         if val is not None:
             self['superpages'] = val
+        val = sxp.child_value(image_sxp, 'hugepage_num')
+        if val is not None:
+            self['hugepage_num'] = val
         
         val = sxp.child_value(image_sxp, 'memory_sharing')
         if val is not None:
tools/python/xen/xend/image.py +5 -1
diff -r 4e108cf56d07 tools/python/xen/xend/image.py
@@ -84,6 +84,7 @@
 
     ostype = None
     superpages = 0
+    hugepage_num = 0
     memory_sharing = 0
 
     def __init__(self, vm, vmConfig):
@@ -711,6 +712,7 @@
         self.vramsize = int(vmConfig['platform'].get('videoram',4)) * 1024
         self.is_stubdom = (self.kernel.find('stubdom') >= 0)
         self.superpages = int(vmConfig['superpages'])
+	self.hugepage_num = int(vmConfig['hugepage_num'])
 
     def buildDomain(self):
         store_evtchn = self.vm.getStorePort()
@@ -729,6 +731,7 @@
         log.debug("features       = %s", self.vm.getFeatures())
         log.debug("flags          = %d", self.flags)
         log.debug("superpages     = %d", self.superpages)
+	log.debug("hugepage_num   = %d", self.hugepage_num)
         if arch.type == "ia64":
             log.debug("vhpt          = %d", self.vhpt)
 
@@ -742,7 +745,8 @@
                               features       = self.vm.getFeatures(),
                               flags          = self.flags,
                               vhpt           = self.vhpt,
-                              superpages     = self.superpages)
+                              superpages     = self.superpages,
+			      hugepage_num   = self.hugepage_num)
 
     def getBitSize(self):
         return xc.getBitSize(image    = self.kernel,
tools/python/xen/xm/create.dtd +1 -0
diff -r 4e108cf56d07 tools/python/xen/xm/create.dtd
@@ -56,6 +56,7 @@
                  actions_after_crash    %CRASH_BEHAVIOUR; #REQUIRED
                  PCI_bus                CDATA #REQUIRED
                  superpages             CDATA #REQUIRED
+		 hugepage_num		CDATA #REQUIRED
                  security_label         CDATA #IMPLIED>
 
 <!ELEMENT memory EMPTY> 
tools/python/xen/xm/create.py +8 -0
diff -r 4e108cf56d07 tools/python/xen/xm/create.py
@@ -680,6 +680,11 @@
            fn=set_int, default=0,
            use="Create domain with superpages")
 
+gopts.var('hugepage_num', val='NUM',
+           fn=set_int, default=0,
+           use="Domain with hugepages support")
+
+
 def err(msg):
     """Print an error to stderr and exit.
     """
@@ -770,6 +775,9 @@
         config_image.append(['args', vals.extra])
     if vals.superpages:
         config_image.append(['superpages', vals.superpages])
+    if vals.hugepage_num:
+        config_image.append(['hugepage_num', vals.hugepage_num])
+
 
     if vals.builder == 'hvm':
         configure_hvm(config_image, vals) 
tools/python/xen/xm/xenapi_create.py +4 -0
diff -r 4e108cf56d07 tools/python/xen/xm/xenapi_create.py
@@ -285,6 +285,8 @@
                 vm.attributes["s3_integrity"].value,
             "superpages":
                 vm.attributes["superpages"].value,
+ 	    "hugepage_num":
+                vm.attributes["hugepage_num"].value,
             "memory_static_max":
                 get_child_node_attribute(vm, "memory", "static_max"),
             "memory_static_min":
@@ -697,6 +699,8 @@
             = str(get_child_by_name(config, "s3_integrity", 0))
         vm.attributes["superpages"] \
             = str(get_child_by_name(config, "superpages", 0))
+	vm.attributes["hugepage_num"] \
+            = str(get_child_by_name(config, "hugepage_num", 0))
         vm.attributes["pool_name"] \
             = str(get_child_by_name(config, "pool_name", "Pool-0"))
 
xen/arch/x86/setup.c +9 -2
diff -r 4e108cf56d07 xen/arch/x86/setup.c
@@ -44,6 +44,7 @@
 #include <asm/mach-generic/mach_apic.h> /* for generic_apic_probe */
 #include <asm/setup.h>
 #include <xen/cpu.h>
+
 
 extern u16 boot_edid_caps;
 extern u8 boot_edid_info[128];
@@ -60,7 +61,10 @@
 /* opt_watchdog: If true, run a watchdog NMI on each processor. */
 static bool_t __initdata opt_watchdog;
 boolean_param("watchdog", opt_watchdog);
-
+//a2k2:
+static unsigned int __initdata dom0_hugepages=0;
+integer_param("dom0_hugepages", dom0_hugepages);
+int allocate_hugepages(struct domain *,int,int);
 /* **** Linux config option: propagated to domain0. */
 /* "acpi=off":    Sisables both ACPI table parsing and interpreter. */
 /* "acpi=force":  Override the disable blacklist.                   */
@@ -1259,7 +1263,10 @@
     
     if ( !tboot_protect_mem_regions() )
         panic("Could not protect TXT memory regions\n");
+    //a2k2:
 
+    //init_hugepages_pool();
+    printk("a2k2:Dom0 hugepages are :%u\n",dom0_hugepages);
     /* Create initial domain 0. */
     dom0 = domain_create(0, DOMCRF_s3_integrity, DOM0_SSIDREF);
     if ( (dom0 == NULL) || (alloc_dom0_vcpu0() == NULL) )
@@ -1267,7 +1274,7 @@
 
     dom0->is_privileged = 1;
     dom0->target = NULL;
-
+    allocate_hugepages(dom0,dom0_hugepages,SUPERPAGE_ORDER);
     /* Grab the DOM0 command line. */
     cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL);
     if ( (cmdline != NULL) || (kextra != NULL) )
xen/common/domain.c +9 -3
diff -r 4e108cf56d07 xen/common/domain.c
@@ -240,9 +240,9 @@
     spin_lock_init(&d->hypercall_deadlock_mutex);
     INIT_PAGE_LIST_HEAD(&d->page_list);
     INIT_PAGE_LIST_HEAD(&d->xenpage_list);
-
+    INIT_PAGE_LIST_HEAD(&d->hugepage_list);
     spin_lock_init(&d->node_affinity_lock);
-
+    d->hugepage_num=0;
     spin_lock_init(&d->shutdown_lock);
     d->shutdown_code = -1;
 
@@ -441,7 +441,7 @@
 int domain_kill(struct domain *d)
 {
     int rc = 0;
-
+    struct page_info* page;
     if ( d == current->domain )
         return -EINVAL;
 
@@ -451,6 +451,12 @@
     case DOMDYING_alive:
         domain_pause(d);
         d->is_dying = DOMDYING_dying;
+         while(!page_list_empty(&(d->hugepage_list)))
+            {
+          
+                page=page_list_remove_head(&(d->hugepage_list));
+                free_domheap_pages(page,SUPERPAGE_ORDER);
+            }
         spin_barrier(&d->domain_lock);
         evtchn_destroy(d);
         gnttab_release_mappings(d);
xen/common/memory.c +73 -4

118 lines not on this page · raw message

xen/include/public/memory.h +3 -0
diff -r 4e108cf56d07 xen/include/public/memory.h
@@ -37,6 +37,9 @@
 #define XENMEM_increase_reservation 0
 #define XENMEM_decrease_reservation 1
 #define XENMEM_populate_physmap     6
+#define XENMEM_populate_hugepage    19
+#define XENMEM_hugepage_cnt         20
+#define XENMEM_populate_hugemap     21
 
 #if __XEN_INTERFACE_VERSION__ >= 0x00030209
 /*
xen/include/xen/mm.h +16 -1
diff -r 4e108cf56d07 xen/include/xen/mm.h
@@ -96,14 +96,19 @@
 #endif
 
 #define page_list_entry list_head
+#define hugepage_list_entry list_head
 
 #include <asm/mm.h>
 
 #ifndef page_list_entry
 struct page_list_head
 {
-    struct page_info *next, *tail;
+    struct page_info *next, *tail; 
 };
+/*struct hugepage_list_head
+{
+  struct hugepage_info *next,*tail;
+  };*/
 /* These must only have instances in struct page_info. */
 # define page_list_entry
 
@@ -326,5 +331,15 @@
 #define RAM_TYPE_ACPI         0x00000008
 /* TRUE if the whole page at @mfn is of the requested RAM type(s) above. */
 int page_is_ram_type(unsigned long mfn, unsigned long mem_type);
+/*
+#define hugepage_list_head list_head
 
+//a2k2
+struct hugepage_info
+{
+  mfn_t mfn;
+  hugepage_list_entry hugepage_list;
+
+
+  };*/
 #endif /* __XEN_MM_H__ */
xen/include/xen/sched.h +3 -0
diff -r 4e108cf56d07 xen/include/xen/sched.h
@@ -211,6 +211,9 @@
     spinlock_t       page_alloc_lock; /* protects all the following fields  */
     struct page_list_head page_list;  /* linked list, of size tot_pages     */
     struct page_list_head xenpage_list; /* linked list (size xenheap_pages) */
+    struct page_list_head hugepage_list; /*a2k2:Free hugepage list*/
+    unsigned int     hugepage_num;    /*a2k2:  */
+
     unsigned int     tot_pages;       /* number of pages currently possesed */
     unsigned int     max_pages;       /* maximum value for tot_pages        */
     atomic_t         shr_pages;       /* number of shared pages             */

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

#1 lore raw

Keshav,

There is already optional support for superpage allocations and mappings for PV guests in the hypervisor and toolstack. See the opt_allow_superpages boolean flag in the hypervisor, and the 'superpages' domain config option that can be specified when creating a new domain via xend/xm.

-- Keir

Quoted 54 lines · Keshav Darak

have corrected few mistakes in previously attached xen patch file. Please review it.

Quoted 48 lines · Keshav Darak

From: Keshav Darak <[email protected]>
Subject: [Xen-devel] PATCH: Hugepage support for Domains booting with 4KB pages
To: [email protected]
Cc: [email protected], [email protected]
Date: Sunday, March 20, 2011, 10:34 PM

We have implemented hugepage support for guests in following manner

In our implementation we added a parameter hugepage_num which is specified in the config file of the DomU. It is the number of hugepages that the guest is guaranteed to receive whenever the kernel asks for hugepage by using its boot time parameter or reserving after booting (eg. Using echo XX > /proc/sys/vm/nr_hugepages). During creation of the domain we reserve MFN's for these hugepages and store them in the list. The listhead of this list is inside the domain structure with name "hugepage_list". When the domain is booting, at that time the memory seen by the kernel is allocated memory less the amount required for hugepages. The function reserve_hugepage_range is called as a initcall. Before this function the xen_extra_mem_start points to this apparent end of the memory. In this function we reserve the PFN range for the hugepages which are going to be allocated by kernel by incrementing the xen_extra_mem_start. We maintain these PFNs as pages in "xen_hugepfn_list" in the kernel.

Now before the kernel requests for hugepages, it makes a hypercall HYPERVISOR_memory_op to get count of hugepages allocated to it and accordingly reserves the pfn range.
then whenever kernel requests for hugepages it again make hypercall HYPERVISOR_memory_op to get the preallocated hugepage and according makes the p2m mapping on both sides (xen as well as kernel side)

The approach can be better explained using the presentation attached.

--
Keshav Darak
Kaustubh Kabra
Ashwin Vasani
Aditya Gadre

-----Inline Attachment Follows-----

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

#2 lore raw

Keir,
    We are aware of it and we have to use 'opt_allow_superpages' boolean flag in our implementation too. But when we use superpages flag in domain configuration file,
entire domain boots on hugepages (superpages).If the specified memory in 'hugepages' for the domain is not available, then the domain does not boot.
     But in our implementation , we target to give only those many hugepages ( using "hugepage_num" option in config file) to the domain that it actually requires and hence entire domain need not be booted on hugepages. This is to support domains that boot with 4 KB pages and still can use hugepages. So,
the pressure on the number of hugepages required for a domain even to boot is reduced to a great extent.
--- On Mon, 3/21/11, Keir Fraser <[email protected]> wrote:

From: Keir Fraser <[email protected]>
Subject: Re: [Xen-devel] PATCH: Hugepage support for Domains booting with 4KB pages
To: "Keshav Darak" <[email protected]>, [email protected]
Cc: [email protected]
Date: Monday, March 21, 2011, 9:31 PM

Keshav,

There is already optional support for superpage allocations and mappings for PV guests in the hypervisor and toolstack. See the opt_allow_superpages boolean flag in the hypervisor, and the 'superpages' domain config option that can be specified when creating a new domain via xend/xm.

-- Keir

Quoted 54 lines · Keshav Darak

have corrected few mistakes in previously attached xen patch file. Please review it.

Quoted 48 lines · Keshav Darak

From: Keshav Darak <[email protected]>
Subject: [Xen-devel] PATCH: Hugepage support for Domains booting with 4KB pages
To: [email protected]
Cc: [email protected], [email protected]
Date: Sunday, March 20, 2011, 10:34 PM

We have implemented hugepage support for guests in following manner

In our implementation we added a parameter hugepage_num which is specified in the config file of the DomU. It is the number of hugepages that the guest is guaranteed to receive whenever the kernel asks for hugepage by using its boot time parameter or reserving after booting (eg. Using echo XX > /proc/sys/vm/nr_hugepages). During creation of the domain we reserve MFN's for these hugepages and store them in the list. The listhead of this list is inside the domain structure with name "hugepage_list". When the domain is booting, at that time the memory seen by the kernel is allocated memory  less the amount required for hugepages. The function reserve_hugepage_range is called as a initcall. Before this function the xen_extra_mem_start points to this apparent end of the memory. In this function we reserve the PFN range for the hugepages which are going to be allocated by kernel by incrementing the xen_extra_mem_start. We maintain these PFNs as pages in "xen_hugepfn_list" in the kernel.

Now before the kernel requests for hugepages, it makes a hypercall HYPERVISOR_memory_op  to get count of hugepages allocated to it and accordingly reserves the pfn range.
then whenever kernel requests for hugepages it again make hypercall HYPERVISOR_memory_op to get the preallocated hugepage and according makes the p2m mapping on both sides (xen as well as kernel side)

The approach can be better explained using the presentation attached.

--
Keshav Darak
Kaustubh Kabra
Ashwin Vasani
Aditya Gadre

-----Inline Attachment Follows-----

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

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

#3 lore raw
Quoted 6 lines · Keshav Darak

Keir,
We are aware of it and we have to use 'opt_allow_superpages' boolean flag
in our implementation too. But when we use superpages flag in domain configuration file,
entire domain boots on hugepages (superpages).If the specified memory in 'hugepages' for the domain is not available, then the domain does not boot.

Quoted 7 lines
     But in our implementation , we target to give only those many hugepages (

using "hugepage_num" option in config file) to the domain that it actually requires and hence entire domain need not be booted on hugepages.
This is to support domains that boot with 4 KB pages and still can use
hugepages. So,
the pressure on the number of hugepages required for a domain even to boot is reduced to a great extent.

Okay, I don't see why that would need further changes in the hypervisor itself, however.

-- Keir

Quoted 93 lines
Quoted 90 lines · Keir Fraser

From: Keir Fraser <[email protected]>
Subject: Re: [Xen-devel] PATCH: Hugepage support for Domains booting with 4KB pages
To: "Keshav Darak" <[email protected]>, [email protected]
Cc: [email protected]
Date: Monday, March 21, 2011, 9:31 PM

Keshav,

There is already optional support for superpage allocations and mappings for PV guests in the hypervisor and toolstack. See the opt_allow_superpages boolean flag in the hypervisor, and the 'superpages' domain config option that can be specified when creating a new domain via xend/xm.

-- Keir

Quoted 68 lines · On 21/03/2011 21:01, "Keshav Darak" <[email protected]…

have corrected few mistakes in previously attached xen patch file. Please review it.

--- On Sun, 3/20/11, Keshav Darak <[email protected]

Quoted 61 lines · </mc/[email protected]> > wrote:

From: Keshav Darak <[email protected] </mc/[email protected]> >
Subject: [Xen-devel] PATCH: Hugepage support for Domains booting with 4KB pages
To: [email protected] </mc/[email protected]>
Cc: [email protected] </mc/[email protected]> , [email protected] </mc/[email protected]>
Date: Sunday, March 20, 2011, 10:34 PM

We have implemented hugepage support for guests in following manner

In our implementation we added a parameter hugepage_num which is specified in
the config file of the DomU. It is the number of hugepages that the guest is
guaranteed to receive whenever the kernel asks for hugepage by using its boot
time parameter or reserving after booting (eg. Using echo XX > /proc/sys/vm/nr_hugepages). During creation of the domain we reserve MFN's for these hugepages and store them in the list. The listhead of this list is
inside the domain structure with name "hugepage_list". When the domain is booting, at that time the memory seen by the kernel is allocated memory less
the amount required for hugepages. The function reserve_hugepage_range is called as a initcall. Before this function the xen_extra_mem_start points to
this apparent end of the memory. In this function we reserve the PFN range for the hugepages which are going to be allocated by kernel by incrementing the xen_extra_mem_start. We maintain these PFNs as pages in "xen_hugepfn_list" in the kernel.

Now before the kernel requests for hugepages, it makes a hypercall HYPERVISOR_memory_op to get count of hugepages allocated to it and accordingly reserves the pfn range.
then whenever kernel requests for hugepages it again make hypercall HYPERVISOR_memory_op to get the preallocated hugepage and according makes the
p2m mapping on both sides (xen as well as kernel side)

The approach can be better explained using the presentation attached.

--
Keshav Darak
Kaustubh Kabra
Ashwin Vasani
Aditya Gadre

-----Inline Attachment Follows-----

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