xcp-1.6-updates/xen-4.1.hg

changeset 23250:a168569a7659

x86: consolidate cpu_core_id and phys_proc_id into cpuinfo_x86 struct

This patch moves cpu_core_id and phys_proc_id into cpuinfo_x86
structure. This is similar to upstream Linux kernel's approach.

Signed-off-by: Wei Huang <wei.huang2@amd.com>
xen-unstable changeset: 23610:87c2013c2aa2
xen-unstable date: Tue Jun 28 09:13:31 2011 +0100
author Wei Huang <wei.huang2@amd.com>
date Wed Mar 07 09:23:41 2012 +0000 (2012-03-07)
parents b5051d40e1cc
children f141db2fe4c1
files xen/arch/x86/cpu/amd.c xen/arch/x86/cpu/common.c xen/arch/x86/cpu/mcheck/mce.c xen/arch/x86/smpboot.c xen/include/asm-x86/processor.h
line diff
     1.1 --- a/xen/arch/x86/cpu/amd.c	Wed Mar 07 09:22:58 2012 +0000
     1.2 +++ b/xen/arch/x86/cpu/amd.c	Wed Mar 07 09:23:41 2012 +0000
     1.3 @@ -579,11 +579,11 @@ static void __devinit init_amd(struct cp
     1.4  			while ((1 << bits) < c->x86_max_cores)
     1.5  				bits++;
     1.6  		}
     1.7 -		cpu_core_id[cpu] = phys_proc_id[cpu] & ((1<<bits)-1);
     1.8 -		phys_proc_id[cpu] >>= bits;
     1.9 +		c->cpu_core_id = c->phys_proc_id & ((1<<bits)-1);
    1.10 +		c->phys_proc_id >>= bits;
    1.11  		if (opt_cpu_info)
    1.12  			printk("CPU %d(%d) -> Core %d\n",
    1.13 -			       cpu, c->x86_max_cores, cpu_core_id[cpu]);
    1.14 +			       cpu, c->x86_max_cores, c->cpu_core_id);
    1.15  	}
    1.16  #endif
    1.17  
     2.1 --- a/xen/arch/x86/cpu/common.c	Wed Mar 07 09:22:58 2012 +0000
     2.2 +++ b/xen/arch/x86/cpu/common.c	Wed Mar 07 09:23:41 2012 +0000
     2.3 @@ -326,7 +326,7 @@ void __cpuinit generic_identify(struct c
     2.4  	early_intel_workaround(c);
     2.5  
     2.6  #ifdef CONFIG_X86_HT
     2.7 -	phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
     2.8 +	c->phys_proc_id = (cpuid_ebx(1) >> 24) & 0xff;
     2.9  #endif
    2.10  }
    2.11  
    2.12 @@ -362,6 +362,8 @@ void __cpuinit identify_cpu(struct cpuin
    2.13  	c->x86_max_cores = 1;
    2.14  	c->x86_num_siblings = 1;
    2.15  	c->x86_clflush_size = 0;
    2.16 +	c->phys_proc_id = BAD_APICID;
    2.17 +	c->cpu_core_id = BAD_APICID;
    2.18  	memset(&c->x86_capability, 0, sizeof c->x86_capability);
    2.19  
    2.20  	if (!have_cpuid_p()) {
    2.21 @@ -510,7 +512,6 @@ void __cpuinit detect_extended_topology(
    2.22  	unsigned int ht_mask_width, core_plus_mask_width;
    2.23  	unsigned int core_select_mask, core_level_siblings;
    2.24  	unsigned int initial_apicid;
    2.25 -	int cpu = smp_processor_id();
    2.26  
    2.27  	if ( c->cpuid_level < 0xb )
    2.28  		return;
    2.29 @@ -545,9 +546,9 @@ void __cpuinit detect_extended_topology(
    2.30  
    2.31  	core_select_mask = (~(-1 << core_plus_mask_width)) >> ht_mask_width;
    2.32  
    2.33 -	cpu_core_id[cpu] = phys_pkg_id(initial_apicid, ht_mask_width)
    2.34 +	c->cpu_core_id = phys_pkg_id(initial_apicid, ht_mask_width)
    2.35  		& core_select_mask;
    2.36 -	phys_proc_id[cpu] = phys_pkg_id(initial_apicid, core_plus_mask_width);
    2.37 +	c->phys_proc_id = phys_pkg_id(initial_apicid, core_plus_mask_width);
    2.38  
    2.39  	c->apicid = phys_pkg_id(initial_apicid, 0);
    2.40  	c->x86_max_cores = (core_level_siblings / c->x86_num_siblings);
    2.41 @@ -555,10 +556,10 @@ void __cpuinit detect_extended_topology(
    2.42  	if ( opt_cpu_info )
    2.43  	{
    2.44  		printk("CPU: Physical Processor ID: %d\n",
    2.45 -		       phys_proc_id[cpu]);
    2.46 +		       c->phys_proc_id);
    2.47  		if ( c->x86_max_cores > 1 )
    2.48  			printk("CPU: Processor Core ID: %d\n",
    2.49 -			       cpu_core_id[cpu]);
    2.50 +			       c->cpu_core_id);
    2.51  	}
    2.52  }
    2.53  
    2.54 @@ -567,7 +568,6 @@ void __cpuinit detect_ht(struct cpuinfo_
    2.55  {
    2.56  	u32 	eax, ebx, ecx, edx;
    2.57  	int 	index_msb, core_bits;
    2.58 -	int 	cpu = smp_processor_id();
    2.59  
    2.60  	cpuid(1, &eax, &ebx, &ecx, &edx);
    2.61  
    2.62 @@ -590,11 +590,11 @@ void __cpuinit detect_ht(struct cpuinfo_
    2.63  		}
    2.64  
    2.65  		index_msb = get_count_order(c->x86_num_siblings);
    2.66 -		phys_proc_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb);
    2.67 +		c->phys_proc_id = phys_pkg_id((ebx >> 24) & 0xFF, index_msb);
    2.68  
    2.69  		if (opt_cpu_info)
    2.70  			printk("CPU: Physical Processor ID: %d\n",
    2.71 -			       phys_proc_id[cpu]);
    2.72 +			       c->phys_proc_id);
    2.73  
    2.74  		c->x86_num_siblings = c->x86_num_siblings / c->x86_max_cores;
    2.75  
    2.76 @@ -602,12 +602,12 @@ void __cpuinit detect_ht(struct cpuinfo_
    2.77  
    2.78  		core_bits = get_count_order(c->x86_max_cores);
    2.79  
    2.80 -		cpu_core_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb) &
    2.81 +		c->cpu_core_id = phys_pkg_id((ebx >> 24) & 0xFF, index_msb) &
    2.82  					       ((1 << core_bits) - 1);
    2.83  
    2.84  		if (opt_cpu_info && c->x86_max_cores > 1)
    2.85  			printk("CPU: Processor Core ID: %d\n",
    2.86 -			       cpu_core_id[cpu]);
    2.87 +			       c->cpu_core_id);
    2.88  	}
    2.89  }
    2.90  #endif
     3.1 --- a/xen/arch/x86/cpu/mcheck/mce.c	Wed Mar 07 09:22:58 2012 +0000
     3.2 +++ b/xen/arch/x86/cpu/mcheck/mce.c	Wed Mar 07 09:23:41 2012 +0000
     3.3 @@ -1041,9 +1041,9 @@ void x86_mc_get_cpu_info(unsigned cpu, u
     3.4          if (nthreads != NULL)
     3.5              *nthreads = 1;
     3.6      } else {
     3.7 -        *chipid = phys_proc_id[cpu];
     3.8 +        *chipid = c->phys_proc_id;
     3.9          if (c->x86_max_cores > 1)
    3.10 -            *coreid = cpu_core_id[cpu];
    3.11 +            *coreid = c->cpu_core_id;
    3.12          else
    3.13              *coreid = 0;
    3.14          *threadid = c->apicid & ((1 << (c->x86_num_siblings - 1)) - 1);
     4.1 --- a/xen/arch/x86/smpboot.c	Wed Mar 07 09:22:58 2012 +0000
     4.2 +++ b/xen/arch/x86/smpboot.c	Wed Mar 07 09:23:41 2012 +0000
     4.3 @@ -52,12 +52,6 @@
     4.4  /* Set if we find a B stepping CPU */
     4.5  static int smp_b_stepping;
     4.6  
     4.7 -/* Package ID of each logical CPU */
     4.8 -int phys_proc_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID};
     4.9 -
    4.10 -/* Core ID of each logical CPU */
    4.11 -int cpu_core_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID};
    4.12 -
    4.13  /* representing HT siblings of each logical CPU */
    4.14  DEFINE_PER_CPU_READ_MOSTLY(cpumask_t, cpu_sibling_map);
    4.15  /* representing HT and core siblings of each logical CPU */
    4.16 @@ -258,8 +252,8 @@ static void set_cpu_sibling_map(int cpu)
    4.17      {
    4.18          for_each_cpu_mask ( i, cpu_sibling_setup_map )
    4.19          {
    4.20 -            if ( (phys_proc_id[cpu] == phys_proc_id[i]) &&
    4.21 -                 (cpu_core_id[cpu] == cpu_core_id[i]) )
    4.22 +            if ( (c[cpu].phys_proc_id == c[i].phys_proc_id) &&
    4.23 +                 (c[cpu].cpu_core_id == c[i].cpu_core_id) )
    4.24              {
    4.25                  cpu_set(i, per_cpu(cpu_sibling_map, cpu));
    4.26                  cpu_set(cpu, per_cpu(cpu_sibling_map, i));
    4.27 @@ -282,7 +276,7 @@ static void set_cpu_sibling_map(int cpu)
    4.28  
    4.29      for_each_cpu_mask ( i, cpu_sibling_setup_map )
    4.30      {
    4.31 -        if ( phys_proc_id[cpu] == phys_proc_id[i] )
    4.32 +        if ( c[cpu].phys_proc_id == c[i].phys_proc_id )
    4.33          {
    4.34              cpu_set(i, per_cpu(cpu_core_map, cpu));
    4.35              cpu_set(cpu, per_cpu(cpu_core_map, i));
    4.36 @@ -858,8 +852,8 @@ remove_siblinginfo(int cpu)
    4.37          cpu_clear(cpu, per_cpu(cpu_sibling_map, sibling));
    4.38      cpus_clear(per_cpu(cpu_sibling_map, cpu));
    4.39      cpus_clear(per_cpu(cpu_core_map, cpu));
    4.40 -    phys_proc_id[cpu] = BAD_APICID;
    4.41 -    cpu_core_id[cpu] = BAD_APICID;
    4.42 +    c[cpu].phys_proc_id = BAD_APICID;
    4.43 +    c[cpu].cpu_core_id = BAD_APICID;
    4.44      cpu_clear(cpu, cpu_sibling_setup_map);
    4.45  }
    4.46  
     5.1 --- a/xen/include/asm-x86/processor.h	Wed Mar 07 09:22:58 2012 +0000
     5.2 +++ b/xen/include/asm-x86/processor.h	Wed Mar 07 09:23:41 2012 +0000
     5.3 @@ -175,6 +175,8 @@ struct cpuinfo_x86 {
     5.4      __u32 x86_max_cores; /* cpuid returned max cores value */
     5.5      __u32 booted_cores;  /* number of cores as seen by OS */
     5.6      __u32 x86_num_siblings; /* cpuid logical cpus per chip value */
     5.7 +    int   phys_proc_id; /* package ID of each logical CPU */
     5.8 +    int   cpu_core_id; /* core ID of each logical CPU*/
     5.9      __u32 apicid;
    5.10      unsigned short x86_clflush_size;
    5.11  } __cacheline_aligned;
    5.12 @@ -196,8 +198,6 @@ extern struct cpuinfo_x86 cpu_data[];
    5.13  extern void set_cpuid_faulting(bool_t enable);
    5.14  
    5.15  extern u64 host_pat;
    5.16 -extern int phys_proc_id[NR_CPUS];
    5.17 -extern int cpu_core_id[NR_CPUS];
    5.18  extern bool_t opt_cpu_info;
    5.19  
    5.20  /* Maximum width of physical addresses supported by the hardware */
    5.21 @@ -217,8 +217,8 @@ extern void detect_ht(struct cpuinfo_x86
    5.22  static always_inline void detect_ht(struct cpuinfo_x86 *c) {}
    5.23  #endif
    5.24  
    5.25 -#define cpu_to_core(_cpu)   (cpu_core_id[_cpu])
    5.26 -#define cpu_to_socket(_cpu) (phys_proc_id[_cpu])
    5.27 +#define cpu_to_core(_cpu)   (cpu_data[_cpu].cpu_core_id)
    5.28 +#define cpu_to_socket(_cpu) (cpu_data[_cpu].phys_proc_id)
    5.29  
    5.30  /*
    5.31   * Generic CPUID function