ia64/xen-unstable

changeset 10293:4122e88b6c75

Move idle-vcpu allocation logic to a common function.
Signed-off-by: Kevin Tian <kevin.tian@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Jun 02 09:31:35 2006 +0100 (2006-06-02)
parents e67432187b88
children 1f619b6adbc6
files xen/arch/ia64/linux-xen/smpboot.c xen/arch/ia64/xen/xensetup.c xen/arch/x86/setup.c xen/arch/x86/smpboot.c xen/common/domain.c xen/include/xen/domain.h
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/smpboot.c	Fri Jun 02 09:20:58 2006 +0100
     1.2 +++ b/xen/arch/ia64/linux-xen/smpboot.c	Fri Jun 02 09:31:35 2006 +0100
     1.3 @@ -488,7 +488,7 @@ do_rest:
     1.4  #else
     1.5  	struct vcpu *v;
     1.6  
     1.7 -	v = idle_vcpu[cpu] = alloc_vcpu(idle_vcpu[0]->domain, cpu, cpu);
     1.8 +	v = alloc_idle_vcpu(cpu);
     1.9  	BUG_ON(v == NULL);
    1.10  
    1.11  	//printf ("do_boot_cpu: cpu=%d, domain=%p, vcpu=%p\n", cpu, idle, v);
     2.1 --- a/xen/arch/ia64/xen/xensetup.c	Fri Jun 02 09:20:58 2006 +0100
     2.2 +++ b/xen/arch/ia64/xen/xensetup.c	Fri Jun 02 09:31:35 2006 +0100
     2.3 @@ -35,8 +35,6 @@ unsigned long xenheap_phys_end, total_pa
     2.4  char saved_command_line[COMMAND_LINE_SIZE];
     2.5  char dom0_command_line[COMMAND_LINE_SIZE];
     2.6  
     2.7 -struct vcpu *idle_vcpu[NR_CPUS];
     2.8 -
     2.9  cpumask_t cpu_present_map;
    2.10  
    2.11  extern unsigned long domain0_ready;
     3.1 --- a/xen/arch/x86/setup.c	Fri Jun 02 09:20:58 2006 +0100
     3.2 +++ b/xen/arch/x86/setup.c	Fri Jun 02 09:31:35 2006 +0100
     3.3 @@ -85,8 +85,6 @@ extern void early_cpu_init(void);
     3.4  
     3.5  struct tss_struct init_tss[NR_CPUS];
     3.6  
     3.7 -struct vcpu *idle_vcpu[NR_CPUS];
     3.8 -
     3.9  extern unsigned long cpu0_stack[];
    3.10  
    3.11  struct cpuinfo_x86 boot_cpu_data = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
     4.1 --- a/xen/arch/x86/smpboot.c	Fri Jun 02 09:20:58 2006 +0100
     4.2 +++ b/xen/arch/x86/smpboot.c	Fri Jun 02 09:31:35 2006 +0100
     4.3 @@ -887,25 +887,13 @@ static int __devinit do_boot_cpu(int api
     4.4  	int timeout;
     4.5  	unsigned long start_eip;
     4.6  	unsigned short nmi_high = 0, nmi_low = 0;
     4.7 -	struct domain *d;
     4.8  	struct vcpu *v;
     4.9 -	int vcpu_id;
    4.10  
    4.11  	++cpucount;
    4.12  
    4.13  	booting_cpu = cpu;
    4.14  
    4.15 -	if ((vcpu_id = cpu % MAX_VIRT_CPUS) == 0) {
    4.16 -		d = domain_create(IDLE_DOMAIN_ID, cpu);
    4.17 -		BUG_ON(d == NULL);
    4.18 -		v = d->vcpu[0];
    4.19 -	} else {
    4.20 -		d = idle_vcpu[cpu - vcpu_id]->domain;
    4.21 -		BUG_ON(d == NULL);
    4.22 -		v = alloc_vcpu(d, vcpu_id, cpu);
    4.23 -	}
    4.24 -
    4.25 -	idle_vcpu[cpu] = v;
    4.26 +	v = alloc_idle_vcpu(cpu);
    4.27  	BUG_ON(v == NULL);
    4.28  
    4.29  	v->arch.monitor_table = pagetable_from_paddr(__pa(idle_pg_table));
     5.1 --- a/xen/common/domain.c	Fri Jun 02 09:20:58 2006 +0100
     5.2 +++ b/xen/common/domain.c	Fri Jun 02 09:31:35 2006 +0100
     5.3 @@ -32,6 +32,8 @@ struct domain *domain_list;
     5.4  
     5.5  struct domain *dom0;
     5.6  
     5.7 +struct vcpu *idle_vcpu[NR_CPUS];
     5.8 +
     5.9  struct domain *alloc_domain(domid_t domid)
    5.10  {
    5.11      struct domain *d;
    5.12 @@ -104,6 +106,29 @@ struct vcpu *alloc_vcpu(
    5.13      return v;
    5.14  }
    5.15  
    5.16 +struct vcpu *alloc_idle_vcpu(unsigned int cpu_id)
    5.17 +{
    5.18 +    struct domain *d;
    5.19 +    struct vcpu *v;
    5.20 +    unsigned int vcpu_id;
    5.21 +
    5.22 +    if ((vcpu_id = cpu_id % MAX_VIRT_CPUS) == 0)
    5.23 +    {
    5.24 +        d = domain_create(IDLE_DOMAIN_ID, cpu_id);
    5.25 +        BUG_ON(d == NULL);
    5.26 +        v = d->vcpu[0];
    5.27 +    }
    5.28 +    else
    5.29 +    {
    5.30 +        d = idle_vcpu[cpu_id - vcpu_id]->domain;
    5.31 +        BUG_ON(d == NULL);
    5.32 +        v = alloc_vcpu(d, vcpu_id, cpu_id);
    5.33 +    }
    5.34 +
    5.35 +    idle_vcpu[cpu_id] = v;
    5.36 +
    5.37 +    return v;
    5.38 +}
    5.39  
    5.40  struct domain *domain_create(domid_t domid, unsigned int cpu)
    5.41  {
     6.1 --- a/xen/include/xen/domain.h	Fri Jun 02 09:20:58 2006 +0100
     6.2 +++ b/xen/include/xen/domain.h	Fri Jun 02 09:31:35 2006 +0100
     6.3 @@ -6,6 +6,7 @@ struct vcpu *alloc_vcpu(
     6.4      struct domain *d, unsigned int vcpu_id, unsigned int cpu_id);
     6.5  int boot_vcpu(
     6.6      struct domain *d, int vcpuid, struct vcpu_guest_context *ctxt);
     6.7 +struct vcpu *alloc_idle_vcpu(unsigned int cpu_id);
     6.8  
     6.9  struct domain *alloc_domain(domid_t domid);
    6.10  void free_domain(struct domain *d);