ia64/xen-unstable

changeset 10030:d8954fc3b76b

Set up and tear down phys_proc_id, cpu_core_id, cpu_sibling_map
and cpu_core_map when CPUs come online and go offline.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed May 10 15:44:56 2006 +0100 (2006-05-10)
parents 019411cc3ae5
children 8f02d7cb222a
files linux-2.6-xen-sparse/drivers/xen/core/smpboot.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Wed May 10 13:27:17 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Wed May 10 15:44:56 2006 +0100
     1.3 @@ -107,6 +107,18 @@ void __init smp_alloc_memory(void)
     1.4  {
     1.5  }
     1.6  
     1.7 +static inline void
     1.8 +set_cpu_sibling_map(int cpu)
     1.9 +{
    1.10 +	phys_proc_id[cpu] = cpu;
    1.11 +	cpu_core_id[cpu]  = 0;
    1.12 +
    1.13 +	cpu_sibling_map[cpu] = cpumask_of_cpu(cpu);
    1.14 +	cpu_core_map[cpu]    = cpumask_of_cpu(cpu);
    1.15 +
    1.16 +	cpu_data[cpu].booted_cores = 1;
    1.17 +}
    1.18 +
    1.19  static void xen_smp_intr_init(unsigned int cpu)
    1.20  {
    1.21  	sprintf(resched_name[cpu], "resched%d", cpu);
    1.22 @@ -230,14 +242,20 @@ void __init smp_prepare_cpus(unsigned in
    1.23  	struct Xgt_desc_struct *gdt_descr;
    1.24  #endif
    1.25  
    1.26 +	boot_cpu_data.apicid = 0;
    1.27  	cpu_data[0] = boot_cpu_data;
    1.28  
    1.29  	cpu_2_logical_apicid[0] = 0;
    1.30  	x86_cpu_to_apicid[0] = 0;
    1.31  
    1.32  	current_thread_info()->cpu = 0;
    1.33 -	cpu_sibling_map[0] = cpumask_of_cpu(0);
    1.34 -	cpu_core_map[0]    = cpumask_of_cpu(0);
    1.35 +
    1.36 +	for (cpu = 0; cpu < NR_CPUS; cpu++) {
    1.37 +		cpus_clear(cpu_sibling_map[cpu]);
    1.38 +		cpus_clear(cpu_core_map[cpu]);
    1.39 +	}
    1.40 +
    1.41 +	set_cpu_sibling_map(0);
    1.42  
    1.43  	xen_smp_intr_init(0);
    1.44  
    1.45 @@ -262,6 +280,8 @@ void __init smp_prepare_cpus(unsigned in
    1.46  			XENFEAT_writable_descriptor_tables);
    1.47  
    1.48  		cpu_data[cpu] = boot_cpu_data;
    1.49 +		cpu_data[cpu].apicid = cpu;
    1.50 +
    1.51  		cpu_2_logical_apicid[cpu] = cpu;
    1.52  		x86_cpu_to_apicid[cpu] = cpu;
    1.53  
    1.54 @@ -470,6 +490,18 @@ void smp_resume(void)
    1.55  		vcpu_hotplug(i);
    1.56  }
    1.57  
    1.58 +static void
    1.59 +remove_siblinginfo(int cpu)
    1.60 +{
    1.61 +	phys_proc_id[cpu] = BAD_APICID;
    1.62 +	cpu_core_id[cpu]  = BAD_APICID;
    1.63 +
    1.64 +	cpus_clear(cpu_sibling_map[cpu]);
    1.65 +	cpus_clear(cpu_core_map[cpu]);
    1.66 +
    1.67 +	cpu_data[cpu].booted_cores = 0;
    1.68 +}
    1.69 +
    1.70  int __cpu_disable(void)
    1.71  {
    1.72  	cpumask_t map = cpu_online_map;
    1.73 @@ -478,6 +510,8 @@ int __cpu_disable(void)
    1.74  	if (cpu == 0)
    1.75  		return -EBUSY;
    1.76  
    1.77 +	remove_siblinginfo(cpu);
    1.78 +
    1.79  	cpu_clear(cpu, map);
    1.80  	fixup_irqs(map);
    1.81  	cpu_clear(cpu, cpu_online_map);
    1.82 @@ -549,6 +583,10 @@ int __devinit __cpu_up(unsigned int cpu)
    1.83  		prepare_for_smp();
    1.84  #endif
    1.85  
    1.86 +	/* This must be done before setting cpu_online_map */
    1.87 +	set_cpu_sibling_map(cpu);
    1.88 +	wmb();
    1.89 +
    1.90  	xen_smp_intr_init(cpu);
    1.91  	cpu_set(cpu, cpu_online_map);
    1.92