ia64/xen-unstable

changeset 19067:a37267e43365

x86: Make the num_siblings CPU parameter per-CPU.

While it is unlikely that a system has a different number of siblings
for different physical CPUs, make this parameter per-CPU for
consistency, and deal with the (so far theoretical) case that this is
different per CPU package.

Signed-off-by: Frank van der Linden <Frank.Vanderlinden@Sun.COM>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 22 11:05:54 2009 +0000 (2009-01-22)
parents af1d9af1a993
children a92ed09b4032
files xen/arch/x86/cpu/common.c xen/arch/x86/cpu/mcheck/mce_intel.c xen/arch/x86/nmi.c xen/arch/x86/oprofile/nmi_int.c xen/arch/x86/oprofile/op_model_p4.c xen/arch/x86/smpboot.c xen/include/asm-x86/processor.h xen/include/asm-x86/smp.h
line diff
     1.1 --- a/xen/arch/x86/cpu/common.c	Wed Jan 21 14:44:43 2009 +0000
     1.2 +++ b/xen/arch/x86/cpu/common.c	Thu Jan 22 11:05:54 2009 +0000
     1.3 @@ -338,6 +338,7 @@ void __cpuinit identify_cpu(struct cpuin
     1.4  	c->x86_vendor_id[0] = '\0'; /* Unset */
     1.5  	c->x86_model_id[0] = '\0';  /* Unset */
     1.6  	c->x86_max_cores = 1;
     1.7 +	c->x86_num_siblings = 1;
     1.8  	c->x86_clflush_size = 0;
     1.9  	memset(&c->x86_capability, 0, sizeof c->x86_capability);
    1.10  
    1.11 @@ -480,27 +481,27 @@ void __cpuinit detect_ht(struct cpuinfo_
    1.12  	if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY))
    1.13  		return;
    1.14  
    1.15 -	smp_num_siblings = (ebx & 0xff0000) >> 16;
    1.16 +	c->x86_num_siblings = (ebx & 0xff0000) >> 16;
    1.17  
    1.18 -	if (smp_num_siblings == 1) {
    1.19 +	if (c->x86_num_siblings == 1) {
    1.20  		printk(KERN_INFO  "CPU: Hyper-Threading is disabled\n");
    1.21 -	} else if (smp_num_siblings > 1 ) {
    1.22 +	} else if (c->x86_num_siblings > 1 ) {
    1.23  
    1.24 -		if (smp_num_siblings > NR_CPUS) {
    1.25 -			printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings);
    1.26 -			smp_num_siblings = 1;
    1.27 +		if (c->x86_num_siblings > NR_CPUS) {
    1.28 +			printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", c->x86_num_siblings);
    1.29 +			c->x86_num_siblings = 1;
    1.30  			return;
    1.31  		}
    1.32  
    1.33 -		index_msb = get_count_order(smp_num_siblings);
    1.34 +		index_msb = get_count_order(c->x86_num_siblings);
    1.35  		phys_proc_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb);
    1.36  
    1.37  		printk(KERN_INFO  "CPU: Physical Processor ID: %d\n",
    1.38  		       phys_proc_id[cpu]);
    1.39  
    1.40 -		smp_num_siblings = smp_num_siblings / c->x86_max_cores;
    1.41 +		c->x86_num_siblings = c->x86_num_siblings / c->x86_max_cores;
    1.42  
    1.43 -		index_msb = get_count_order(smp_num_siblings) ;
    1.44 +		index_msb = get_count_order(c->x86_num_siblings) ;
    1.45  
    1.46  		core_bits = get_count_order(c->x86_max_cores);
    1.47  
     2.1 --- a/xen/arch/x86/cpu/mcheck/mce_intel.c	Wed Jan 21 14:44:43 2009 +0000
     2.2 +++ b/xen/arch/x86/cpu/mcheck/mce_intel.c	Thu Jan 22 11:05:54 2009 +0000
     2.3 @@ -186,7 +186,8 @@ static struct mc_info *machine_check_pol
     2.4      mcg.mc_socketid = phys_proc_id[cpu];
     2.5      mcg.mc_coreid = cpu_core_id[cpu];
     2.6      mcg.mc_apicid = cpu_physical_id(cpu);
     2.7 -    mcg.mc_core_threadid = mcg.mc_apicid & ( 1 << (smp_num_siblings - 1)); 
     2.8 +    mcg.mc_core_threadid =
     2.9 +        mcg.mc_apicid & ( 1 << (cpu_data[cpu].x86_num_siblings - 1)); 
    2.10      rdmsrl(MSR_IA32_MCG_STATUS, mcg.mc_gstatus);
    2.11  
    2.12      for ( i = 0; i < nr_mce_banks; i++ ) {
     3.1 --- a/xen/arch/x86/nmi.c	Wed Jan 21 14:44:43 2009 +0000
     3.2 +++ b/xen/arch/x86/nmi.c	Thu Jan 22 11:05:54 2009 +0000
     3.3 @@ -286,7 +286,7 @@ static int __pminit setup_p4_watchdog(vo
     3.4  
     3.5      nmi_perfctr_msr = MSR_P4_IQ_PERFCTR0;
     3.6      nmi_p4_cccr_val = P4_NMI_IQ_CCCR0;
     3.7 -    if ( smp_num_siblings == 2 )
     3.8 +    if ( boot_cpu_data.x86_num_siblings == 2 )
     3.9          nmi_p4_cccr_val |= P4_CCCR_OVF_PMI1;
    3.10  
    3.11      if (!(misc_enable & MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL))
     4.1 --- a/xen/arch/x86/oprofile/nmi_int.c	Wed Jan 21 14:44:43 2009 +0000
     4.2 +++ b/xen/arch/x86/oprofile/nmi_int.c	Thu Jan 22 11:05:54 2009 +0000
     4.3 @@ -326,7 +326,7 @@ static int __init p4_init(char ** cpu_ty
     4.4  	model = &op_p4_spec;
     4.5  	return 1;
     4.6  #else
     4.7 -	switch (smp_num_siblings) {
     4.8 +	switch (current_cpu_data.x86_num_siblings) {
     4.9  		case 1:
    4.10  			*cpu_type = "i386/p4";
    4.11  			model = &op_p4_spec;
     5.1 --- a/xen/arch/x86/oprofile/op_model_p4.c	Wed Jan 21 14:44:43 2009 +0000
     5.2 +++ b/xen/arch/x86/oprofile/op_model_p4.c	Thu Jan 22 11:05:54 2009 +0000
     5.3 @@ -41,7 +41,7 @@ static unsigned int num_counters = NUM_C
     5.4  static inline void setup_num_counters(void)
     5.5  {
     5.6  #ifdef CONFIG_SMP
     5.7 -	if (smp_num_siblings == 2)
     5.8 +	if (boot_cpu_data.x86_num_siblings == 2) 	/* XXX */
     5.9  		num_counters = NUM_COUNTERS_HT2;
    5.10  #endif
    5.11  }
    5.12 @@ -49,7 +49,7 @@ static inline void setup_num_counters(vo
    5.13  static int inline addr_increment(void)
    5.14  {
    5.15  #ifdef CONFIG_SMP
    5.16 -	return smp_num_siblings == 2 ? 2 : 1;
    5.17 +	return boot_cpu_data.x86_num_siblings == 2 ? 2 : 1;
    5.18  #else
    5.19  	return 1;
    5.20  #endif
     6.1 --- a/xen/arch/x86/smpboot.c	Wed Jan 21 14:44:43 2009 +0000
     6.2 +++ b/xen/arch/x86/smpboot.c	Thu Jan 22 11:05:54 2009 +0000
     6.3 @@ -63,12 +63,6 @@
     6.4  /* Set if we find a B stepping CPU */
     6.5  static int __devinitdata smp_b_stepping;
     6.6  
     6.7 -/* Number of siblings per CPU package */
     6.8 -int smp_num_siblings = 1;
     6.9 -#ifdef CONFIG_X86_HT
    6.10 -EXPORT_SYMBOL(smp_num_siblings);
    6.11 -#endif
    6.12 -
    6.13  /* Package ID of each logical CPU */
    6.14  int phys_proc_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID};
    6.15  
    6.16 @@ -423,7 +417,7 @@ set_cpu_sibling_map(int cpu)
    6.17  
    6.18  	cpu_set(cpu, cpu_sibling_setup_map);
    6.19  
    6.20 -	if (smp_num_siblings > 1) {
    6.21 +	if (c[cpu].x86_num_siblings > 1) {
    6.22  		for_each_cpu_mask(i, cpu_sibling_setup_map) {
    6.23  			if (phys_proc_id[cpu] == phys_proc_id[i] &&
    6.24  			    cpu_core_id[cpu] == cpu_core_id[i]) {
    6.25 @@ -437,7 +431,7 @@ set_cpu_sibling_map(int cpu)
    6.26  		cpu_set(cpu, cpu_sibling_map[cpu]);
    6.27  	}
    6.28  
    6.29 -	if (current_cpu_data.x86_max_cores == 1) {
    6.30 +	if (c[cpu].x86_max_cores == 1) {
    6.31  		cpu_core_map[cpu] = cpu_sibling_map[cpu];
    6.32  		c[cpu].booted_cores = 1;
    6.33  		return;
     7.1 --- a/xen/include/asm-x86/processor.h	Wed Jan 21 14:44:43 2009 +0000
     7.2 +++ b/xen/include/asm-x86/processor.h	Thu Jan 22 11:05:54 2009 +0000
     7.3 @@ -169,6 +169,7 @@ struct cpuinfo_x86 {
     7.4      int  x86_power;
     7.5      __u32 x86_max_cores; /* cpuid returned max cores value */
     7.6      __u32 booted_cores;  /* number of cores as seen by OS */
     7.7 +    __u32 x86_num_siblings; /* cpuid logical cpus per chip value */
     7.8      __u32 apicid;
     7.9      unsigned short x86_clflush_size;
    7.10  } __cacheline_aligned;
     8.1 --- a/xen/include/asm-x86/smp.h	Wed Jan 21 14:44:43 2009 +0000
     8.2 +++ b/xen/include/asm-x86/smp.h	Thu Jan 22 11:05:54 2009 +0000
     8.3 @@ -32,7 +32,6 @@
     8.4   
     8.5  extern void smp_alloc_memory(void);
     8.6  extern int pic_mode;
     8.7 -extern int smp_num_siblings;
     8.8  extern cpumask_t cpu_sibling_map[];
     8.9  extern cpumask_t cpu_core_map[];
    8.10