Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 16 Mar 2011 02:00:53 +0000 (19:00 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 16 Mar 2011 02:00:53 +0000 (19:00 -0700)
* 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  x86: Fix and clean up generic_processor_info()
  x86: Don't copy per_cpu cpuinfo for BSP two times
  x86: Move llc_shared_map out of cpu_info

1  2 
arch/x86/include/asm/smp.h
arch/x86/kernel/apic/apic.c
arch/x86/kernel/smpboot.c

index c1bbfa89a0e222ce9e95f744141c8ccd070f03bc,bc6f84e11d32600be4e34d55938cbba502600060..99fa8b47381e1c60f6cfe500e94ece362266157f
  #endif
  #include <asm/thread_info.h>
  #include <asm/cpumask.h>
 +#include <asm/cpufeature.h>
  
  extern int smp_num_siblings;
  extern unsigned int num_processors;
  
 +static inline bool cpu_has_ht_siblings(void)
 +{
 +      bool has_siblings = false;
 +#ifdef CONFIG_SMP
 +      has_siblings = cpu_has_ht && smp_num_siblings > 1;
 +#endif
 +      return has_siblings;
 +}
 +
  DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map);
  DECLARE_PER_CPU(cpumask_var_t, cpu_core_map);
+ /* cpus sharing the last level cache: */
+ DECLARE_PER_CPU(cpumask_var_t, cpu_llc_shared_map);
  DECLARE_PER_CPU(u16, cpu_llc_id);
  DECLARE_PER_CPU(int, cpu_number);
  
@@@ -46,6 -38,11 +48,11 @@@ static inline struct cpumask *cpu_core_
        return per_cpu(cpu_core_map, cpu);
  }
  
+ static inline struct cpumask *cpu_llc_shared_mask(int cpu)
+ {
+       return per_cpu(cpu_llc_shared_map, cpu);
+ }
  DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid);
  DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid);
  
index 76b96d74978a101c4770658e0f053b6e34ea3923,628dcdb7afd536d4772ffa80cd15242562dc2b6c..3606feb7d67ce9336384f9d09a36c93a8d2ae96f
@@@ -1381,17 -1381,12 +1381,17 @@@ void __cpuinit end_local_APIC_setup(voi
  #endif
  
        apic_pm_activate();
 +}
 +
 +void __init bsp_end_local_APIC_setup(void)
 +{
 +      end_local_APIC_setup();
  
        /*
         * Now that local APIC setup is completed for BP, configure the fault
         * handling for interrupt remapping.
         */
 -      if (!smp_processor_id() && intr_remapping_enabled)
 +      if (intr_remapping_enabled)
                enable_drhd_fault_handling();
  
  }
@@@ -1761,7 -1756,7 +1761,7 @@@ int __init APIC_init_uniprocessor(void
                enable_IO_APIC();
  #endif
  
 -      end_local_APIC_setup();
 +      bsp_end_local_APIC_setup();
  
  #ifdef CONFIG_X86_IO_APIC
        if (smp_found_config && !skip_ioapic_setup && nr_ioapics)
@@@ -1930,17 -1925,6 +1930,6 @@@ void __cpuinit generic_processor_info(i
  {
        int cpu;
  
-       /*
-        * Validate version
-        */
-       if (version == 0x0) {
-               pr_warning("BIOS bug, APIC version is 0 for CPU#%d! "
-                          "fixing up to 0x10. (tell your hw vendor)\n",
-                               version);
-               version = 0x10;
-       }
-       apic_version[apicid] = version;
        if (num_processors >= nr_cpu_ids) {
                int max = nr_cpu_ids;
                int thiscpu = max + disabled_cpus;
        }
  
        num_processors++;
-       cpu = cpumask_next_zero(-1, cpu_present_mask);
-       if (version != apic_version[boot_cpu_physical_apicid])
-               WARN_ONCE(1,
-                       "ACPI: apic version mismatch, bootcpu: %x cpu %d: %x\n",
-                       apic_version[boot_cpu_physical_apicid], cpu, version);
-       physid_set(apicid, phys_cpu_present_map);
        if (apicid == boot_cpu_physical_apicid) {
                /*
                 * x86_bios_cpu_apicid is required to have processors listed
                 * in same order as logical cpu numbers. Hence the first
                 * entry is BSP, and so on.
+                * boot_cpu_init() already hold bit 0 in cpu_present_mask
+                * for BSP.
                 */
                cpu = 0;
+       } else
+               cpu = cpumask_next_zero(-1, cpu_present_mask);
+       /*
+        * Validate version
+        */
+       if (version == 0x0) {
+               pr_warning("BIOS bug: APIC version is 0 for CPU %d/0x%x, fixing up to 0x10\n",
+                          cpu, apicid);
+               version = 0x10;
        }
+       apic_version[apicid] = version;
+       if (version != apic_version[boot_cpu_physical_apicid]) {
+               pr_warning("BIOS bug: APIC version mismatch, boot CPU: %x, CPU %d: version %x\n",
+                       apic_version[boot_cpu_physical_apicid], cpu, version);
+       }
+       physid_set(apicid, phys_cpu_present_map);
        if (apicid > max_physical_apicid)
                max_physical_apicid = apicid;
  
index 08776a953487f826dad0acc84b5b6e35f6272387,592214d99b43b6f1e3487a6e51a427bcd6ac6727..e2865df242bcc734740af942834df0db867ae8f8
@@@ -130,6 -130,8 +130,8 @@@ EXPORT_PER_CPU_SYMBOL(cpu_sibling_map)
  DEFINE_PER_CPU(cpumask_var_t, cpu_core_map);
  EXPORT_PER_CPU_SYMBOL(cpu_core_map);
  
+ DEFINE_PER_CPU(cpumask_var_t, cpu_llc_shared_map);
  /* Per CPU bogomips and other parameters */
  DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
  EXPORT_PER_CPU_SYMBOL(cpu_info);
@@@ -355,23 -357,6 +357,6 @@@ notrace static void __cpuinit start_sec
        cpu_idle();
  }
  
- #ifdef CONFIG_CPUMASK_OFFSTACK
- /* In this case, llc_shared_map is a pointer to a cpumask. */
- static inline void copy_cpuinfo_x86(struct cpuinfo_x86 *dst,
-                                   const struct cpuinfo_x86 *src)
- {
-       struct cpumask *llc = dst->llc_shared_map;
-       *dst = *src;
-       dst->llc_shared_map = llc;
- }
- #else
- static inline void copy_cpuinfo_x86(struct cpuinfo_x86 *dst,
-                                   const struct cpuinfo_x86 *src)
- {
-       *dst = *src;
- }
- #endif /* CONFIG_CPUMASK_OFFSTACK */
  /*
   * The bootstrap kernel entry code has set these up. Save them for
   * a given CPU
@@@ -381,7 -366,7 +366,7 @@@ void __cpuinit smp_store_cpu_info(int i
  {
        struct cpuinfo_x86 *c = &cpu_data(id);
  
-       copy_cpuinfo_x86(c, &boot_cpu_data);
+       *c = boot_cpu_data;
        c->cpu_index = id;
        if (id != 0)
                identify_secondary_cpu(c);
  
  static void __cpuinit link_thread_siblings(int cpu1, int cpu2)
  {
-       struct cpuinfo_x86 *c1 = &cpu_data(cpu1);
-       struct cpuinfo_x86 *c2 = &cpu_data(cpu2);
        cpumask_set_cpu(cpu1, cpu_sibling_mask(cpu2));
        cpumask_set_cpu(cpu2, cpu_sibling_mask(cpu1));
        cpumask_set_cpu(cpu1, cpu_core_mask(cpu2));
        cpumask_set_cpu(cpu2, cpu_core_mask(cpu1));
-       cpumask_set_cpu(cpu1, c2->llc_shared_map);
-       cpumask_set_cpu(cpu2, c1->llc_shared_map);
+       cpumask_set_cpu(cpu1, cpu_llc_shared_mask(cpu2));
+       cpumask_set_cpu(cpu2, cpu_llc_shared_mask(cpu1));
  }
  
  
@@@ -425,7 -407,7 +407,7 @@@ void __cpuinit set_cpu_sibling_map(int 
                cpumask_set_cpu(cpu, cpu_sibling_mask(cpu));
        }
  
-       cpumask_set_cpu(cpu, c->llc_shared_map);
+       cpumask_set_cpu(cpu, cpu_llc_shared_mask(cpu));
  
        if (__this_cpu_read(cpu_info.x86_max_cores) == 1) {
                cpumask_copy(cpu_core_mask(cpu), cpu_sibling_mask(cpu));
        for_each_cpu(i, cpu_sibling_setup_mask) {
                if (per_cpu(cpu_llc_id, cpu) != BAD_APICID &&
                    per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) {
-                       cpumask_set_cpu(i, c->llc_shared_map);
-                       cpumask_set_cpu(cpu, cpu_data(i).llc_shared_map);
+                       cpumask_set_cpu(i, cpu_llc_shared_mask(cpu));
+                       cpumask_set_cpu(cpu, cpu_llc_shared_mask(i));
                }
                if (c->phys_proc_id == cpu_data(i).phys_proc_id) {
                        cpumask_set_cpu(i, cpu_core_mask(cpu));
@@@ -476,7 -458,7 +458,7 @@@ const struct cpumask *cpu_coregroup_mas
            !(cpu_has(c, X86_FEATURE_AMD_DCM)))
                return cpu_core_mask(cpu);
        else
-               return c->llc_shared_map;
+               return cpu_llc_shared_mask(cpu);
  }
  
  static void impress_friends(void)
@@@ -1060,7 -1042,7 +1042,7 @@@ static int __init smp_sanity_check(unsi
  
                connect_bsp_APIC();
                setup_local_APIC();
 -              end_local_APIC_setup();
 +              bsp_end_local_APIC_setup();
                return -1;
        }
  
@@@ -1089,13 -1071,13 +1071,13 @@@ void __init native_smp_prepare_cpus(uns
  
        preempt_disable();
        smp_cpu_index_default();
-       memcpy(__this_cpu_ptr(&cpu_info), &boot_cpu_data, sizeof(cpu_info));
-       cpumask_copy(cpu_callin_mask, cpumask_of(0));
-       mb();
        /*
         * Setup boot CPU information
         */
        smp_store_cpu_info(0); /* Final full version of the data */
+       cpumask_copy(cpu_callin_mask, cpumask_of(0));
+       mb();
  #ifdef CONFIG_X86_32
        boot_cpu_logical_apicid = logical_smp_processor_id();
  #endif
        for_each_possible_cpu(i) {
                zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL);
                zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL);
-               zalloc_cpumask_var(&cpu_data(i).llc_shared_map, GFP_KERNEL);
+               zalloc_cpumask_var(&per_cpu(cpu_llc_shared_map, i), GFP_KERNEL);
        }
        set_cpu_sibling_map(0);
  
        if (!skip_ioapic_setup && nr_ioapics)
                enable_IO_APIC();
  
 -      end_local_APIC_setup();
 +      bsp_end_local_APIC_setup();
  
        map_cpu_to_logical_apicid();
  
This page took 0.030747 seconds and 5 git commands to generate.