ia64/xen-unstable

changeset 19213:d9480422034b

hvm: Align periodic vpts.

Aligned periodic vpts can improve the HVM guest power consumption a
lot, especially while the guest using high HZ such as 1000HZ.

Signed-off-by: Wei Gang <gang.wei@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Feb 13 09:43:06 2009 +0000 (2009-02-13)
parents 5ae8ed54e2cd
children 09a6fa059b37
files tools/python/xen/xend/XendConfig.py tools/python/xen/xend/XendConstants.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/create.py tools/python/xen/xm/xenapi_create.py xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/vpt.c xen/common/timer.c xen/include/public/hvm/params.h xen/include/xen/timer.h
line diff
     1.1 --- a/tools/python/xen/xend/XendConfig.py	Fri Feb 13 09:38:16 2009 +0000
     1.2 +++ b/tools/python/xen/xend/XendConfig.py	Fri Feb 13 09:43:06 2009 +0000
     1.3 @@ -158,6 +158,7 @@ XENAPI_PLATFORM_CFG_TYPES = {
     1.4      'vncdisplay': int,
     1.5      'vnclisten': str,
     1.6      'timer_mode': int,
     1.7 +    'vpt_align': int,
     1.8      'viridian': int,
     1.9      'vncpasswd': str,
    1.10      'vncunused': int,
    1.11 @@ -459,6 +460,8 @@ class XendConfig(dict):
    1.12                  self['platform']['rtc_timeoffset'] = 0
    1.13              if 'hpet' not in self['platform']:
    1.14                  self['platform']['hpet'] = 0
    1.15 +            if 'vpt_align' not in self['platform']:
    1.16 +                self['platform']['vpt_align'] = 1
    1.17              if 'loader' not in self['platform']:
    1.18                  # Old configs may have hvmloader set as PV_kernel param
    1.19                  if self.has_key('PV_kernel') and self['PV_kernel'] != '':
     2.1 --- a/tools/python/xen/xend/XendConstants.py	Fri Feb 13 09:38:16 2009 +0000
     2.2 +++ b/tools/python/xen/xend/XendConstants.py	Fri Feb 13 09:43:06 2009 +0000
     2.3 @@ -50,6 +50,7 @@ HVM_PARAM_VIRIDIAN     = 9 # x86
     2.4  HVM_PARAM_TIMER_MODE   = 10
     2.5  HVM_PARAM_HPET_ENABLED = 11
     2.6  HVM_PARAM_ACPI_S_STATE = 14
     2.7 +HVM_PARAM_VPT_ALIGN    = 16
     2.8  
     2.9  restart_modes = [
    2.10      "restart",
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Feb 13 09:38:16 2009 +0000
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Feb 13 09:43:06 2009 +0000
     3.3 @@ -2237,6 +2237,12 @@ class XendDomainInfo:
     3.4              xc.hvm_set_param(self.domid, HVM_PARAM_HPET_ENABLED,
     3.5                               long(hpet))
     3.6  
     3.7 +        # Optionally enable periodic vpt aligning
     3.8 +        vpt_align = self.info["platform"].get("vpt_align")
     3.9 +        if hvm and vpt_align is not None:
    3.10 +            xc.hvm_set_param(self.domid, HVM_PARAM_VPT_ALIGN,
    3.11 +                             long(vpt_align))
    3.12 +
    3.13          # Set maximum number of vcpus in domain
    3.14          xc.domain_max_vcpus(self.domid, int(self.info['VCPUs_max']))
    3.15  
     4.1 --- a/tools/python/xen/xm/create.py	Fri Feb 13 09:38:16 2009 +0000
     4.2 +++ b/tools/python/xen/xm/create.py	Fri Feb 13 09:43:06 2009 +0000
     4.3 @@ -219,6 +219,10 @@ gopts.var('timer_mode', val='TIMER_MODE'
     4.4            use="""Timer mode (0=delay virtual time when ticks are missed;
     4.5            1=virtual time is always wallclock time.""")
     4.6  
     4.7 +gopts.var('vpt_align', val='VPT_ALIGN',
     4.8 +          fn=set_int, default=1,
     4.9 +          use="Enable aligning all periodic vpt to reduce timer interrupts.")
    4.10 +
    4.11  gopts.var('viridian', val='VIRIDIAN',
    4.12            fn=set_int, default=0,
    4.13            use="""Expose Viridian interface to x86 HVM guest?
    4.14 @@ -891,7 +895,8 @@ def configure_hvm(config_image, vals):
    4.15               'sdl', 'display', 'xauthority', 'rtc_timeoffset', 'monitor',
    4.16               'acpi', 'apic', 'usb', 'usbdevice', 'keymap', 'pci', 'hpet',
    4.17               'guest_os_type', 'hap', 'opengl', 'cpuid', 'cpuid_check',
    4.18 -             'viridian', 'xen_extended_power_mgmt', 'pci_msitranslate' ]
    4.19 +             'viridian', 'xen_extended_power_mgmt', 'pci_msitranslate',
    4.20 +             'vpt_align' ]
    4.21  
    4.22      for a in args:
    4.23          if a in vals.__dict__ and vals.__dict__[a] is not None:
     5.1 --- a/tools/python/xen/xm/xenapi_create.py	Fri Feb 13 09:38:16 2009 +0000
     5.2 +++ b/tools/python/xen/xm/xenapi_create.py	Fri Feb 13 09:43:06 2009 +0000
     5.3 @@ -1037,6 +1037,7 @@ class sxp2xml:
     5.4              'usbdevice',
     5.5              'hpet',
     5.6              'timer_mode',
     5.7 +            'vpt_align',
     5.8              'viridian',
     5.9              'vhpt',
    5.10              'guest_os_type',
     6.1 --- a/xen/arch/x86/hvm/hvm.c	Fri Feb 13 09:38:16 2009 +0000
     6.2 +++ b/xen/arch/x86/hvm/hvm.c	Fri Feb 13 09:43:06 2009 +0000
     6.3 @@ -311,6 +311,7 @@ int hvm_domain_initialise(struct domain 
     6.4      hvm_init_guest_time(d);
     6.5  
     6.6      d->arch.hvm_domain.params[HVM_PARAM_HPET_ENABLED] = 1;
     6.7 +    d->arch.hvm_domain.params[HVM_PARAM_VPT_ALIGN]    = 1;
     6.8  
     6.9      hvm_init_cacheattr_region_list(d);
    6.10  
     7.1 --- a/xen/arch/x86/hvm/vpt.c	Fri Feb 13 09:38:16 2009 +0000
     7.2 +++ b/xen/arch/x86/hvm/vpt.c	Fri Feb 13 09:43:06 2009 +0000
     7.3 @@ -389,8 +389,14 @@ void create_periodic_time(
     7.4       * LAPIC ticks for process accounting can see long sequences of process
     7.5       * ticks incorrectly accounted to interrupt processing.
     7.6       */
     7.7 -    if ( !pt->one_shot && (pt->source == PTSRC_lapic) )
     7.8 -        pt->scheduled += delta >> 1;
     7.9 +    if ( !pt->one_shot )
    7.10 +    {
    7.11 +        if ( v->domain->arch.hvm_domain.params[HVM_PARAM_VPT_ALIGN] )
    7.12 +            pt->scheduled = align_timer(pt->scheduled, pt->period);
    7.13 +        else if ( pt->source == PTSRC_lapic )
    7.14 +            pt->scheduled += delta >> 1;
    7.15 +    }
    7.16 +
    7.17      pt->cb = cb;
    7.18      pt->priv = data;
    7.19  
     8.1 --- a/xen/common/timer.c	Fri Feb 13 09:38:16 2009 +0000
     8.2 +++ b/xen/common/timer.c	Fri Feb 13 09:43:06 2009 +0000
     8.3 @@ -473,6 +473,13 @@ void process_pending_timers(void)
     8.4          timer_softirq_action();
     8.5  }
     8.6  
     8.7 +s_time_t align_timer(s_time_t firsttick, uint64_t period)
     8.8 +{
     8.9 +    if ( !period )
    8.10 +        return firsttick;
    8.11 +
    8.12 +    return firsttick + (period - 1) - ((firsttick - 1) % period);
    8.13 +}
    8.14  
    8.15  static void dump_timerq(unsigned char key)
    8.16  {
     9.1 --- a/xen/include/public/hvm/params.h	Fri Feb 13 09:38:16 2009 +0000
     9.2 +++ b/xen/include/public/hvm/params.h	Fri Feb 13 09:43:06 2009 +0000
     9.3 @@ -103,6 +103,9 @@
     9.4  /* TSS used on Intel when CR0.PE=0. */
     9.5  #define HVM_PARAM_VM86_TSS     15
     9.6  
     9.7 -#define HVM_NR_PARAMS          16
     9.8 +/* Boolean: Enable aligning all periodic vpts to reduce interrupts */
     9.9 +#define HVM_PARAM_VPT_ALIGN    16
    9.10 +
    9.11 +#define HVM_NR_PARAMS          17
    9.12  
    9.13  #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
    10.1 --- a/xen/include/xen/timer.h	Fri Feb 13 09:38:16 2009 +0000
    10.2 +++ b/xen/include/xen/timer.h	Fri Feb 13 09:43:06 2009 +0000
    10.3 @@ -122,6 +122,9 @@ DECLARE_PER_CPU(s_time_t, timer_deadline
    10.4  /* Arch-defined function to reprogram timer hardware for new deadline. */
    10.5  extern int reprogram_timer(s_time_t timeout);
    10.6  
    10.7 +/* calculate the aligned first tick time for a given periodic timer */ 
    10.8 +extern s_time_t align_timer(s_time_t firsttick, uint64_t period);
    10.9 +
   10.10  #endif /* _TIMER_H_ */
   10.11  
   10.12  /*