Replace tsc_native config option with tsc_mode config option

(NOTE: pvrdtscp mode not finished yet, but all other
modes have been tested so sooner seemed better than
later to submit this fairly major patch so we can get
more mileage on it before next release.)

New tsc_mode config option supercedes tsc_native and
offers a more intelligent default and an additional
option for intelligent apps running on PV domains
("pvrdtscp").

For PV domains, default mode will determine if the initial
host has a "safe"** TSC (meaning it is always synchronized
across all physical CPUs).  If so, all domains will
execute all rdtsc instructions natively; if not,
all domains will emulate all rdtsc instructions but
providing the TSC hertz rate of the initial machine.
After being restored or live-migrated, all PV domains will
emulate all rdtsc instructions.  Hence, this default mode
guarantees correctness while providing native performance
in most conditions.

For PV domains, tsc_mode==1 will always emulate rdtsc
and tsc_mode==2 will never emulate rdtsc.  For tsc_mode==3,
rdtsc will never be emulated, but information is provided
through pvcpuid instructions and rdtscp instructions
so that an app can obtain "safe" pvclock-like TSC information
across save/restore and live migration. (Will be completed in
a follow-on patch.)

For HVM domains, the default mode and "always emulate"
mode do the same as tsc_native==0; the other two modes
do the same as tsc_native==1.  (HVM domains since 3.4
have implemented a tsc_mode=default-like functionality,
but also can preserve native TSC across save/restore
and live-migration IFF the initial and target machines
have a common TSC cycle rate.)

** All newer AMD machines, and Nehalem and future Intel
machines have "Invariant TSC"; many newer Intel machines
have "Constant TSC" and do not support deep-C sleep states;
these and all single-processor machines are "safe".

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
This commit is contained in:
Keir Fraser committed 2009-11-25 14:05:28 +00:00
1 parent 83371c34bc
commit 08a0b4ab0d
20 files changed
+488 -81

No files matched your search

+9 -8
View File
@@ -1486,14 +1486,14 @@ static PyObject *pyxc_domain_set_time_offset(XcObject *self, PyObject *args)
return zero;
}
static PyObject *pyxc_domain_set_tsc_native(XcObject *self, PyObject *args)
static PyObject *pyxc_domain_set_tsc_info(XcObject *self, PyObject *args)
{
uint32_t dom, is_native;
uint32_t dom, tsc_mode;
if (!PyArg_ParseTuple(args, "ii", &dom, &is_native))
if (!PyArg_ParseTuple(args, "ii", &dom, &tsc_mode))
return NULL;
if (xc_domain_set_tsc_native(self->xc_handle, dom, is_native) != 0)
if (xc_domain_set_tsc_info(self->xc_handle, dom, tsc_mode, 0, 0, 0) != 0)
return pyxc_error_to_exception();
Py_INCREF(zero);
@@ -2036,12 +2036,13 @@ static PyMethodDef pyxc_methods[] = {
" offset [int]: Time offset from UTC in seconds.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_set_tsc_native",
(PyCFunction)pyxc_domain_set_tsc_native,
{ "domain_set_tsc_info",
(PyCFunction)pyxc_domain_set_tsc_info,
METH_VARARGS, "\n"
"Set a domain's TSC mode (emulate vs native)\n"
"Set a domain's TSC mode\n"
" dom [int]: Domain whose TSC mode is being set.\n"
" is_native [int]: 1=native, 0=emulate.\n"
" tsc_mode [int]: 0=default (monotonic, but native where possible)\n"
" 1=always emulate 2=never emulate 3=pvrdtscp\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_disable_migrate",
+3 -3
View File
@@ -163,7 +163,7 @@ XENAPI_PLATFORM_CFG_TYPES = {
'vncdisplay': int,
'vnclisten': str,
'timer_mode': int,
'tsc_native': int,
'tsc_mode': int,
'vpt_align': int,
'viridian': int,
'vncpasswd': str,
@@ -477,8 +477,8 @@ class XendConfig(dict):
if not os.path.exists(self['platform']['device_model']):
raise VmError("device model '%s' not found" % str(self['platform']['device_model']))
if 'tsc_native' not in self['platform']:
self['platform']['tsc_native'] = 0
if 'tsc_mode' not in self['platform']:
self['platform']['tsc_mode'] = 0
if 'nomigrate' not in self['platform']:
self['platform']['nomigrate'] = 0
+3 -3
View File
@@ -2468,9 +2468,9 @@ class XendDomainInfo:
self._recreateDom()
# Set TSC mode of domain
tsc_native = self.info["platform"].get("tsc_native")
if arch.type == "x86" and tsc_native is not None:
xc.domain_set_tsc_native(self.domid, int(tsc_native))
tsc_mode = self.info["platform"].get("tsc_mode")
if arch.type == "x86" and tsc_mode is not None:
xc.domain_set_tsc_info(self.domid, int(tsc_mode))
# Set timer configuration of domain
timer_mode = self.info["platform"].get("timer_mode")
+5 -5
View File
@@ -221,9 +221,9 @@ gopts.var('timer_mode', val='TIMER_MODE',
use="""Timer mode (0=delay virtual time when ticks are missed;
1=virtual time is always wallclock time.""")
gopts.var('tsc_native', val='TSC_NATIVE',
gopts.var('tsc_mode', val='TSC_MODE',
fn=set_int, default=0,
use="""TSC mode (0=emulate TSC, 1=native TSC).""")
use="""TSC mode (0=default, 1=always emulate, 2=never emulate, 3=pvrdtscp).""")
gopts.var('nomigrate', val='NOMIGRATE',
fn=set_int, default=0,
@@ -738,8 +738,8 @@ def configure_image(vals):
if vals.suppress_spurious_page_faults:
config_image.append(['suppress_spurious_page_faults', vals.suppress_spurious_page_faults])
if vals.tsc_native is not None:
config_image.append(['tsc_native', vals.tsc_native])
if vals.tsc_mode is not None:
config_image.append(['tsc_mode', vals.tsc_mode])
if vals.nomigrate is not None:
config_image.append(['nomigrate', vals.nomigrate])
@@ -1036,7 +1036,7 @@ def make_config(vals):
config.append([n, v])
map(add_conf, ['name', 'memory', 'maxmem', 'shadow_memory',
'restart', 'on_poweroff', 'tsc_native', 'nomigrate',
'restart', 'on_poweroff', 'tsc_mode', 'nomigrate',
'on_reboot', 'on_crash', 'vcpus', 'vcpu_avail', 'features',
'on_xend_start', 'on_xend_stop', 'target', 'cpuid',
'cpuid_check', 'machine_address_size', 'suppress_spurious_page_faults'])
+1 -1
View File
@@ -1108,7 +1108,7 @@ class sxp2xml:
'pci_msitranslate',
'pci_power_mgmt',
'xen_platform_pci',
'tsc_native'
'tsc_mode'
'description',
'nomigrate'
]
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.