From: kaf24@firebug.cl.cam.ac.uk Date: Fri, 2 Jun 2006 08:31:35 +0000 (+0100) Subject: Move idle-vcpu allocation logic to a common function. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15972^2~49^2~23 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=32ede0e12b4760907ab0f5a2e4a976b181e12c32;p=xen.git Move idle-vcpu allocation logic to a common function. Signed-off-by: Kevin Tian --- diff --git a/xen/arch/ia64/linux-xen/smpboot.c b/xen/arch/ia64/linux-xen/smpboot.c index 493488ba1f..11e1b1bbc3 100644 --- a/xen/arch/ia64/linux-xen/smpboot.c +++ b/xen/arch/ia64/linux-xen/smpboot.c @@ -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); diff --git a/xen/arch/ia64/xen/xensetup.c b/xen/arch/ia64/xen/xensetup.c index 8040fd5222..60ad3b179d 100644 --- a/xen/arch/ia64/xen/xensetup.c +++ b/xen/arch/ia64/xen/xensetup.c @@ -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; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 944bdb2e00..7c0ff9890d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -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 }; diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 8572105325..f75c01f7b2 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -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)); diff --git a/xen/common/domain.c b/xen/common/domain.c index 5ea044c3ee..48a2b32162 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -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) { diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 8e6992fea2..e421c8442d 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -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);