Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86: convert cpu_llc_id to be a per cpu variable

Convert cpu_llc_id from a static array sized by NR_CPUS to a per_cpu
variable. This saves sizeof(cpu_llc_id) * NR unused cpus. Access is
mostly from startup and CPU HOTPLUG functions.

Note there's an additional change of the type of cpu_llc_id from int to
u8 for ARCH i386 to correspond with the same type in ARCH x86_64.

Signed-off-by: Mike Travis <travis@sgi.com>
Cc: Andi Kleen <ak@suse.de>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: "Siddha, Suresh B" <suresh.b.siddha@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Mike Travis and committed by
Thomas Gleixner
b6278470 71fff5e6

+15 -10
+2 -2
arch/x86/kernel/cpu/intel_cacheinfo.c
··· 417 417 if (new_l2) { 418 418 l2 = new_l2; 419 419 #ifdef CONFIG_X86_HT 420 - cpu_llc_id[cpu] = l2_id; 420 + per_cpu(cpu_llc_id, cpu) = l2_id; 421 421 #endif 422 422 } 423 423 424 424 if (new_l3) { 425 425 l3 = new_l3; 426 426 #ifdef CONFIG_X86_HT 427 - cpu_llc_id[cpu] = l3_id; 427 + per_cpu(cpu_llc_id, cpu) = l3_id; 428 428 #endif 429 429 } 430 430
+3 -3
arch/x86/kernel/smpboot_32.c
··· 67 67 EXPORT_SYMBOL(smp_num_siblings); 68 68 69 69 /* Last level cache ID of each logical CPU */ 70 - int cpu_llc_id[NR_CPUS] __cpuinitdata = {[0 ... NR_CPUS-1] = BAD_APICID}; 70 + DEFINE_PER_CPU(u8, cpu_llc_id) = BAD_APICID; 71 71 72 72 /* representing HT siblings of each logical CPU */ 73 73 DEFINE_PER_CPU(cpumask_t, cpu_sibling_map); ··· 348 348 } 349 349 350 350 for_each_cpu_mask(i, cpu_sibling_setup_map) { 351 - if (cpu_llc_id[cpu] != BAD_APICID && 352 - cpu_llc_id[cpu] == cpu_llc_id[i]) { 351 + if (per_cpu(cpu_llc_id, cpu) != BAD_APICID && 352 + per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) { 353 353 cpu_set(i, c[cpu].llc_shared_map); 354 354 cpu_set(cpu, c[i].llc_shared_map); 355 355 }
+3 -3
arch/x86/kernel/smpboot_64.c
··· 65 65 EXPORT_SYMBOL(smp_num_siblings); 66 66 67 67 /* Last level cache ID of each logical CPU */ 68 - u8 cpu_llc_id[NR_CPUS] __cpuinitdata = {[0 ... NR_CPUS-1] = BAD_APICID}; 68 + DEFINE_PER_CPU(u8, cpu_llc_id) = BAD_APICID; 69 69 70 70 /* Bitmask of currently online CPUs */ 71 71 cpumask_t cpu_online_map __read_mostly; ··· 283 283 } 284 284 285 285 for_each_cpu_mask(i, cpu_sibling_setup_map) { 286 - if (cpu_llc_id[cpu] != BAD_APICID && 287 - cpu_llc_id[cpu] == cpu_llc_id[i]) { 286 + if (per_cpu(cpu_llc_id, cpu) != BAD_APICID && 287 + per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) { 288 288 cpu_set(i, c[cpu].llc_shared_map); 289 289 cpu_set(cpu, c[i].llc_shared_map); 290 290 }
+5 -1
include/asm-x86/processor_32.h
··· 110 110 #define current_cpu_data boot_cpu_data 111 111 #endif 112 112 113 - extern int cpu_llc_id[NR_CPUS]; 113 + /* 114 + * the following now lives in the per cpu area: 115 + * extern int cpu_llc_id[NR_CPUS]; 116 + */ 117 + DECLARE_PER_CPU(u8, cpu_llc_id); 114 118 extern char ignore_fpu_irq; 115 119 116 120 void __init cpu_detect(struct cpuinfo_x86 *c);
+2 -1
include/asm-x86/smp_64.h
··· 49 49 */ 50 50 DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); 51 51 DECLARE_PER_CPU(cpumask_t, cpu_core_map); 52 - extern u8 cpu_llc_id[NR_CPUS]; 52 + DECLARE_PER_CPU(u8, cpu_llc_id); 53 53 54 54 #define SMP_TRAMPOLINE_BASE 0x6000 55 55 ··· 121 121 #ifdef CONFIG_SMP 122 122 #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) 123 123 #else 124 + extern unsigned int boot_cpu_id; 124 125 #define cpu_physical_id(cpu) boot_cpu_id 125 126 #endif /* !CONFIG_SMP */ 126 127 #endif