mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
Add support for superpages (hugepages) in PV domain
This patch adds the option "superpages" to the domain configuration file. If it is set, the domain is populated using 2M pages. This code does not support fallback to small pages. If the domain can not be created with 2M pages, the create will fail. The patch also includes support for saving and restoring domains with the superpage flag set. However, if a domain has freed small pages within its physical page array and then extended the array, the restore will fill in those freed pages. It will then attempt to allocate more than its memory limit and will fail. This is significant because apparently Linux does this during boot, thus a freshly booted Linux image can not be saved and restored successfully. Signed-off-by: Dave McCracken <dcm@mccr.org>
This commit is contained in:
1 parent
2cda4bd1e1
commit
6a9b5290e9
15 files changed
+211
-153
No files matched your search
@@ -405,6 +405,7 @@ static PyObject *pyxc_linux_build(XcObject *self,
|
||||
int flags = 0;
|
||||
int store_evtchn, console_evtchn;
|
||||
int vhpt = 0;
|
||||
int superpages = 0;
|
||||
unsigned int mem_mb;
|
||||
unsigned long store_mfn = 0;
|
||||
unsigned long console_mfn = 0;
|
||||
@@ -417,14 +418,14 @@ static PyObject *pyxc_linux_build(XcObject *self,
|
||||
"console_evtchn", "image",
|
||||
/* optional */
|
||||
"ramdisk", "cmdline", "flags",
|
||||
"features", "vhpt", NULL };
|
||||
"features", "vhpt", "superpages", NULL };
|
||||
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssisi", kwd_list,
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssisii", kwd_list,
|
||||
&domid, &store_evtchn, &mem_mb,
|
||||
&console_evtchn, &image,
|
||||
/* optional */
|
||||
&ramdisk, &cmdline, &flags,
|
||||
&features, &vhpt) )
|
||||
&features, &vhpt, &superpages) )
|
||||
return NULL;
|
||||
|
||||
xc_dom_loginit();
|
||||
@@ -436,7 +437,7 @@ static PyObject *pyxc_linux_build(XcObject *self,
|
||||
|
||||
if ( xc_dom_linux_build(self->xc_handle, dom, domid, mem_mb, image,
|
||||
ramdisk, flags, store_evtchn, &store_mfn,
|
||||
console_evtchn, &console_mfn) != 0 ) {
|
||||
console_evtchn, &console_mfn, superpages) != 0 ) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
@@ -272,9 +272,11 @@ def restore(xd, fd, dominfo = None, paused = False, relocating = False):
|
||||
shadow_cur = xc.shadow_mem_control(dominfo.getDomid(), shadow / 1024)
|
||||
dominfo.info['shadow_memory'] = shadow_cur
|
||||
|
||||
superpages = restore_image.superpages
|
||||
|
||||
cmd = map(str, [xen.util.auxbin.pathTo(XC_RESTORE),
|
||||
fd, dominfo.getDomid(),
|
||||
store_port, console_port, int(is_hvm), pae, apic])
|
||||
store_port, console_port, int(is_hvm), pae, apic, superpages])
|
||||
log.debug("[xc_restore]: %s", string.join(cmd))
|
||||
|
||||
handler = RestoreInputHandler()
|
||||
|
||||
@@ -220,6 +220,7 @@ XENAPI_CFG_TYPES = {
|
||||
'machine_address_size': int,
|
||||
'suppress_spurious_page_faults': bool0,
|
||||
's3_integrity' : int,
|
||||
'superpages' : int,
|
||||
}
|
||||
|
||||
# List of legacy configuration keys that have no equivalent in the
|
||||
@@ -392,6 +393,7 @@ class XendConfig(dict):
|
||||
'other_config': {},
|
||||
'platform': {},
|
||||
'target': 0,
|
||||
'superpages': 0,
|
||||
}
|
||||
|
||||
return defaults
|
||||
@@ -2014,6 +2016,8 @@ class XendConfig(dict):
|
||||
image.append(['ramdisk', self['PV_ramdisk']])
|
||||
if self.has_key('PV_args') and self['PV_args']:
|
||||
image.append(['args', self['PV_args']])
|
||||
if self.has_key('superpages'):
|
||||
image.append(['superpages', self['superpages']])
|
||||
|
||||
for key in XENAPI_PLATFORM_CFG_TYPES.keys():
|
||||
if key in self['platform']:
|
||||
@@ -2051,6 +2055,8 @@ class XendConfig(dict):
|
||||
self['PV_ramdisk'] = sxp.child_value(image_sxp, 'ramdisk','')
|
||||
self['PV_args'] = kernel_args
|
||||
|
||||
self['superpages'] = sxp.child_value(image_sxp, 'superpages',0)
|
||||
|
||||
for key in XENAPI_PLATFORM_CFG_TYPES.keys():
|
||||
val = sxp.child_value(image_sxp, key, None)
|
||||
if val is not None and val != '':
|
||||
|
||||
@@ -651,6 +651,7 @@ class LinuxImageHandler(ImageHandler):
|
||||
ImageHandler.configure(self, vmConfig)
|
||||
self.vramsize = int(vmConfig['platform'].get('videoram',4)) * 1024
|
||||
self.is_stubdom = (self.kernel.find('stubdom') >= 0)
|
||||
self.superpages = vmConfig['superpages']
|
||||
|
||||
def buildDomain(self):
|
||||
store_evtchn = self.vm.getStorePort()
|
||||
@@ -668,6 +669,7 @@ class LinuxImageHandler(ImageHandler):
|
||||
log.debug("vcpus = %d", self.vm.getVCpuCount())
|
||||
log.debug("features = %s", self.vm.getFeatures())
|
||||
log.debug("flags = %d", self.flags)
|
||||
log.debug("superpages = %d", self.superpages)
|
||||
if arch.type == "ia64":
|
||||
log.debug("vhpt = %d", self.vhpt)
|
||||
|
||||
@@ -680,7 +682,8 @@ class LinuxImageHandler(ImageHandler):
|
||||
ramdisk = self.ramdisk,
|
||||
features = self.vm.getFeatures(),
|
||||
flags = self.flags,
|
||||
vhpt = self.vhpt)
|
||||
vhpt = self.vhpt,
|
||||
superpages = self.superpages)
|
||||
|
||||
def getRequiredAvailableMemory(self, mem_kb):
|
||||
if self.is_stubdom :
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
actions_after_reboot %NORMAL_EXIT; #REQUIRED
|
||||
actions_after_crash %CRASH_BEHAVIOUR; #REQUIRED
|
||||
PCI_bus CDATA #REQUIRED
|
||||
superpages CDATA #REQUIRED
|
||||
security_label CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT memory EMPTY>
|
||||
|
||||
@@ -660,6 +660,8 @@ def configure_image(vals):
|
||||
config_image.append(['videoram', vals.videoram])
|
||||
if vals.extra:
|
||||
config_image.append(['args', vals.extra])
|
||||
if vals.superpages:
|
||||
config_image.append(['superpages', vals.superpages])
|
||||
|
||||
if vals.builder == 'hvm':
|
||||
configure_hvm(config_image, vals)
|
||||
|
||||
@@ -271,6 +271,8 @@ class xenapi_create:
|
||||
vm.attributes["auto_power_on"].value == 'true',
|
||||
"s3_integrity":
|
||||
vm.attributes["s3_integrity"].value,
|
||||
"superpages":
|
||||
vm.attributes["superpages"].value,
|
||||
"memory_static_max":
|
||||
get_child_node_attribute(vm, "memory", "static_max"),
|
||||
"memory_static_min":
|
||||
@@ -654,6 +656,8 @@ class sxp2xml:
|
||||
= str(get_child_by_name(config, "vcpus", 1))
|
||||
vm.attributes["s3_integrity"] \
|
||||
= str(get_child_by_name(config, "s3_integrity", 0))
|
||||
vm.attributes["superpages"] \
|
||||
= str(get_child_by_name(config, "superpages", 0))
|
||||
|
||||
sec_data = get_child_by_name(config, "security")
|
||||
if sec_data:
|
||||
|
||||