Move idle-vcpu allocation logic to a common function.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 2 Jun 2006 08:31:35 +0000 (09:31 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 2 Jun 2006 08:31:35 +0000 (09:31 +0100)
Signed-off-by: Kevin Tian <kevin.tian@intel.com>
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

index 493488ba1ffae022a3c1970a79411732062350d4..11e1b1bbc3e65fa91a371156beff5e4fc3479220 100644 (file)
@@ -488,7 +488,7 @@ do_rest:
 #else
        struct vcpu *v;
 
-       v = idle_vcpu[cpu] = alloc_vcpu(idle_vcpu[0]->domain, cpu, cpu);
+       v = alloc_idle_vcpu(cpu);
        BUG_ON(v == NULL);
 
        //printf ("do_boot_cpu: cpu=%d, domain=%p, vcpu=%p\n", cpu, idle, v);
index 8040fd5222e2c61eea377065bfa4d02ca607ac08..60ad3b179d8a53febd677990c8735d3e61cac254 100644 (file)
@@ -35,8 +35,6 @@ unsigned long xenheap_phys_end, total_pages;
 char saved_command_line[COMMAND_LINE_SIZE];
 char dom0_command_line[COMMAND_LINE_SIZE];
 
-struct vcpu *idle_vcpu[NR_CPUS];
-
 cpumask_t cpu_present_map;
 
 extern unsigned long domain0_ready;
index 944bdb2e00001bad4aa7542a2f69ea1d7ff80756..7c0ff9890dfbf0615ea049d14b6a67c8468c4f5a 100644 (file)
@@ -85,8 +85,6 @@ extern void early_cpu_init(void);
 
 struct tss_struct init_tss[NR_CPUS];
 
-struct vcpu *idle_vcpu[NR_CPUS];
-
 extern unsigned long cpu0_stack[];
 
 struct cpuinfo_x86 boot_cpu_data = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
index 8572105325e41c0388431dcbf2b70f137942c0c0..f75c01f7b2d60ca0ef83b279b8b3d5a7a6b59333 100644 (file)
@@ -887,25 +887,13 @@ static int __devinit do_boot_cpu(int apicid, int cpu)
        int timeout;
        unsigned long start_eip;
        unsigned short nmi_high = 0, nmi_low = 0;
-       struct domain *d;
        struct vcpu *v;
-       int vcpu_id;
 
        ++cpucount;
 
        booting_cpu = cpu;
 
-       if ((vcpu_id = cpu % MAX_VIRT_CPUS) == 0) {
-               d = domain_create(IDLE_DOMAIN_ID, cpu);
-               BUG_ON(d == NULL);
-               v = d->vcpu[0];
-       } else {
-               d = idle_vcpu[cpu - vcpu_id]->domain;
-               BUG_ON(d == NULL);
-               v = alloc_vcpu(d, vcpu_id, cpu);
-       }
-
-       idle_vcpu[cpu] = v;
+       v = alloc_idle_vcpu(cpu);
        BUG_ON(v == NULL);
 
        v->arch.monitor_table = pagetable_from_paddr(__pa(idle_pg_table));
index 5ea044c3ee4c42d566a08af6a676bb083fae1d72..48a2b32162ee88a4173ee06b2144d731ec4b53be 100644 (file)
@@ -32,6 +32,8 @@ struct domain *domain_list;
 
 struct domain *dom0;
 
+struct vcpu *idle_vcpu[NR_CPUS];
+
 struct domain *alloc_domain(domid_t domid)
 {
     struct domain *d;
@@ -104,6 +106,29 @@ struct vcpu *alloc_vcpu(
     return v;
 }
 
+struct vcpu *alloc_idle_vcpu(unsigned int cpu_id)
+{
+    struct domain *d;
+    struct vcpu *v;
+    unsigned int vcpu_id;
+
+    if ((vcpu_id = cpu_id % MAX_VIRT_CPUS) == 0)
+    {
+        d = domain_create(IDLE_DOMAIN_ID, cpu_id);
+        BUG_ON(d == NULL);
+        v = d->vcpu[0];
+    }
+    else
+    {
+        d = idle_vcpu[cpu_id - vcpu_id]->domain;
+        BUG_ON(d == NULL);
+        v = alloc_vcpu(d, vcpu_id, cpu_id);
+    }
+
+    idle_vcpu[cpu_id] = v;
+
+    return v;
+}
 
 struct domain *domain_create(domid_t domid, unsigned int cpu)
 {
index 8e6992fea293826c12c3bd338ab69f340b5b2c11..e421c8442dca9059af48e7d11d425bad8d32a576 100644 (file)
@@ -6,6 +6,7 @@ struct vcpu *alloc_vcpu(
     struct domain *d, unsigned int vcpu_id, unsigned int cpu_id);
 int boot_vcpu(
     struct domain *d, int vcpuid, struct vcpu_guest_context *ctxt);
+struct vcpu *alloc_idle_vcpu(unsigned int cpu_id);
 
 struct domain *alloc_domain(domid_t domid);
 void free_domain(struct domain *d);