debuggers.hg

changeset 21145:a3f52abcd7da

CSCHED: Optimize __runq_tickle to reduce IPIs

Limiting the number of idle cpus tickled for vcpu migration purpose
to ONLY ONE to get rid of a lot of IPI events which may impact the
average cpu idle residency time.

The default on option 'tickle_one_idle_cpu=0' can be used to disable
this optimization if needed.

Signed-off-by: Wei Gang <gang.wei@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 06 06:59:32 2010 +0100 (2010-04-06)
parents aef25086c71c
children 6868816898bd
files xen/common/sched_credit.c
line diff
     1.1 --- a/xen/common/sched_credit.c	Tue Apr 06 06:56:20 2010 +0100
     1.2 +++ b/xen/common/sched_credit.c	Tue Apr 06 06:59:32 2010 +0100
     1.3 @@ -228,6 +228,11 @@ static void burn_credits(struct csched_v
     1.4      svc->start_time += (credits * MILLISECS(1)) / CSCHED_CREDITS_PER_MSEC;
     1.5  }
     1.6  
     1.7 +static int opt_tickle_one_idle __read_mostly = 1;
     1.8 +boolean_param("tickle_one_idle_cpu", opt_tickle_one_idle);
     1.9 +
    1.10 +DEFINE_PER_CPU(unsigned int, last_tickle_cpu) = 0;
    1.11 +
    1.12  static inline void
    1.13  __runq_tickle(unsigned int cpu, struct csched_vcpu *new)
    1.14  {
    1.15 @@ -265,8 +270,21 @@ static inline void
    1.16          }
    1.17          else
    1.18          {
    1.19 -            CSCHED_STAT_CRANK(tickle_idlers_some);
    1.20 -            cpus_or(mask, mask, csched_priv.idlers);
    1.21 +            cpumask_t idle_mask;
    1.22 +
    1.23 +            cpus_and(idle_mask, csched_priv.idlers, new->vcpu->cpu_affinity);
    1.24 +            if ( !cpus_empty(idle_mask) )
    1.25 +            {
    1.26 +                CSCHED_STAT_CRANK(tickle_idlers_some);
    1.27 +                if ( opt_tickle_one_idle )
    1.28 +                {
    1.29 +                    this_cpu(last_tickle_cpu) = 
    1.30 +                        cycle_cpu(this_cpu(last_tickle_cpu), idle_mask);
    1.31 +                    cpu_set(this_cpu(last_tickle_cpu), mask);
    1.32 +                }
    1.33 +                else
    1.34 +                    cpus_or(mask, mask, idle_mask);
    1.35 +            }
    1.36              cpus_and(mask, mask, new->vcpu->cpu_affinity);
    1.37          }
    1.38      }