ia64/xen-unstable

changeset 19296:95e3cd67add2

Add vcpu_migration_delay=<microsecs> boot option to scheduler

The idea is borrowed from Linux kernel: if the vCPU is just
scheduled out and put to run-queue, it's likely cache-hot on its
current pCPU, and it may be scheduled in in a short period of time;
however, if vCPU is migrated to another pCPU, it need to re-warm the
cache.

The patch introduces an option vcpu_migration_delay to avoid
aggressive vCPU migration (actually we really see migration frequency
is very high most of the time.), while in the meantime keeping load
balancing over slightly longer time scales.

Linux kernel uses 0.5ms by default. Considering the cost may be
higher (e.g. VMCS impact) than in native, vcpu_migration_delay=1000 is
chosen for our tests, which are performed on a 4x 6-core Dunnington
platform. In 24-VM case, there is ~2% stable performance gain for
enterprise workloads like SPECjbb and sysbench. If HVM is with
stubdom, the gain is more: 4% for the same workloads.

Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Mar 09 09:37:52 2009 +0000 (2009-03-09)
parents c4760d58ee6f
children 12c19447f6ea
files xen/common/sched_credit.c
line diff
     1.1 --- a/xen/common/sched_credit.c	Mon Mar 09 09:19:42 2009 +0000
     1.2 +++ b/xen/common/sched_credit.c	Mon Mar 09 09:37:52 2009 +0000
     1.3 @@ -123,7 +123,8 @@
     1.4      _MACRO(dom_init)                        \
     1.5      _MACRO(dom_destroy)                     \
     1.6      _MACRO(vcpu_init)                       \
     1.7 -    _MACRO(vcpu_destroy)
     1.8 +    _MACRO(vcpu_destroy)                    \
     1.9 +    _MACRO(vcpu_hot)
    1.10  
    1.11  #ifndef NDEBUG
    1.12  #define CSCHED_STATS_EXPAND_CHECKS(_MACRO)  \
    1.13 @@ -395,14 +396,37 @@ static inline void
    1.14  #define CSCHED_VCPU_CHECK(_vc)
    1.15  #endif
    1.16  
    1.17 +/*
    1.18 + * Delay, in microseconds, between migrations of a VCPU between PCPUs.
    1.19 + * This prevents rapid fluttering of a VCPU between CPUs, and reduces the
    1.20 + * implicit overheads such as cache-warming. 1ms (1000) has been measured
    1.21 + * as a good value.
    1.22 + */
    1.23 +static unsigned int vcpu_migration_delay;
    1.24 +integer_param("vcpu_migration_delay", vcpu_migration_delay);
    1.25 +
    1.26 +static inline int
    1.27 +__csched_vcpu_is_cache_hot(struct vcpu *v)
    1.28 +{
    1.29 +    int hot = ((NOW() - v->runstate.state_entry_time) <
    1.30 +               ((uint64_t)vcpu_migration_delay * 1000u));
    1.31 +
    1.32 +    if ( hot )
    1.33 +        CSCHED_STAT_CRANK(vcpu_hot);
    1.34 +
    1.35 +    return hot;
    1.36 +}
    1.37 +
    1.38  static inline int
    1.39  __csched_vcpu_is_migrateable(struct vcpu *vc, int dest_cpu)
    1.40  {
    1.41      /*
    1.42 -     * Don't pick up work that's in the peer's scheduling tail. Also only pick
    1.43 -     * up work that's allowed to run on our CPU.
    1.44 +     * Don't pick up work that's in the peer's scheduling tail or hot on
    1.45 +     * peer PCPU. Only pick up work that's allowed to run on our CPU.
    1.46       */
    1.47 -    return !vc->is_running && cpu_isset(dest_cpu, vc->cpu_affinity);
    1.48 +    return !vc->is_running &&
    1.49 +           !__csched_vcpu_is_cache_hot(vc) &&
    1.50 +           cpu_isset(dest_cpu, vc->cpu_affinity);
    1.51  }
    1.52  
    1.53  static int
    1.54 @@ -1297,7 +1321,8 @@ csched_dump(void)
    1.55             "\tmsecs per tick     = %dms\n"
    1.56             "\tcredits per tick   = %d\n"
    1.57             "\tticks per tslice   = %d\n"
    1.58 -           "\tticks per acct     = %d\n",
    1.59 +           "\tticks per acct     = %d\n"
    1.60 +           "\tmigration delay    = %uus\n",
    1.61             csched_priv.ncpus,
    1.62             csched_priv.master,
    1.63             csched_priv.credit,
    1.64 @@ -1308,7 +1333,8 @@ csched_dump(void)
    1.65             CSCHED_MSECS_PER_TICK,
    1.66             CSCHED_CREDITS_PER_TICK,
    1.67             CSCHED_TICKS_PER_TSLICE,
    1.68 -           CSCHED_TICKS_PER_ACCT);
    1.69 +           CSCHED_TICKS_PER_ACCT,
    1.70 +           vcpu_migration_delay);
    1.71  
    1.72      cpumask_scnprintf(idlers_buf, sizeof(idlers_buf), csched_priv.idlers);
    1.73      printk("idlers: %s\n", idlers_buf);