Skip to content

Commit

Permalink
x86: convert cpu_llc_id to be a per cpu variable
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mike Travis authored and Thomas Gleixner committed Oct 19, 2007
1 parent 71fff5e commit b627847
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions arch/x86/kernel/cpu/intel_cacheinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,14 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
if (new_l2) {
l2 = new_l2;
#ifdef CONFIG_X86_HT
cpu_llc_id[cpu] = l2_id;
per_cpu(cpu_llc_id, cpu) = l2_id;
#endif
}

if (new_l3) {
l3 = new_l3;
#ifdef CONFIG_X86_HT
cpu_llc_id[cpu] = l3_id;
per_cpu(cpu_llc_id, cpu) = l3_id;
#endif
}

Expand Down
6 changes: 3 additions & 3 deletions arch/x86/kernel/smpboot_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int smp_num_siblings = 1;
EXPORT_SYMBOL(smp_num_siblings);

/* Last level cache ID of each logical CPU */
int cpu_llc_id[NR_CPUS] __cpuinitdata = {[0 ... NR_CPUS-1] = BAD_APICID};
DEFINE_PER_CPU(u8, cpu_llc_id) = BAD_APICID;

/* representing HT siblings of each logical CPU */
DEFINE_PER_CPU(cpumask_t, cpu_sibling_map);
Expand Down Expand Up @@ -348,8 +348,8 @@ void __cpuinit set_cpu_sibling_map(int cpu)
}

for_each_cpu_mask(i, cpu_sibling_setup_map) {
if (cpu_llc_id[cpu] != BAD_APICID &&
cpu_llc_id[cpu] == cpu_llc_id[i]) {
if (per_cpu(cpu_llc_id, cpu) != BAD_APICID &&
per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) {
cpu_set(i, c[cpu].llc_shared_map);
cpu_set(cpu, c[i].llc_shared_map);
}
Expand Down
6 changes: 3 additions & 3 deletions arch/x86/kernel/smpboot_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int smp_num_siblings = 1;
EXPORT_SYMBOL(smp_num_siblings);

/* Last level cache ID of each logical CPU */
u8 cpu_llc_id[NR_CPUS] __cpuinitdata = {[0 ... NR_CPUS-1] = BAD_APICID};
DEFINE_PER_CPU(u8, cpu_llc_id) = BAD_APICID;

/* Bitmask of currently online CPUs */
cpumask_t cpu_online_map __read_mostly;
Expand Down Expand Up @@ -283,8 +283,8 @@ static inline void set_cpu_sibling_map(int cpu)
}

for_each_cpu_mask(i, cpu_sibling_setup_map) {
if (cpu_llc_id[cpu] != BAD_APICID &&
cpu_llc_id[cpu] == cpu_llc_id[i]) {
if (per_cpu(cpu_llc_id, cpu) != BAD_APICID &&
per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) {
cpu_set(i, c[cpu].llc_shared_map);
cpu_set(cpu, c[i].llc_shared_map);
}
Expand Down
6 changes: 5 additions & 1 deletion include/asm-x86/processor_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ extern struct cpuinfo_x86 cpu_data[];
#define current_cpu_data boot_cpu_data
#endif

extern int cpu_llc_id[NR_CPUS];
/*
* the following now lives in the per cpu area:
* extern int cpu_llc_id[NR_CPUS];
*/
DECLARE_PER_CPU(u8, cpu_llc_id);
extern char ignore_fpu_irq;

void __init cpu_detect(struct cpuinfo_x86 *c);
Expand Down
3 changes: 2 additions & 1 deletion include/asm-x86/smp_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
*/
DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
DECLARE_PER_CPU(cpumask_t, cpu_core_map);
extern u8 cpu_llc_id[NR_CPUS];
DECLARE_PER_CPU(u8, cpu_llc_id);

#define SMP_TRAMPOLINE_BASE 0x6000

Expand Down Expand Up @@ -121,6 +121,7 @@ static __inline int logical_smp_processor_id(void)
#ifdef CONFIG_SMP
#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
#else
extern unsigned int boot_cpu_id;
#define cpu_physical_id(cpu) boot_cpu_id
#endif /* !CONFIG_SMP */
#endif
Expand Down

0 comments on commit b627847

Please sign in to comment.