ia64/xen-unstable

changeset 11622:b7b653e36d20

Make dom0_vcpus_pin a platform independant option.
By default, it's off. When enabled on the command line, it
causes dom0's VCPUs to be pinned to their respective physical
CPUs at creation time. Once pinned, they can never be moved.
ALso cleanup VCPU initialization of scheduler parameters.
Signed-off-by: Emmanuel Ackaouy <ack@xensource.com>
author Emmanuel Ackaouy <ack@xensource.com>
date Mon Sep 25 16:31:02 2006 +0100 (2006-09-25)
parents f052ccc0cc26
children 1d3f52eb256e
files docs/src/user.tex xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/xensetup.c xen/common/domain.c xen/common/schedule.c xen/include/xen/sched.h
line diff
     1.1 --- a/docs/src/user.tex	Mon Sep 25 14:11:22 2006 +0100
     1.2 +++ b/docs/src/user.tex	Mon Sep 25 16:31:02 2006 +0100
     1.3 @@ -3208,6 +3208,8 @@ editing \path{grub.conf}.
     1.4    respectively; if no suffix is specified, the parameter defaults to
     1.5    kilobytes. In previous versions of Xen, suffixes were not supported
     1.6    and the value is always interpreted as kilobytes.
     1.7 +\item [ dom0\_vcpus\_pin ] Pins domain 0 VCPUs on their respective
     1.8 +  physical CPUS (default=false).
     1.9  \item [ tbuf\_size=xxx ] Set the size of the per-cpu trace buffers, in
    1.10    pages (default 0).  
    1.11  \item [ sched=xxx ] Select the CPU scheduler Xen should use.  The
     2.1 --- a/xen/arch/ia64/xen/domain.c	Mon Sep 25 14:11:22 2006 +0100
     2.2 +++ b/xen/arch/ia64/xen/domain.c	Mon Sep 25 16:31:02 2006 +0100
     2.3 @@ -54,7 +54,6 @@ unsigned long dom0_align = 64*1024*1024;
     2.4  static unsigned int dom0_max_vcpus = 1;
     2.5  integer_param("dom0_max_vcpus", dom0_max_vcpus); 
     2.6  
     2.7 -extern int opt_dom0_vcpus_pin;
     2.8  extern unsigned long running_on_sim;
     2.9  
    2.10  extern char dom0_command_line[];
    2.11 @@ -1021,12 +1020,9 @@ int construct_dom0(struct domain *d,
    2.12  	    dom0_max_vcpus = MAX_VIRT_CPUS;
    2.13  	
    2.14  	printf ("Dom0 max_vcpus=%d\n", dom0_max_vcpus);
    2.15 -	for ( i = 1; i < dom0_max_vcpus; i++ ) {
    2.16 +	for ( i = 1; i < dom0_max_vcpus; i++ )
    2.17  	    if (alloc_vcpu(d, i, i) == NULL)
    2.18  		printf ("Cannot allocate dom0 vcpu %d\n", i);
    2.19 -	    else if (opt_dom0_vcpus_pin)
    2.20 -		d->vcpu[i]->cpu_affinity = cpumask_of_cpu(i);
    2.21 -	}
    2.22  
    2.23  	/* Copy the OS image. */
    2.24  	loaddomainelfimage(d,image_start);
     3.1 --- a/xen/arch/ia64/xen/xensetup.c	Mon Sep 25 14:11:22 2006 +0100
     3.2 +++ b/xen/arch/ia64/xen/xensetup.c	Mon Sep 25 16:31:02 2006 +0100
     3.3 @@ -48,10 +48,6 @@ extern void mem_init(void);
     3.4  extern void init_IRQ(void);
     3.5  extern void trap_init(void);
     3.6  
     3.7 -/* opt_dom0_vcpus_pin: If true, dom0 VCPUs are pinned. */
     3.8 -unsigned int opt_dom0_vcpus_pin = 0;
     3.9 -boolean_param("dom0_vcpus_pin", opt_dom0_vcpus_pin);
    3.10 -
    3.11  /* opt_nosmp: If true, secondary processors are ignored. */
    3.12  static int opt_nosmp = 0;
    3.13  boolean_param("nosmp", opt_nosmp);
    3.14 @@ -520,10 +516,6 @@ printk("num_online_cpus=%d, max_cpus=%d\
    3.15    			0) != 0)
    3.16          panic("Could not set up DOM0 guest OS\n");
    3.17  
    3.18 -    /* PIN domain0 VCPU 0 on CPU 0. */
    3.19 -    if (opt_dom0_vcpus_pin)
    3.20 -        dom0->vcpu[0]->cpu_affinity = cpumask_of_cpu(0);
    3.21 -
    3.22      if (!running_on_sim)  // slow on ski and pages are pre-initialized to zero
    3.23  	scrub_heap_pages();
    3.24  
     4.1 --- a/xen/common/domain.c	Mon Sep 25 14:11:22 2006 +0100
     4.2 +++ b/xen/common/domain.c	Mon Sep 25 16:31:02 2006 +0100
     4.3 @@ -82,20 +82,16 @@ struct vcpu *alloc_vcpu(
     4.4  
     4.5      v->domain = d;
     4.6      v->vcpu_id = vcpu_id;
     4.7 -    v->processor = cpu_id;
     4.8      v->vcpu_info = &d->shared_info->vcpu_info[vcpu_id];
     4.9      spin_lock_init(&v->pause_lock);
    4.10  
    4.11 -    v->cpu_affinity = is_idle_domain(d) ?
    4.12 -        cpumask_of_cpu(cpu_id) : CPU_MASK_ALL;
    4.13 -
    4.14      v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline;
    4.15      v->runstate.state_entry_time = NOW();
    4.16  
    4.17      if ( (vcpu_id != 0) && !is_idle_domain(d) )
    4.18          set_bit(_VCPUF_down, &v->vcpu_flags);
    4.19  
    4.20 -    if ( sched_init_vcpu(v) < 0 )
    4.21 +    if ( sched_init_vcpu(v, cpu_id) < 0 )
    4.22      {
    4.23          free_vcpu_struct(v);
    4.24          return NULL;
     5.1 --- a/xen/common/schedule.c	Mon Sep 25 14:11:22 2006 +0100
     5.2 +++ b/xen/common/schedule.c	Mon Sep 25 16:31:02 2006 +0100
     5.3 @@ -37,6 +37,11 @@ extern void arch_getdomaininfo_ctxt(stru
     5.4  static char opt_sched[10] = "credit";
     5.5  string_param("sched", opt_sched);
     5.6  
     5.7 +/* opt_dom0_vcpus_pin: If true, dom0 VCPUs are pinned. */
     5.8 +static unsigned int opt_dom0_vcpus_pin;
     5.9 +boolean_param("dom0_vcpus_pin", opt_dom0_vcpus_pin);
    5.10 +
    5.11 +
    5.12  #define TIME_SLOP      (s32)MICROSECS(50)     /* allow time to slip a bit */
    5.13  
    5.14  /* Various timer handlers. */
    5.15 @@ -97,19 +102,38 @@ void vcpu_runstate_get(struct vcpu *v, s
    5.16      }
    5.17  }
    5.18  
    5.19 -int sched_init_vcpu(struct vcpu *v) 
    5.20 +int sched_init_vcpu(struct vcpu *v, unsigned int processor) 
    5.21  {
    5.22 +    const struct domain * const d = v->domain;
    5.23 +
    5.24 +    /* Initialize processor and affinity settings. */
    5.25 +    v->processor = processor;
    5.26 +
    5.27 +    if ( is_idle_domain(d) || (d->domain_id == 0 && opt_dom0_vcpus_pin) )
    5.28 +    {
    5.29 +        /*
    5.30 +         * The idler and potentially dom0 VCPUs are pinned onto their
    5.31 +         * respective physical CPUs.
    5.32 +         */
    5.33 +        v->cpu_affinity = cpumask_of_cpu(processor);
    5.34 +
    5.35 +        /* The idle VCPUs takes over their CPUs on creation... */
    5.36 +        if ( is_idle_domain(d) )
    5.37 +        {
    5.38 +            per_cpu(schedule_data, v->processor).curr = v;
    5.39 +            per_cpu(schedule_data, v->processor).idle = v;
    5.40 +            set_bit(_VCPUF_running, &v->vcpu_flags);
    5.41 +        }
    5.42 +    }
    5.43 +    else
    5.44 +    {
    5.45 +        v->cpu_affinity = CPU_MASK_ALL;
    5.46 +    }
    5.47 +
    5.48      /* Initialise the per-domain timers. */
    5.49      init_timer(&v->timer, vcpu_timer_fn, v, v->processor);
    5.50      init_timer(&v->poll_timer, poll_timer_fn, v, v->processor);
    5.51  
    5.52 -    if ( is_idle_vcpu(v) )
    5.53 -    {
    5.54 -        per_cpu(schedule_data, v->processor).curr = v;
    5.55 -        per_cpu(schedule_data, v->processor).idle = v;
    5.56 -        set_bit(_VCPUF_running, &v->vcpu_flags);
    5.57 -    }
    5.58 -
    5.59      TRACE_2D(TRC_SCHED_DOM_ADD, v->domain->domain_id, v->vcpu_id);
    5.60  
    5.61      return SCHED_OP(init_vcpu, v);
    5.62 @@ -212,6 +236,9 @@ int vcpu_set_affinity(struct vcpu *v, cp
    5.63      cpumask_t online_affinity;
    5.64      unsigned long flags;
    5.65  
    5.66 +    if ( v->domain->domain_id == 0 && opt_dom0_vcpus_pin )
    5.67 +        return -EINVAL;
    5.68 +
    5.69      cpus_and(online_affinity, *affinity, cpu_online_map);
    5.70      if ( cpus_empty(online_affinity) )
    5.71          return -EINVAL;
     6.1 --- a/xen/include/xen/sched.h	Mon Sep 25 14:11:22 2006 +0100
     6.2 +++ b/xen/include/xen/sched.h	Mon Sep 25 16:31:02 2006 +0100
     6.3 @@ -280,7 +280,7 @@ void new_thread(struct vcpu *d,
     6.4  #define set_current_state(_s) do { current->state = (_s); } while (0)
     6.5  void scheduler_init(void);
     6.6  void schedulers_start(void);
     6.7 -int  sched_init_vcpu(struct vcpu *);
     6.8 +int  sched_init_vcpu(struct vcpu *v, unsigned int processor);
     6.9  void sched_destroy_domain(struct domain *);
    6.10  long sched_adjust(struct domain *, struct xen_domctl_scheduler_op *);
    6.11  int  sched_id(void);