Create domains with superpages
RFC PATCH 1/1 Create domains with superpages
This patch modifies xend to always create and restore domains to 2M pages. It currently works unconditionally, ie once the library is installed all domains will be created with 2M pages.
The patch is intended only to show feasibility and for testing. I am working on adding an option in the domain config file to enable this functionality on a per-domain basis.
Dave McCracken
Oracle Corp.
./tools/libxc/xc_dom_x86.c +40 -7
@@ -26,6 +26,9 @@/* ------------------------------------------------------------------------ */ +#define SUPERPAGE_PFN_SHIFT 9 +#define SUPERPAGE_NR_PFNS (1UL << SUPERPAGE_PFN_SHIFT) +#define bits_to_mask (bits) (((xen_vaddr_t)1 << (bits))-1)#define round_down (addr, mask) ((addr) & ~(mask))#define round_up (addr, mask) ((addr) | (mask))
@@ -695,6 +698,7 @@ int arch_setup_meminit(struct xc_dom_ima {int rc;xen_pfn_t pfn; +int superpages =1 ; rc =x86_compat (dom->guest_xc, dom->guest_domid, dom->guest_type);if ( rc )
@@ -707,15 +711,44 @@ int arch_setup_meminit(struct xc_dom_imareturn rc; } -/* setup initial p2m */ dom->p2m_host =xc_dom_malloc (dom,sizeof (xen_pfn_t) * dom->total_pages); -for ( pfn =0 ; pfn < dom->total_pages; pfn++ ) - dom->p2m_host[pfn] = pfn; +if (superpages) + { +int count = dom->total_pages >>SUPERPAGE_PFN_SHIFT ; +xen_pfn_t extents[count]; -/* allocate guest memory */ - rc =xc_domain_memory_populate_physmap (dom->guest_xc, dom->guest_domid, - dom->total_pages,0 ,0 , - dom->p2m_host); +for (pfn =0 ; pfn < count; pfn++) + extents[pfn] = pfn <<SUPERPAGE_PFN_SHIFT ; + rc =xc_domain_memory_populate_physmap (dom->guest_xc, dom->guest_domid, + count,SUPERPAGE_PFN_SHIFT ,0 , + extents); +if (!rc) + { +int i, j; +xen_pfn_t mfn; + +/* Expand the returned mfn into the p2m array */ + pfn =0 ; +for (i =0 ; i < count; i++) + { + mfn = extents[i]; +for (j =0 ; j <SUPERPAGE_NR_PFNS ; j++, pfn++) + { + dom->p2m_host[pfn] = mfn + j; + } + } + } + }else + { +/* setup initial p2m */ +for ( pfn =0 ; pfn < dom->total_pages; pfn++ ) + dom->p2m_host[pfn] = pfn; + +/* allocate guest memory */ + rc =xc_domain_memory_populate_physmap (dom->guest_xc, dom->guest_domid, + dom->total_pages,0 ,0 , + dom->p2m_host); + }return rc; }
./tools/libxc/xc_domain_restore.c +103 -111
283 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel